; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/ThirdParty/MINC/src/libminc/nifti (nifti1_io)

; 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"

%struct.nifti_global_options = type { i32, i32, i32 }
%struct.nifti_type_ele = type { i32, i32, i32, ptr }

@stderr = external global ptr, align 8
@g_opts = external hidden global %struct.nifti_global_options, align 4
@nifti_type_list = external hidden global [43 x %struct.nifti_type_ele], align 16
@.str.412 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.413 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.414 = external hidden unnamed_addr constant [38 x i8], align 1

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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local void @nifti_datatype_sizes(i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @nifti_test_datatype_sizes(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 43, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %74, %1
  %9 = load i32, ptr %6, align 4, !tbaa !5
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %12, label %77

12:                                               ; preds = %8
  store i32 -1, ptr %5, align 4, !tbaa !5
  store i32 -1, ptr %4, align 4, !tbaa !5
  %13 = load i32, ptr %6, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [43 x %struct.nifti_type_ele], ptr @nifti_type_list, i64 0, i64 %14
  %16 = getelementptr inbounds %struct.nifti_type_ele, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !9
  call void @nifti_datatype_sizes(i32 noundef %17, ptr noundef %4, ptr noundef %5)
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = icmp slt i32 %18, 0
  br i1 %19, label %39, label %20

20:                                               ; preds = %12
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 0
  br i1 %22, label %39, label %23

23:                                               ; preds = %20
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [43 x %struct.nifti_type_ele], ptr @nifti_type_list, i64 0, i64 %26
  %28 = getelementptr inbounds %struct.nifti_type_ele, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !12
  %30 = icmp ne i32 %24, %29
  br i1 %30, label %39, label %31

31:                                               ; preds = %23
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [43 x %struct.nifti_type_ele], ptr @nifti_type_list, i64 0, i64 %34
  %36 = getelementptr inbounds %struct.nifti_type_ele, ptr %35, i32 0, i32 2
  %37 = load i32, ptr %36, align 8, !tbaa !13
  %38 = icmp ne i32 %32, %37
  br i1 %38, label %39, label %73

39:                                               ; preds = %31, %23, %20, %12
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %45, label %42

42:                                               ; preds = %39
  %43 = load i32, ptr @g_opts, align 4, !tbaa !14
  %44 = icmp sgt i32 %43, 2
  br i1 %44, label %45, label %70

45:                                               ; preds = %42, %39
  %46 = load ptr, ptr @stderr, align 8, !tbaa !16
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [43 x %struct.nifti_type_ele], ptr @nifti_type_list, i64 0, i64 %48
  %50 = getelementptr inbounds %struct.nifti_type_ele, ptr %49, i32 0, i32 3
  %51 = load ptr, ptr %50, align 8, !tbaa !17
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [43 x %struct.nifti_type_ele], ptr @nifti_type_list, i64 0, i64 %53
  %55 = getelementptr inbounds %struct.nifti_type_ele, ptr %54, i32 0, i32 0
  %56 = load i32, ptr %55, align 8, !tbaa !9
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [43 x %struct.nifti_type_ele], ptr @nifti_type_list, i64 0, i64 %58
  %60 = getelementptr inbounds %struct.nifti_type_ele, ptr %59, i32 0, i32 1
  %61 = load i32, ptr %60, align 4, !tbaa !12
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [43 x %struct.nifti_type_ele], ptr @nifti_type_list, i64 0, i64 %63
  %65 = getelementptr inbounds %struct.nifti_type_ele, ptr %64, i32 0, i32 2
  %66 = load i32, ptr %65, align 8, !tbaa !13
  %67 = load i32, ptr %4, align 4, !tbaa !5
  %68 = load i32, ptr %5, align 4, !tbaa !5
  %69 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef @.str.412, ptr noundef %51, i32 noundef %56, i32 noundef %61, i32 noundef %66, i32 noundef %67, i32 noundef %68) #3
  br label %70

70:                                               ; preds = %45, %42
  %71 = load i32, ptr %7, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %7, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %70, %31
  br label %74

74:                                               ; preds = %73
  %75 = load i32, ptr %6, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %6, align 4, !tbaa !5
  br label %8, !llvm.loop !18

77:                                               ; preds = %8
  %78 = load i32, ptr %7, align 4, !tbaa !5
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %84

80:                                               ; preds = %77
  %81 = load ptr, ptr @stderr, align 8, !tbaa !16
  %82 = load i32, ptr %7, align 4, !tbaa !5
  %83 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %81, ptr noundef @.str.413, i32 noundef %82) #3
  br label %94

84:                                               ; preds = %77
  %85 = load i32, ptr %2, align 4, !tbaa !5
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %90, label %87

87:                                               ; preds = %84
  %88 = load i32, ptr @g_opts, align 4, !tbaa !14
  %89 = icmp sgt i32 %88, 1
  br i1 %89, label %90, label %93

90:                                               ; preds = %87, %84
  %91 = load ptr, ptr @stderr, align 8, !tbaa !16
  %92 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %91, ptr noundef @.str.414) #3
  br label %93

93:                                               ; preds = %90, %87
  br label %94

94:                                               ; preds = %93, %80
  %95 = load i32, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret i32 %95
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !11, i64 16}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !6, i64 4}
!13 = !{!10, !6, i64 8}
!14 = !{!15, !6, i64 0}
!15 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !11, i64 16}
!18 = distinct !{!18, !19}
!19 = !{!"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"

%struct.nifti_global_options = type { i32, i32, i32 }
%struct.nifti_type_ele = type { i32, i32, i32, ptr }

@stderr = external local_unnamed_addr global ptr, align 8
@g_opts = external hidden local_unnamed_addr global %struct.nifti_global_options, align 4
@nifti_type_list = external hidden local_unnamed_addr global [43 x %struct.nifti_type_ele], align 16
@.str.412 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.413 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.414 = external hidden unnamed_addr constant [38 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @nifti_datatype_sizes(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @nifti_test_datatype_sizes(i32 noundef %0) local_unnamed_addr #2 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %.not30 = icmp eq i32 %0, 0
  br i1 %.not30, label %.split, label %.split.us

.split.us:                                        ; preds = %1, %22
  %indvars.iv = phi i64 [ %indvars.iv.next, %22 ], [ 0, %1 ]
  %.027.us = phi i32 [ %.1.us, %22 ], [ 0, %1 ]
  store i32 -1, ptr %3, align 4, !tbaa !5
  store i32 -1, ptr %2, align 4, !tbaa !5
  %4 = getelementptr inbounds [43 x %struct.nifti_type_ele], ptr @nifti_type_list, i64 0, i64 %indvars.iv
  %5 = load i32, ptr %4, align 8, !tbaa !9
  call void @nifti_datatype_sizes(i32 noundef %5, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, -1
  %8 = load i32, ptr %3, align 4
  %9 = icmp sgt i32 %8, -1
  %or.cond.us.not41 = select i1 %7, i1 %9, i1 false
  %.phi.trans.insert = getelementptr inbounds i8, ptr %4, i64 4
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !12
  %.not24.us = icmp eq i32 %6, %.pre
  %or.cond38 = select i1 %or.cond.us.not41, i1 %.not24.us, i1 false
  br i1 %or.cond38, label %10, label %.split.us._crit_edge

10:                                               ; preds = %.split.us
  %11 = getelementptr inbounds i8, ptr %4, i64 8
  %12 = load i32, ptr %11, align 8, !tbaa !13
  %.not25.us = icmp eq i32 %8, %12
  br i1 %.not25.us, label %22, label %.split.us._crit_edge

.split.us._crit_edge:                             ; preds = %.split.us, %10
  %13 = phi i32 [ %6, %10 ], [ %.pre, %.split.us ]
  %14 = load ptr, ptr @stderr, align 8, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %4, i64 16
  %16 = load ptr, ptr %15, align 8, !tbaa !15
  %17 = load i32, ptr %4, align 8, !tbaa !9
  %18 = getelementptr inbounds i8, ptr %4, i64 8
  %19 = load i32, ptr %18, align 8, !tbaa !13
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.412, ptr noundef %16, i32 noundef %17, i32 noundef %13, i32 noundef %19, i32 noundef %6, i32 noundef %8) #4
  %21 = add nsw i32 %.027.us, 1
  br label %22

22:                                               ; preds = %.split.us._crit_edge, %10
  %.1.us = phi i32 [ %21, %.split.us._crit_edge ], [ %.027.us, %10 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 43
  br i1 %exitcond.not, label %.split29.us, label %.split.us, !llvm.loop !16

.split:                                           ; preds = %1, %50
  %indvars.iv33 = phi i64 [ %indvars.iv.next34, %50 ], [ 0, %1 ]
  %.027 = phi i32 [ %.1, %50 ], [ 0, %1 ]
  store i32 -1, ptr %3, align 4, !tbaa !5
  store i32 -1, ptr %2, align 4, !tbaa !5
  %23 = getelementptr inbounds [43 x %struct.nifti_type_ele], ptr @nifti_type_list, i64 0, i64 %indvars.iv33
  %24 = load i32, ptr %23, align 8, !tbaa !9
  call void @nifti_datatype_sizes(i32 noundef %24, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = icmp slt i32 %25, 0
  %27 = load i32, ptr %3, align 4
  %28 = icmp slt i32 %27, 0
  %or.cond = select i1 %26, i1 true, i1 %28
  br i1 %or.cond, label %35, label %29

29:                                               ; preds = %.split
  %30 = getelementptr inbounds i8, ptr %23, i64 4
  %31 = load i32, ptr %30, align 4, !tbaa !12
  %.not24 = icmp eq i32 %25, %31
  br i1 %.not24, label %32, label %35

32:                                               ; preds = %29
  %33 = getelementptr inbounds i8, ptr %23, i64 8
  %34 = load i32, ptr %33, align 8, !tbaa !13
  %.not25 = icmp eq i32 %27, %34
  br i1 %.not25, label %50, label %35

35:                                               ; preds = %32, %29, %.split
  %36 = load i32, ptr @g_opts, align 4
  %37 = icmp sgt i32 %36, 2
  br i1 %37, label %38, label %48

38:                                               ; preds = %35
  %39 = load ptr, ptr @stderr, align 8, !tbaa !14
  %40 = getelementptr inbounds i8, ptr %23, i64 16
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  %42 = load i32, ptr %23, align 8, !tbaa !9
  %43 = getelementptr inbounds i8, ptr %23, i64 4
  %44 = load i32, ptr %43, align 4, !tbaa !12
  %45 = getelementptr inbounds i8, ptr %23, i64 8
  %46 = load i32, ptr %45, align 8, !tbaa !13
  %47 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef nonnull @.str.412, ptr noundef %41, i32 noundef %42, i32 noundef %44, i32 noundef %46, i32 noundef %25, i32 noundef %27) #4
  br label %48

48:                                               ; preds = %35, %38
  %49 = add nsw i32 %.027, 1
  br label %50

50:                                               ; preds = %32, %48
  %.1 = phi i32 [ %49, %48 ], [ %.027, %32 ]
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %exitcond36.not = icmp eq i64 %indvars.iv.next34, 43
  br i1 %exitcond36.not, label %.split29.us, label %.split, !llvm.loop !16

.split29.us:                                      ; preds = %22, %50
  %.us-phi = phi i32 [ %.1, %50 ], [ %.1.us, %22 ]
  %.not = icmp eq i32 %.us-phi, 0
  br i1 %.not, label %54, label %51

51:                                               ; preds = %.split29.us
  %52 = load ptr, ptr @stderr, align 8, !tbaa !14
  %53 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %52, ptr noundef nonnull @.str.413, i32 noundef %.us-phi) #4
  br label %61

54:                                               ; preds = %.split29.us
  %55 = icmp ne i32 %0, 0
  %56 = load i32, ptr @g_opts, align 4
  %57 = icmp sgt i32 %56, 1
  %or.cond5 = select i1 %55, i1 true, i1 %57
  br i1 %or.cond5, label %58, label %61

58:                                               ; preds = %54
  %59 = load ptr, ptr @stderr, align 8, !tbaa !14
  %60 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %59, ptr noundef nonnull @.str.414) #4
  br label %61

61:                                               ; preds = %58, %54, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  ret i32 %.us-phi
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { nounwind }
attributes #4 = { cold 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !11, i64 16}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !6, i64 4}
!13 = !{!10, !6, i64 8}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !11, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass