; LLVM IR from wuzhouhui/leetcode :: 120_triangle (main)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @minimumTotal(ptr noundef, i32 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %3 = call noalias ptr @malloc(i64 noundef 32) #6
  store ptr %3, ptr %2, align 8, !tbaa !5
  %4 = call noalias ptr @malloc(i64 noundef 4) #6
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds ptr, ptr %5, i64 0
  store ptr %4, ptr %6, align 8, !tbaa !5
  %7 = call noalias ptr @malloc(i64 noundef 8) #6
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds ptr, ptr %8, i64 1
  store ptr %7, ptr %9, align 8, !tbaa !5
  %10 = call noalias ptr @malloc(i64 noundef 12) #6
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds ptr, ptr %11, i64 2
  store ptr %10, ptr %12, align 8, !tbaa !5
  %13 = call noalias ptr @malloc(i64 noundef 16) #6
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds ptr, ptr %14, i64 3
  store ptr %13, ptr %15, align 8, !tbaa !5
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds ptr, ptr %16, i64 0
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %19 = getelementptr inbounds i32, ptr %18, i64 0
  store i32 2, ptr %19, align 4, !tbaa !9
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds ptr, ptr %20, i64 1
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds i32, ptr %22, i64 0
  store i32 3, ptr %23, align 4, !tbaa !9
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds ptr, ptr %24, i64 1
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = getelementptr inbounds i32, ptr %26, i64 1
  store i32 4, ptr %27, align 4, !tbaa !9
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds ptr, ptr %28, i64 2
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = getelementptr inbounds i32, ptr %30, i64 0
  store i32 6, ptr %31, align 4, !tbaa !9
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds ptr, ptr %32, i64 2
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = getelementptr inbounds i32, ptr %34, i64 1
  store i32 5, ptr %35, align 4, !tbaa !9
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds ptr, ptr %36, i64 2
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = getelementptr inbounds i32, ptr %38, i64 2
  store i32 7, ptr %39, align 4, !tbaa !9
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds ptr, ptr %40, i64 3
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = getelementptr inbounds i32, ptr %42, i64 0
  store i32 4, ptr %43, align 4, !tbaa !9
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds ptr, ptr %44, i64 3
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  %47 = getelementptr inbounds i32, ptr %46, i64 1
  store i32 1, ptr %47, align 4, !tbaa !9
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds ptr, ptr %48, i64 3
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  %51 = getelementptr inbounds i32, ptr %50, i64 2
  store i32 8, ptr %51, align 4, !tbaa !9
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds ptr, ptr %52, i64 3
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  %55 = getelementptr inbounds i32, ptr %54, i64 3
  store i32 3, ptr %55, align 4, !tbaa !9
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = call i32 @minimumTotal(ptr noundef %56, i32 noundef 4)
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %57)
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds ptr, ptr %59, i64 0
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  call void @free(ptr noundef %61) #5
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds ptr, ptr %62, i64 1
  %64 = load ptr, ptr %63, align 8, !tbaa !5
  call void @free(ptr noundef %64) #5
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds ptr, ptr %65, i64 2
  %67 = load ptr, ptr %66, align 8, !tbaa !5
  call void @free(ptr noundef %67) #5
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds ptr, ptr %68, i64 3
  %70 = load ptr, ptr %69, align 8, !tbaa !5
  call void @free(ptr noundef %70) #5
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %71) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  ret i32 0
}

declare i32 @printf(ptr noundef, ...) #4

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @minimumTotal(ptr noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #4
  %2 = tail call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #4
  store ptr %2, ptr %1, align 8, !tbaa !5
  %3 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #4
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  store ptr %3, ptr %4, align 8, !tbaa !5
  %5 = tail call noalias dereferenceable_or_null(12) ptr @malloc(i64 noundef 12) #4
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr %5, ptr %6, align 8, !tbaa !5
  %7 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #4
  %8 = getelementptr inbounds i8, ptr %1, i64 24
  store ptr %7, ptr %8, align 8, !tbaa !5
  store i32 2, ptr %2, align 4, !tbaa !9
  store i32 3, ptr %3, align 4, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 4, ptr %9, align 4, !tbaa !9
  store i32 6, ptr %5, align 4, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 5, ptr %10, align 4, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %5, i64 8
  store i32 7, ptr %11, align 4, !tbaa !9
  store <4 x i32> <i32 4, i32 1, i32 8, i32 3>, ptr %7, align 4, !tbaa !9
  %12 = tail call i32 @minimumTotal(ptr noundef nonnull %1, i32 noundef 4)
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %12)
  %14 = load ptr, ptr %1, align 8, !tbaa !5
  tail call void @free(ptr noundef %14) #5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  tail call void @free(ptr noundef %15) #5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  tail call void @free(ptr noundef %16) #5
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  tail call void @free(ptr noundef %17) #5
  tail call void @free(ptr noundef %1) #5
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind allocsize(0) }
attributes #5 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass