; 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_1_header = type { i32, [10 x i8], [18 x i8], i32, i16, i8, i8, [8 x i16], float, float, float, i16, i16, i16, i16, [8 x float], float, float, float, i16, i8, i8, float, float, float, float, i32, i32, [80 x i8], [24 x i8], i16, i16, float, float, float, float, float, float, [4 x float], [4 x float], [4 x float], [16 x i8], [4 x i8] }

@stderr = external global ptr, align 8
@g_opts = external hidden global %struct.nifti_global_options, align 4
@.str.219 = external hidden unnamed_addr constant [4 x i8], align 1
@__const.nifti_make_new_header.default_dims = external hidden unnamed_addr constant [8 x i32], align 16
@.str.220 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.221 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.222 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.223 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.224 = external hidden unnamed_addr constant [47 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
declare ptr @strcpy(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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @nifti_is_valid_datatype(i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @nifti_make_new_header(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca [8 x i32], align 16
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %7, ptr align 16 @__const.nifti_make_new_header.default_dims, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, 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
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %18

16:                                               ; preds = %2
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %17, ptr %8, align 8, !tbaa !5
  br label %20

18:                                               ; preds = %2
  %19 = getelementptr inbounds [8 x i32], ptr %7, i64 0, i64 0
  store ptr %19, ptr %8, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %18, %16
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds i32, ptr %21, i64 0
  %23 = load i32, ptr %22, align 4, !tbaa !9
  %24 = icmp slt i32 %23, 1
  br i1 %24, label %30, label %25

25:                                               ; preds = %20
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds i32, ptr %26, i64 0
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = icmp sgt i32 %28, 7
  br i1 %29, label %30, label %37

30:                                               ; preds = %25, %20
  %31 = load ptr, ptr @stderr, align 8, !tbaa !5
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds i32, ptr %32, i64 0
  %34 = load i32, ptr %33, align 4, !tbaa !9
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str.220, i32 noundef %34) #5
  %36 = getelementptr inbounds [8 x i32], ptr %7, i64 0, i64 0
  store ptr %36, ptr %8, align 8, !tbaa !5
  br label %66

37:                                               ; preds = %25
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %62, %37
  %39 = load i32, ptr %10, align 4, !tbaa !9
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = getelementptr inbounds i32, ptr %40, i64 0
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = icmp sle i32 %39, %42
  br i1 %43, label %44, label %65

44:                                               ; preds = %38
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = load i32, ptr %10, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i32, ptr %45, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !9
  %50 = icmp slt i32 %49, 1
  br i1 %50, label %51, label %61

51:                                               ; preds = %44
  %52 = load ptr, ptr @stderr, align 8, !tbaa !5
  %53 = load i32, ptr %10, align 4, !tbaa !9
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = load i32, ptr %10, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i32, ptr %54, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !9
  %59 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %52, ptr noundef @.str.221, i32 noundef %53, i32 noundef %58) #5
  %60 = getelementptr inbounds [8 x i32], ptr %7, i64 0, i64 0
  store ptr %60, ptr %8, align 8, !tbaa !5
  br label %65

61:                                               ; preds = %44
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %10, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %10, align 4, !tbaa !9
  br label %38, !llvm.loop !11

65:                                               ; preds = %51, %38
  br label %66

66:                                               ; preds = %65, %30
  %67 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %67, ptr %9, align 4, !tbaa !9
  %68 = load i32, ptr %9, align 4, !tbaa !9
  %69 = call i32 @nifti_is_valid_datatype(i32 noundef %68)
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %75, label %71

71:                                               ; preds = %66
  %72 = load ptr, ptr @stderr, align 8, !tbaa !5
  %73 = load i32, ptr %9, align 4, !tbaa !9
  %74 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %72, ptr noundef @.str.222, i32 noundef %73) #5
  store i32 16, ptr %9, align 4, !tbaa !9
  br label %75

75:                                               ; preds = %71, %66
  %76 = load i32, ptr @g_opts, align 4, !tbaa !13
  %77 = icmp sgt i32 %76, 1
  br i1 %77, label %78, label %85

78:                                               ; preds = %75
  %79 = load ptr, ptr @stderr, align 8, !tbaa !5
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = getelementptr inbounds i32, ptr %80, i64 0
  %82 = load i32, ptr %81, align 4, !tbaa !9
  %83 = load i32, ptr %9, align 4, !tbaa !9
  %84 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %79, ptr noundef @.str.223, i32 noundef %82, i32 noundef %83) #5
  br label %85

85:                                               ; preds = %78, %75
  %86 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 348) #6
  store ptr %86, ptr %6, align 8, !tbaa !5
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = icmp ne ptr %87, null
  br i1 %88, label %92, label %89

89:                                               ; preds = %85
  %90 = load ptr, ptr @stderr, align 8, !tbaa !5
  %91 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %90, ptr noundef @.str.224) #5
  store ptr null, ptr %3, align 8
  store i32 1, ptr %13, align 4
  br label %152

92:                                               ; preds = %85
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.nifti_1_header, ptr %93, i32 0, i32 0
  store i32 348, ptr %94, align 4, !tbaa !15
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.nifti_1_header, ptr %95, i32 0, i32 5
  store i8 114, ptr %96, align 2, !tbaa !19
  %97 = load ptr, ptr %8, align 8, !tbaa !5
  %98 = getelementptr inbounds i32, ptr %97, i64 0
  %99 = load i32, ptr %98, align 4, !tbaa !9
  %100 = trunc i32 %99 to i16
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.nifti_1_header, ptr %101, i32 0, i32 7
  %103 = getelementptr inbounds [8 x i16], ptr %102, i64 0, i64 0
  store i16 %100, ptr %103, align 4, !tbaa !20
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.nifti_1_header, ptr %104, i32 0, i32 15
  %106 = getelementptr inbounds [8 x float], ptr %105, i64 0, i64 0
  store float 0.000000e+00, ptr %106, align 4, !tbaa !21
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %107

107:                                              ; preds = %130, %92
  %108 = load i32, ptr %10, align 4, !tbaa !9
  %109 = load ptr, ptr %8, align 8, !tbaa !5
  %110 = getelementptr inbounds i32, ptr %109, i64 0
  %111 = load i32, ptr %110, align 4, !tbaa !9
  %112 = icmp sle i32 %108, %111
  br i1 %112, label %113, label %133

113:                                              ; preds = %107
  %114 = load ptr, ptr %8, align 8, !tbaa !5
  %115 = load i32, ptr %10, align 4, !tbaa !9
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds i32, ptr %114, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !9
  %119 = trunc i32 %118 to i16
  %120 = load ptr, ptr %6, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.nifti_1_header, ptr %120, i32 0, i32 7
  %122 = load i32, ptr %10, align 4, !tbaa !9
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [8 x i16], ptr %121, i64 0, i64 %123
  store i16 %119, ptr %124, align 2, !tbaa !20
  %125 = load ptr, ptr %6, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.nifti_1_header, ptr %125, i32 0, i32 15
  %127 = load i32, ptr %10, align 4, !tbaa !9
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [8 x float], ptr %126, i64 0, i64 %128
  store float 1.000000e+00, ptr %129, align 4, !tbaa !21
  br label %130

130:                                              ; preds = %113
  %131 = load i32, ptr %10, align 4, !tbaa !9
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %10, align 4, !tbaa !9
  br label %107, !llvm.loop !22

133:                                              ; preds = %107
  %134 = load i32, ptr %9, align 4, !tbaa !9
  %135 = trunc i32 %134 to i16
  %136 = load ptr, ptr %6, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.nifti_1_header, ptr %136, i32 0, i32 12
  store i16 %135, ptr %137, align 2, !tbaa !23
  %138 = load ptr, ptr %6, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.nifti_1_header, ptr %138, i32 0, i32 12
  %140 = load i16, ptr %139, align 2, !tbaa !23
  %141 = sext i16 %140 to i32
  call void @nifti_datatype_sizes(i32 noundef %141, ptr noundef %11, ptr noundef %12)
  %142 = load i32, ptr %11, align 4, !tbaa !9
  %143 = mul nsw i32 8, %142
  %144 = trunc i32 %143 to i16
  %145 = load ptr, ptr %6, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.nifti_1_header, ptr %145, i32 0, i32 13
  store i16 %144, ptr %146, align 4, !tbaa !24
  %147 = load ptr, ptr %6, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.nifti_1_header, ptr %147, i32 0, i32 42
  %149 = getelementptr inbounds [4 x i8], ptr %148, i64 0, i64 0
  %150 = call ptr @strcpy(ptr noundef %149, ptr noundef @.str.219) #5
  %151 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %151, ptr %3, align 8
  store i32 1, ptr %13, align 4
  br label %152

152:                                              ; preds = %133, %89
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  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 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %153 = load ptr, ptr %3, align 8
  ret ptr %153
}

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind allocsize(0,1) "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,1) }

!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}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 0}
!14 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!15 = !{!16, !10, i64 0}
!16 = !{!"nifti_1_header", !10, i64 0, !7, i64 4, !7, i64 14, !10, i64 32, !17, i64 36, !7, i64 38, !7, i64 39, !7, i64 40, !18, i64 56, !18, i64 60, !18, i64 64, !17, i64 68, !17, i64 70, !17, i64 72, !17, i64 74, !7, i64 76, !18, i64 108, !18, i64 112, !18, i64 116, !17, i64 120, !7, i64 122, !7, i64 123, !18, i64 124, !18, i64 128, !18, i64 132, !18, i64 136, !10, i64 140, !10, i64 144, !7, i64 148, !7, i64 228, !17, i64 252, !17, i64 254, !18, i64 256, !18, i64 260, !18, i64 264, !18, i64 268, !18, i64 272, !18, i64 276, !7, i64 280, !7, i64 296, !7, i64 312, !7, i64 328, !7, i64 344}
!17 = !{!"short", !7, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = !{!16, !7, i64 38}
!20 = !{!17, !17, i64 0}
!21 = !{!18, !18, i64 0}
!22 = distinct !{!22, !12}
!23 = !{!16, !17, i64 70}
!24 = !{!16, !17, i64 72}


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

@stderr = external local_unnamed_addr global ptr, align 8
@g_opts = external hidden local_unnamed_addr global %struct.nifti_global_options, align 4
@.str.219 = external hidden unnamed_addr constant [4 x i8], align 1
@__const.nifti_make_new_header.default_dims = external hidden unnamed_addr constant [8 x i32], align 16
@.str.220 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.221 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.222 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.223 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.224 = external hidden unnamed_addr constant [47 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: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @nifti_is_valid_datatype(i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @nifti_make_new_header(ptr noundef readonly %0, i32 noundef %1) local_unnamed_addr #3 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  %.not = icmp eq ptr %0, null
  %__const.nifti_make_new_header.default_dims. = select i1 %.not, ptr @__const.nifti_make_new_header.default_dims, ptr %0
  %5 = load i32, ptr %__const.nifti_make_new_header.default_dims., align 4, !tbaa !5
  %6 = add i32 %5, -8
  %or.cond = icmp ult i32 %6, -7
  br i1 %or.cond, label %11, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %7 = add nuw nsw i32 %5, 1
  %8 = getelementptr inbounds i8, ptr %__const.nifti_make_new_header.default_dims., i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 1
  br i1 %10, label %14, label %17

11:                                               ; preds = %2
  %12 = load ptr, ptr @stderr, align 8, !tbaa !9
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.220, i32 noundef %5) #6
  br label %.loopexit

14:                                               ; preds = %.lr.ph.6, %.lr.ph.5, %.lr.ph.4, %.lr.ph.3, %.lr.ph.2, %.lr.ph.1, %.lr.ph.preheader
  %indvars.iv.lcssa = phi i32 [ 1, %.lr.ph.preheader ], [ 2, %.lr.ph.1 ], [ 3, %.lr.ph.2 ], [ 4, %.lr.ph.3 ], [ 5, %.lr.ph.4 ], [ 6, %.lr.ph.5 ], [ 7, %.lr.ph.6 ]
  %.lcssa = phi i32 [ %9, %.lr.ph.preheader ], [ %19, %.lr.ph.1 ], [ %23, %.lr.ph.2 ], [ %27, %.lr.ph.3 ], [ %31, %.lr.ph.4 ], [ %35, %.lr.ph.5 ], [ %39, %.lr.ph.6 ]
  %15 = load ptr, ptr @stderr, align 8, !tbaa !9
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.221, i32 noundef %indvars.iv.lcssa, i32 noundef %.lcssa) #6
  br label %.loopexit

17:                                               ; preds = %.lr.ph.preheader
  %exitcond.not = icmp eq i32 %7, 2
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph.1, !llvm.loop !11

.lr.ph.1:                                         ; preds = %17
  %18 = getelementptr inbounds i8, ptr %__const.nifti_make_new_header.default_dims., i64 8
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = icmp slt i32 %19, 1
  br i1 %20, label %14, label %21

21:                                               ; preds = %.lr.ph.1
  %exitcond.not.1 = icmp eq i32 %7, 3
  br i1 %exitcond.not.1, label %.loopexit, label %.lr.ph.2, !llvm.loop !11

.lr.ph.2:                                         ; preds = %21
  %22 = getelementptr inbounds i8, ptr %__const.nifti_make_new_header.default_dims., i64 12
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = icmp slt i32 %23, 1
  br i1 %24, label %14, label %25

25:                                               ; preds = %.lr.ph.2
  %exitcond.not.2 = icmp eq i32 %7, 4
  br i1 %exitcond.not.2, label %.loopexit, label %.lr.ph.3, !llvm.loop !11

.lr.ph.3:                                         ; preds = %25
  %26 = getelementptr inbounds i8, ptr %__const.nifti_make_new_header.default_dims., i64 16
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = icmp slt i32 %27, 1
  br i1 %28, label %14, label %29

29:                                               ; preds = %.lr.ph.3
  %exitcond.not.3 = icmp eq i32 %7, 5
  br i1 %exitcond.not.3, label %.loopexit, label %.lr.ph.4, !llvm.loop !11

.lr.ph.4:                                         ; preds = %29
  %30 = getelementptr inbounds i8, ptr %__const.nifti_make_new_header.default_dims., i64 20
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = icmp slt i32 %31, 1
  br i1 %32, label %14, label %33

33:                                               ; preds = %.lr.ph.4
  %exitcond.not.4 = icmp eq i32 %7, 6
  br i1 %exitcond.not.4, label %.loopexit, label %.lr.ph.5, !llvm.loop !11

.lr.ph.5:                                         ; preds = %33
  %34 = getelementptr inbounds i8, ptr %__const.nifti_make_new_header.default_dims., i64 24
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = icmp slt i32 %35, 1
  br i1 %36, label %14, label %37

37:                                               ; preds = %.lr.ph.5
  %exitcond.not.5 = icmp eq i32 %7, 7
  br i1 %exitcond.not.5, label %.loopexit, label %.lr.ph.6, !llvm.loop !11

.lr.ph.6:                                         ; preds = %37
  %38 = getelementptr inbounds i8, ptr %__const.nifti_make_new_header.default_dims., i64 28
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = icmp slt i32 %39, 1
  br i1 %40, label %14, label %.loopexit

.loopexit:                                        ; preds = %17, %21, %25, %29, %33, %37, %.lr.ph.6, %14, %11
  %.141 = phi ptr [ @__const.nifti_make_new_header.default_dims, %11 ], [ @__const.nifti_make_new_header.default_dims, %14 ], [ %__const.nifti_make_new_header.default_dims., %.lr.ph.6 ], [ %__const.nifti_make_new_header.default_dims., %37 ], [ %__const.nifti_make_new_header.default_dims., %33 ], [ %__const.nifti_make_new_header.default_dims., %29 ], [ %__const.nifti_make_new_header.default_dims., %25 ], [ %__const.nifti_make_new_header.default_dims., %21 ], [ %__const.nifti_make_new_header.default_dims., %17 ]
  %41 = tail call i32 @nifti_is_valid_datatype(i32 noundef %1)
  %.not48 = icmp eq i32 %41, 0
  br i1 %.not48, label %42, label %45

42:                                               ; preds = %.loopexit
  %43 = load ptr, ptr @stderr, align 8, !tbaa !9
  %44 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef nonnull @.str.222, i32 noundef %1) #6
  br label %45

45:                                               ; preds = %42, %.loopexit
  %.039 = phi i32 [ %1, %.loopexit ], [ 16, %42 ]
  %46 = load i32, ptr @g_opts, align 4, !tbaa !13
  %47 = icmp sgt i32 %46, 1
  br i1 %47, label %48, label %52

48:                                               ; preds = %45
  %49 = load ptr, ptr @stderr, align 8, !tbaa !9
  %50 = load i32, ptr %.141, align 4, !tbaa !5
  %51 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef nonnull @.str.223, i32 noundef %50, i32 noundef %.039) #6
  br label %52

52:                                               ; preds = %48, %45
  %53 = tail call noalias dereferenceable_or_null(348) ptr @calloc(i64 noundef 1, i64 noundef 348) #7
  %.not49 = icmp eq ptr %53, null
  br i1 %.not49, label %54, label %57

54:                                               ; preds = %52
  %55 = load ptr, ptr @stderr, align 8, !tbaa !9
  %56 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef nonnull @.str.224) #6
  br label %87

57:                                               ; preds = %52
  store i32 348, ptr %53, align 4, !tbaa !15
  %58 = getelementptr inbounds i8, ptr %53, i64 38
  store i8 114, ptr %58, align 2, !tbaa !19
  %59 = load i32, ptr %.141, align 4, !tbaa !5
  %60 = trunc i32 %59 to i16
  %61 = getelementptr inbounds i8, ptr %53, i64 40
  store i16 %60, ptr %61, align 4, !tbaa !20
  %62 = getelementptr inbounds i8, ptr %53, i64 76
  %.not5054 = icmp slt i32 %59, 1
  br i1 %.not5054, label %._crit_edge, label %.lr.ph56.preheader

.lr.ph56.preheader:                               ; preds = %57
  %63 = add nuw i32 %59, 1
  %wide.trip.count63 = zext i32 %63 to i64
  %64 = zext nneg i32 %59 to i64
  %min.iters.check = icmp ult i32 %59, 8
  br i1 %min.iters.check, label %.lr.ph56.preheader70, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph56.preheader
  %n.vec = and i64 %64, 2147483640
  %ind.end = or disjoint i64 %n.vec, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %65 = getelementptr inbounds i32, ptr %.141, i64 %offset.idx
  %66 = getelementptr inbounds i8, ptr %65, i64 16
  %wide.load = load <4 x i32>, ptr %65, align 4, !tbaa !5
  %wide.load69 = load <4 x i32>, ptr %66, align 4, !tbaa !5
  %67 = trunc <4 x i32> %wide.load to <4 x i16>
  %68 = trunc <4 x i32> %wide.load69 to <4 x i16>
  %69 = getelementptr inbounds [8 x i16], ptr %61, i64 0, i64 %offset.idx
  %70 = getelementptr inbounds i8, ptr %69, i64 8
  store <4 x i16> %67, ptr %69, align 2, !tbaa !20
  store <4 x i16> %68, ptr %70, align 2, !tbaa !20
  %71 = getelementptr inbounds [8 x float], ptr %62, i64 0, i64 %offset.idx
  %72 = getelementptr inbounds i8, ptr %71, i64 16
  store <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, ptr %71, align 4, !tbaa !21
  store <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, ptr %72, align 4, !tbaa !21
  %index.next = add nuw i64 %index, 8
  %73 = icmp eq i64 %index.next, %n.vec
  br i1 %73, label %middle.block, label %vector.body, !llvm.loop !22

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %64
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph56.preheader70

.lr.ph56.preheader70:                             ; preds = %middle.block, %.lr.ph56.preheader
  %indvars.iv60.ph = phi i64 [ 1, %.lr.ph56.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph56

.lr.ph56:                                         ; preds = %.lr.ph56.preheader70, %.lr.ph56
  %indvars.iv60 = phi i64 [ %indvars.iv.next61, %.lr.ph56 ], [ %indvars.iv60.ph, %.lr.ph56.preheader70 ]
  %74 = getelementptr inbounds i32, ptr %.141, i64 %indvars.iv60
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = trunc i32 %75 to i16
  %77 = getelementptr inbounds [8 x i16], ptr %61, i64 0, i64 %indvars.iv60
  store i16 %76, ptr %77, align 2, !tbaa !20
  %78 = getelementptr inbounds [8 x float], ptr %62, i64 0, i64 %indvars.iv60
  store float 1.000000e+00, ptr %78, align 4, !tbaa !21
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %exitcond64.not = icmp eq i64 %indvars.iv.next61, %wide.trip.count63
  br i1 %exitcond64.not, label %._crit_edge, label %.lr.ph56, !llvm.loop !25

._crit_edge:                                      ; preds = %.lr.ph56, %middle.block, %57
  %79 = trunc i32 %.039 to i16
  %80 = getelementptr inbounds i8, ptr %53, i64 70
  store i16 %79, ptr %80, align 2, !tbaa !26
  %sext = shl i32 %.039, 16
  %81 = ashr exact i32 %sext, 16
  call void @nifti_datatype_sizes(i32 noundef %81, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %82 = load i32, ptr %3, align 4, !tbaa !5
  %.tr = trunc i32 %82 to i16
  %83 = shl i16 %.tr, 3
  %84 = getelementptr inbounds i8, ptr %53, i64 72
  store i16 %83, ptr %84, align 4, !tbaa !27
  %85 = getelementptr inbounds i8, ptr %53, i64 344
  %86 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %85, ptr noundef nonnull dereferenceable(1) @.str.219) #5
  br label %87

87:                                               ; preds = %._crit_edge, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  ret ptr %53
}

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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 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 #4 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) 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 #5 = { nounwind }
attributes #6 = { cold nounwind }
attributes #7 = { nounwind allocsize(0,1) }

!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"}
!13 = !{!14, !6, i64 0}
!14 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8}
!15 = !{!16, !6, i64 0}
!16 = !{!"nifti_1_header", !6, i64 0, !7, i64 4, !7, i64 14, !6, i64 32, !17, i64 36, !7, i64 38, !7, i64 39, !7, i64 40, !18, i64 56, !18, i64 60, !18, i64 64, !17, i64 68, !17, i64 70, !17, i64 72, !17, i64 74, !7, i64 76, !18, i64 108, !18, i64 112, !18, i64 116, !17, i64 120, !7, i64 122, !7, i64 123, !18, i64 124, !18, i64 128, !18, i64 132, !18, i64 136, !6, i64 140, !6, i64 144, !7, i64 148, !7, i64 228, !17, i64 252, !17, i64 254, !18, i64 256, !18, i64 260, !18, i64 264, !18, i64 268, !18, i64 272, !18, i64 276, !7, i64 280, !7, i64 296, !7, i64 312, !7, i64 328, !7, i64 344}
!17 = !{!"short", !7, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = !{!16, !7, i64 38}
!20 = !{!17, !17, i64 0}
!21 = !{!18, !18, i64 0}
!22 = distinct !{!22, !12, !23, !24}
!23 = !{!"llvm.loop.isvectorized", i32 1}
!24 = !{!"llvm.loop.unroll.runtime.disable"}
!25 = distinct !{!25, !12, !24, !23}
!26 = !{!16, !17, i64 70}
!27 = !{!16, !17, i64 72}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass