; LLVM IR from MQCPack/mqcPack :: examples/tools (CheckGauInput)

; 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 [357 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [49 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca [2096 x i8], align 16
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2096, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = sub nsw i32 %12, 1
  %14 = icmp slt i32 %13, 2
  br i1 %14, label %15, label %23

15:                                               ; preds = %2
  %16 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = sub nsw i32 %17, 1
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %15
  call void @mqc_error(ptr noundef @.str.1)
  br label %22

21:                                               ; preds = %15
  call void @mqc_error(ptr noundef @.str.2)
  br label %22

22:                                               ; preds = %21, %20
  br label %23

23:                                               ; preds = %22, %2
  call void @mqc_Global_init()
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = sub nsw i32 %24, 1
  store i32 %25, ptr %11, align 4, !tbaa !5
  %26 = call noalias ptr @malloc(i64 noundef 1024) #6
  store ptr %26, ptr %8, align 8, !tbaa !9
  %27 = call noalias ptr @malloc(i64 noundef 1024) #6
  store ptr %27, ptr %9, align 8, !tbaa !9
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %76, %23
  %29 = load i32, ptr %10, align 4, !tbaa !5
  %30 = load i32, ptr %11, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %32, label %79

32:                                               ; preds = %28
  %33 = load ptr, ptr %5, align 8, !tbaa !9
  %34 = load i32, ptr %10, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds ptr, ptr %33, i64 %35
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  %38 = load ptr, ptr %5, align 8, !tbaa !9
  %39 = load i32, ptr %11, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds ptr, ptr %38, i64 %40
  %42 = load ptr, ptr %41, align 8, !tbaa !9
  %43 = call ptr @mqc_GetMatrixFile(ptr noundef %37, ptr noundef %42)
  store ptr %43, ptr %7, align 8, !tbaa !9
  %44 = load i32, ptr %10, align 4, !tbaa !5
  %45 = icmp sgt i32 %44, 1
  br i1 %45, label %46, label %62

46:                                               ; preds = %32
  %47 = load ptr, ptr %9, align 8, !tbaa !9
  %48 = load i32, ptr %10, align 4, !tbaa !5
  %49 = sub nsw i32 %48, 1
  %50 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %47, ptr noundef @.str.3, i32 noundef %49) #5
  %51 = load ptr, ptr %9, align 8, !tbaa !9
  %52 = load ptr, ptr %8, align 8, !tbaa !9
  %53 = call i32 @setenv(ptr noundef %51, ptr noundef %52, i32 noundef 1) #5
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %61

55:                                               ; preds = %46
  %56 = getelementptr inbounds [2096 x i8], ptr %6, i64 0, i64 0
  %57 = load ptr, ptr %9, align 8, !tbaa !9
  %58 = load ptr, ptr %8, align 8, !tbaa !9
  %59 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %56, ptr noundef @.str.4, ptr noundef %57, ptr noundef %58) #5
  %60 = getelementptr inbounds [2096 x i8], ptr %6, i64 0, i64 0
  call void @mqc_error(ptr noundef %60)
  br label %61

61:                                               ; preds = %55, %46
  br label %62

62:                                               ; preds = %61, %32
  %63 = load ptr, ptr %8, align 8, !tbaa !9
  %64 = load i32, ptr %10, align 4, !tbaa !5
  %65 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %63, ptr noundef @.str.5, i32 noundef %64) #5
  %66 = load ptr, ptr %8, align 8, !tbaa !9
  %67 = load ptr, ptr %7, align 8, !tbaa !9
  %68 = call i32 @setenv(ptr noundef %66, ptr noundef %67, i32 noundef 1) #5
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %75

70:                                               ; preds = %62
  %71 = getelementptr inbounds [2096 x i8], ptr %6, i64 0, i64 0
  %72 = load ptr, ptr %8, align 8, !tbaa !9
  %73 = load ptr, ptr %7, align 8, !tbaa !9
  %74 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %71, ptr noundef @.str.4, ptr noundef %72, ptr noundef %73) #5
  br label %75

75:                                               ; preds = %70, %62
  br label %76

76:                                               ; preds = %75
  %77 = load i32, ptr %10, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %10, align 4, !tbaa !5
  br label %28, !llvm.loop !11

79:                                               ; preds = %28
  %80 = load ptr, ptr %9, align 8, !tbaa !9
  %81 = load i32, ptr %11, align 4, !tbaa !5
  %82 = sub nsw i32 %81, 1
  %83 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %80, ptr noundef @.str.3, i32 noundef %82) #5
  %84 = load ptr, ptr %9, align 8, !tbaa !9
  %85 = call i32 @setenv(ptr noundef %84, ptr noundef @.str.6, i32 noundef 1) #5
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %87, label %92

87:                                               ; preds = %79
  %88 = getelementptr inbounds [2096 x i8], ptr %6, i64 0, i64 0
  %89 = load ptr, ptr %9, align 8, !tbaa !9
  %90 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %88, ptr noundef @.str.7, ptr noundef %89) #5
  %91 = getelementptr inbounds [2096 x i8], ptr %6, i64 0, i64 0
  call void @mqc_error(ptr noundef %91)
  br label %92

92:                                               ; preds = %87, %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 2096, ptr %6) #5
  %93 = load i32, ptr %3, align 4
  ret i32 %93
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @mqc_error(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mqc_Global_init() #0

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

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

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #4

; Function Attrs: nounwind
declare i32 @setenv(ptr noundef, ptr noundef, i32 noundef) #4

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

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 = { "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 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 #4 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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 [357 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [49 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca [2096 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 2096, ptr nonnull %3) #5
  %4 = add i32 %0, -1
  %5 = icmp slt i32 %0, 3
  br i1 %5, label %.sink.split, label %8

.sink.split:                                      ; preds = %2
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %7 = icmp eq i32 %4, 0
  %.str.1..str.2 = select i1 %7, ptr @.str.1, ptr @.str.2
  tail call void @mqc_error(ptr noundef nonnull %.str.1..str.2)
  br label %8

8:                                                ; preds = %.sink.split, %2
  tail call void @mqc_Global_init()
  %9 = tail call noalias dereferenceable_or_null(1024) ptr @malloc(i64 noundef 1024) #6
  %10 = tail call noalias dereferenceable_or_null(1024) ptr @malloc(i64 noundef 1024) #6
  %11 = icmp sgt i32 %0, 2
  br i1 %11, label %12, label %._crit_edge

12:                                               ; preds = %8
  %13 = zext nneg i32 %4 to i64
  %14 = getelementptr inbounds ptr, ptr %1, i64 %13
  %wide.trip.count = zext nneg i32 %4 to i64
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = load ptr, ptr %14, align 8, !tbaa !5
  %18 = tail call ptr @mqc_GetMatrixFile(ptr noundef %16, ptr noundef %17)
  %19 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %9, ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef 1) #5
  %20 = tail call i32 @setenv(ptr noundef %9, ptr noundef %18, i32 noundef 1) #5
  %.not29.peel = icmp eq i32 %20, 0
  br i1 %.not29.peel, label %23, label %21

21:                                               ; preds = %12
  %22 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.4, ptr noundef %9, ptr noundef %18) #5
  br label %23

23:                                               ; preds = %21, %12
  %exitcond.peel.not = icmp eq i32 %4, 2
  br i1 %exitcond.peel.not, label %._crit_edge, label %.peel.next

.peel.next:                                       ; preds = %23, %40
  %indvars.iv = phi i64 [ %indvars.iv.next, %40 ], [ 2, %23 ]
  %24 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = load ptr, ptr %14, align 8, !tbaa !5
  %27 = call ptr @mqc_GetMatrixFile(ptr noundef %25, ptr noundef %26)
  %28 = trunc i64 %indvars.iv to i32
  %29 = add i32 %28, -1
  %30 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %10, ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %29) #5
  %31 = call i32 @setenv(ptr noundef %10, ptr noundef %9, i32 noundef 1) #5
  %.not28 = icmp eq i32 %31, 0
  br i1 %.not28, label %34, label %32

32:                                               ; preds = %.peel.next
  %33 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.4, ptr noundef %10, ptr noundef %9) #5
  call void @mqc_error(ptr noundef nonnull %3)
  br label %34

34:                                               ; preds = %.peel.next, %32
  %35 = trunc nuw nsw i64 %indvars.iv to i32
  %36 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %9, ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %35) #5
  %37 = call i32 @setenv(ptr noundef %9, ptr noundef %27, i32 noundef 1) #5
  %.not29 = icmp eq i32 %37, 0
  br i1 %.not29, label %40, label %38

38:                                               ; preds = %34
  %39 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.4, ptr noundef %9, ptr noundef %27) #5
  br label %40

40:                                               ; preds = %34, %38
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.peel.next, !llvm.loop !9

._crit_edge:                                      ; preds = %40, %23, %8
  %41 = add nsw i32 %0, -2
  %42 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %10, ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %41) #5
  %43 = call i32 @setenv(ptr noundef %10, ptr noundef nonnull @.str.6, i32 noundef 1) #5
  %.not = icmp eq i32 %43, 0
  br i1 %.not, label %46, label %44

44:                                               ; preds = %._crit_edge
  %45 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.7, ptr noundef %10) #5
  call void @mqc_error(ptr noundef nonnull %3)
  br label %46

46:                                               ; preds = %44, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 2096, ptr nonnull %3) #5
  ret i32 0
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @mqc_error(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @mqc_Global_init() 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 #3

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

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @setenv(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

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

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { 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 #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 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass