program pyramid
  implicit none
  integer              :: n, highest, idx, i, j, k, hc
  integer, allocatable :: x(:), y(:), h(:)
  logical              :: invalid
  read(*,*) n
  allocate(x(n),y(n),h(n))
  highest = 0
  idx = 0
  do i = 1, n
     read(*,*) x(i),y(i),h(i)
     if (h(i) .gt. highest) then
        highest = h(i)
        idx = i
     end if
  end do
  do i = 0, 100
     do j = 0, 100
        hc = highest + abs(i-x(idx)) + abs(j-y(idx))
        invalid = .false.
        do k = 1, n
           if (h(k) .ne. max(hc - abs(i-x(k)) - abs(j-y(k)),0)) then
              invalid = .true.
              exit
           end if
        end do
        if (invalid) cycle
        deallocate(x,y,h)
        write(*,'(i0,x,i0,x,i0)') i, j, hc
        stop
     end do
  end do
end program pyramid
; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QFEh.0 = internal unnamed_addr global ptr null
@_QFEx.0 = internal unnamed_addr global ptr null
@_QFEy.0 = internal unnamed_addr global ptr null
@_QQcl.8aa5e08e7745cbdd6e5ea26dbefe6689 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_5456/source.f\00"
@_QQcl.2869302C782C69302C782C693029 = linkonce constant [14 x i8] c"(i0,x,i0,x,i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i32, align 4
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.8aa5e08e7745cbdd6e5ea26dbefe6689, i32 6)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 4)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = load i32, ptr %1, align 4, !tbaa !3
  %6 = call i32 @llvm.smax.i32(i32 %5, i32 0)
  %7 = zext i32 %6 to i64
  %8 = shl nuw nsw i64 %7, 2
  %9 = call ptr @malloc(i64 %8)
  store ptr %9, ptr @_QFEx.0, align 8, !tbaa !7
  %10 = call ptr @malloc(i64 %8)
  store ptr %10, ptr @_QFEy.0, align 8, !tbaa !7
  %11 = call ptr @malloc(i64 %8)
  store ptr %11, ptr @_QFEh.0, align 8, !tbaa !7
  %12 = icmp sgt i32 %5, 0
  br i1 %12, label %.lr.ph.preheader, label %.preheader662.thread

.preheader662.thread:                             ; preds = %0
  %13 = getelementptr i32, ptr %9, i64 -1
  %14 = load i32, ptr %13, align 4, !tbaa !3
  %15 = getelementptr i32, ptr %10, i64 -1
  %16 = load i32, ptr %15, align 4, !tbaa !3
  br label %.preheader.us

.lr.ph.preheader:                                 ; preds = %0
  %17 = zext i32 %5 to i64
  br label %.lr.ph

.preheader662:                                    ; preds = %.lr.ph
  %.unpack.pre = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %.unpack527.pre = load ptr, ptr @_QFEy.0, align 8, !tbaa !7
  %.pre = load i32, ptr %1, align 4, !tbaa !3
  %18 = sext i32 %spec.select659 to i64
  %19 = add nsw i64 %18, -1
  %20 = getelementptr i32, ptr %.unpack.pre, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !3
  %22 = add nsw i64 %18, -1
  %23 = getelementptr i32, ptr %.unpack527.pre, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !3
  %25 = icmp slt i32 %.pre, 1
  br i1 %25, label %.preheader.us, label %.preheader

.preheader.us:                                    ; preds = %.preheader662.thread, %.preheader662
  %26 = phi i32 [ %16, %.preheader662.thread ], [ %24, %.preheader662 ]
  %27 = phi i32 [ %14, %.preheader662.thread ], [ %21, %.preheader662 ]
  %.0482.lcssa732 = phi i32 [ 0, %.preheader662.thread ], [ %spec.select, %.preheader662 ]
  %.unpack731 = phi ptr [ %9, %.preheader662.thread ], [ %.unpack.pre, %.preheader662 ]
  %.unpack527729 = phi ptr [ %10, %.preheader662.thread ], [ %.unpack527.pre, %.preheader662 ]
  %.unpack563727 = phi ptr [ %11, %.preheader662.thread ], [ %.unpack647, %.preheader662 ]
  %28 = call i32 @llvm.abs.i32(i32 %27, i1 false)
  %29 = add i32 %28, %.0482.lcssa732
  %30 = call i32 @llvm.abs.i32(i32 %26, i1 false)
  %31 = add i32 %29, %30
  br label %.critedge

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %.0480666 = phi i32 [ 0, %.lr.ph.preheader ], [ %spec.select659, %.lr.ph ]
  %.0482665 = phi i32 [ 0, %.lr.ph.preheader ], [ %spec.select, %.lr.ph ]
  %32 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.8aa5e08e7745cbdd6e5ea26dbefe6689, i32 11)
  %.unpack611 = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %33 = add nsw i64 %indvars.iv, -1
  %34 = getelementptr i32, ptr %.unpack611, i64 %33
  %35 = call i1 @_FortranAioInputInteger(ptr %32, ptr %34, i32 4)
  %.unpack623 = load ptr, ptr @_QFEy.0, align 8, !tbaa !7
  %36 = add nsw i64 %indvars.iv, -1
  %37 = getelementptr i32, ptr %.unpack623, i64 %36
  %38 = call i1 @_FortranAioInputInteger(ptr %32, ptr %37, i32 4)
  %.unpack635 = load ptr, ptr @_QFEh.0, align 8, !tbaa !7
  %39 = add nsw i64 %indvars.iv, -1
  %40 = getelementptr i32, ptr %.unpack635, i64 %39
  %41 = call i1 @_FortranAioInputInteger(ptr %32, ptr %40, i32 4)
  %42 = call i32 @_FortranAioEndIoStatement(ptr %32)
  %.unpack647 = load ptr, ptr @_QFEh.0, align 8, !tbaa !7
  %43 = add nsw i64 %indvars.iv, -1
  %44 = getelementptr i32, ptr %.unpack647, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !3
  %46 = icmp sgt i32 %45, %.0482665
  %spec.select = call i32 @llvm.smax.i32(i32 %45, i32 %.0482665)
  %47 = trunc i64 %indvars.iv to i32
  %spec.select659 = select i1 %46, i32 %47, i32 %.0480666
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, %17
  br i1 %exitcond.not, label %.preheader662, label %.lr.ph

.preheader:                                       ; preds = %.preheader662, %82
  %.0481699 = phi i32 [ %83, %82 ], [ 0, %.preheader662 ]
  %48 = sub i32 %.0481699, %21
  %49 = call i32 @llvm.abs.i32(i32 %48, i1 false)
  %50 = add i32 %49, %spec.select
  br label %.lr.ph670

.lr.ph670:                                        ; preds = %.preheader, %80
  %.0478683 = phi i32 [ 0, %.preheader ], [ %81, %80 ]
  %51 = sub i32 %.0478683, %24
  %52 = call i32 @llvm.abs.i32(i32 %51, i1 false)
  %53 = add i32 %50, %52
  br label %54

54:                                               ; preds = %.lr.ph670, %72
  %.0669 = phi i32 [ 1, %.lr.ph670 ], [ %73, %72 ]
  %55 = sext i32 %.0669 to i64
  %56 = add nsw i64 %55, -1
  %57 = getelementptr i32, ptr %.unpack647, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !3
  %59 = add nsw i64 %55, -1
  %60 = getelementptr i32, ptr %.unpack.pre, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !3
  %62 = sub i32 %.0481699, %61
  %63 = call i32 @llvm.abs.i32(i32 %62, i1 false)
  %64 = add nsw i64 %55, -1
  %65 = getelementptr i32, ptr %.unpack527.pre, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !3
  %67 = sub i32 %.0478683, %66
  %68 = call i32 @llvm.abs.i32(i32 %67, i1 false)
  %69 = add i32 %63, %68
  %70 = sub i32 %53, %69
  %71 = call i32 @llvm.smax.i32(i32 %70, i32 0)
  %.not = icmp eq i32 %58, %71
  br i1 %.not, label %72, label %80

72:                                               ; preds = %54
  %73 = add nuw i32 %.0669, 1
  %exitcond709 = icmp eq i32 %.0669, %.pre
  br i1 %exitcond709, label %.critedge, label %54

.critedge:                                        ; preds = %72, %.preheader.us
  %.unpack730 = phi ptr [ %.unpack731, %.preheader.us ], [ %.unpack.pre, %72 ]
  %.unpack527728 = phi ptr [ %.unpack527729, %.preheader.us ], [ %.unpack527.pre, %72 ]
  %.unpack563726 = phi ptr [ %.unpack563727, %.preheader.us ], [ %.unpack647, %72 ]
  %.0481.lcssa664 = phi i32 [ 0, %.preheader.us ], [ %.0481699, %72 ]
  %.lcssa = phi i32 [ %31, %.preheader.us ], [ %53, %72 ]
  %.0478.lcssa663 = phi i32 [ 0, %.preheader.us ], [ %.0478683, %72 ]
  call void @free(ptr nonnull %.unpack730)
  store ptr null, ptr @_QFEx.0, align 8, !tbaa !7
  call void @free(ptr nonnull %.unpack527728)
  store ptr null, ptr @_QFEy.0, align 8, !tbaa !7
  call void @free(ptr %.unpack563726)
  store ptr null, ptr @_QFEh.0, align 8, !tbaa !7
  %74 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.2869302C782C69302C782C693029, i64 14, ptr null, i32 -1, ptr nonnull @_QQcl.8aa5e08e7745cbdd6e5ea26dbefe6689, i32 29)
  %75 = call i1 @_FortranAioOutputInteger32(ptr %74, i32 %.0481.lcssa664)
  %76 = call i1 @_FortranAioOutputInteger32(ptr %74, i32 %.0478.lcssa663)
  %77 = call i1 @_FortranAioOutputInteger32(ptr %74, i32 %.lcssa)
  %78 = call i32 @_FortranAioEndIoStatement(ptr %74)
  %79 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

80:                                               ; preds = %54
  %81 = add nuw nsw i32 %.0478683, 1
  %exitcond710.not = icmp eq i32 %81, 101
  br i1 %exitcond710.not, label %82, label %.lr.ph670

82:                                               ; preds = %80
  %83 = add nuw nsw i32 %.0481699, 1
  %exitcond711.not = icmp eq i32 %83, 101
  br i1 %exitcond711.not, label %84, label %.preheader

84:                                               ; preds = %82
  ret void
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

declare {} @_FortranAStopStatement(i32, i1, i1) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #2

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
