; 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.115 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.140 = external hidden unnamed_addr constant [3 x i8], align 1
@__const.nifti_read_header.fname = external hidden unnamed_addr constant [18 x i8], align 16
@.str.169 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.170 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.171 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.172 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.173 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.174 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.175 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.176 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.177 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.178 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.179 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.180 = external hidden unnamed_addr constant [51 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 void @free(ptr noundef) #1

declare i32 @Xznzclose(ptr noundef) #2

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

; 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) #4

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @nifti_is_gzfile(ptr noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local ptr @nifti_findhdrname(ptr noundef) #5

declare ptr @znzopen(ptr noundef, ptr noundef, i32 noundef) #2

declare i64 @znzread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden i32 @need_nhdr_swap(i16 noundef signext, i32 noundef) #5

; Function Attrs: nounwind uwtable
define dso_local ptr @nifti_read_header(ptr noundef %0, ptr noundef %1, i32 noundef %2) #5 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.nifti_1_header, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca [18 x i8], align 16
  %15 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 348, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 18, ptr %14) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %14, ptr align 16 @__const.nifti_read_header.fname, i64 18, i1 false)
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call ptr @nifti_findhdrname(ptr noundef %16)
  store ptr %17, ptr %13, align 8, !tbaa !5
  %18 = load ptr, ptr %13, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %29

20:                                               ; preds = %3
  %21 = load i32, ptr @g_opts, align 4, !tbaa !11
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %23, label %28

23:                                               ; preds = %20
  %24 = load ptr, ptr @stderr, align 8, !tbaa !5
  %25 = getelementptr inbounds [18 x i8], ptr %14, i64 0, i64 0
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str.115, ptr noundef %25, ptr noundef @.str.169, ptr noundef %26) #6
  br label %28

28:                                               ; preds = %23, %20
  store ptr null, ptr %4, align 8
  store i32 1, ptr %15, align 4
  br label %202

29:                                               ; preds = %3
  %30 = load i32, ptr @g_opts, align 4, !tbaa !11
  %31 = icmp sgt i32 %30, 1
  br i1 %31, label %32, label %37

32:                                               ; preds = %29
  %33 = load ptr, ptr @stderr, align 8, !tbaa !5
  %34 = getelementptr inbounds [18 x i8], ptr %14, i64 0, i64 0
  %35 = load ptr, ptr %13, align 8, !tbaa !5
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef @.str.170, ptr noundef %34, ptr noundef %35) #6
  br label %37

37:                                               ; preds = %32, %29
  br label %38

38:                                               ; preds = %37
  %39 = load ptr, ptr %13, align 8, !tbaa !5
  %40 = load ptr, ptr %13, align 8, !tbaa !5
  %41 = call i32 @nifti_is_gzfile(ptr noundef %40)
  %42 = call ptr @znzopen(ptr noundef %39, ptr noundef @.str.140, i32 noundef %41)
  store ptr %42, ptr %10, align 8, !tbaa !5
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = icmp eq ptr %43, null
  br i1 %44, label %45, label %55

45:                                               ; preds = %38
  %46 = load i32, ptr @g_opts, align 4, !tbaa !11
  %47 = icmp sgt i32 %46, 0
  br i1 %47, label %48, label %53

48:                                               ; preds = %45
  %49 = load ptr, ptr @stderr, align 8, !tbaa !5
  %50 = getelementptr inbounds [18 x i8], ptr %14, i64 0, i64 0
  %51 = load ptr, ptr %13, align 8, !tbaa !5
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef @.str.115, ptr noundef %50, ptr noundef @.str.171, ptr noundef %51) #6
  br label %53

53:                                               ; preds = %48, %45
  %54 = load ptr, ptr %13, align 8, !tbaa !5
  call void @free(ptr noundef %54) #6
  store ptr null, ptr %4, align 8
  store i32 1, ptr %15, align 4
  br label %202

55:                                               ; preds = %38
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  call void @free(ptr noundef %56) #6
  %57 = load ptr, ptr %10, align 8, !tbaa !5
  %58 = call i32 @has_ascii_header(ptr noundef %57)
  %59 = icmp eq i32 %58, 1
  br i1 %59, label %60, label %70

60:                                               ; preds = %55
  %61 = call i32 @Xznzclose(ptr noundef %10)
  %62 = load i32, ptr @g_opts, align 4, !tbaa !11
  %63 = icmp sgt i32 %62, 0
  br i1 %63, label %64, label %69

64:                                               ; preds = %60
  %65 = load ptr, ptr @stderr, align 8, !tbaa !5
  %66 = getelementptr inbounds [18 x i8], ptr %14, i64 0, i64 0
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef @.str.115, ptr noundef %66, ptr noundef @.str.172, ptr noundef %67) #6
  br label %69

69:                                               ; preds = %64, %60
  store ptr null, ptr %4, align 8
  store i32 1, ptr %15, align 4
  br label %202

70:                                               ; preds = %55
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  %72 = call i64 @znzread(ptr noundef %8, i64 noundef 1, i64 noundef 348, ptr noundef %71)
  %73 = trunc i64 %72 to i32
  store i32 %73, ptr %11, align 4, !tbaa !9
  %74 = call i32 @Xznzclose(ptr noundef %10)
  %75 = load i32, ptr %11, align 4, !tbaa !9
  %76 = icmp slt i32 %75, 348
  br i1 %76, label %77, label %89

77:                                               ; preds = %70
  %78 = load i32, ptr @g_opts, align 4, !tbaa !11
  %79 = icmp sgt i32 %78, 0
  br i1 %79, label %80, label %88

80:                                               ; preds = %77
  %81 = load ptr, ptr @stderr, align 8, !tbaa !5
  %82 = getelementptr inbounds [18 x i8], ptr %14, i64 0, i64 0
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %81, ptr noundef @.str.115, ptr noundef %82, ptr noundef @.str.173, ptr noundef %83) #6
  %85 = load ptr, ptr @stderr, align 8, !tbaa !5
  %86 = load i32, ptr %11, align 4, !tbaa !9
  %87 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %85, ptr noundef @.str.174, i32 noundef %86, i32 noundef 348) #6
  br label %88

88:                                               ; preds = %80, %77
  store ptr null, ptr %4, align 8
  store i32 1, ptr %15, align 4
  br label %202

89:                                               ; preds = %70
  %90 = getelementptr inbounds %struct.nifti_1_header, ptr %8, i32 0, i32 7
  %91 = getelementptr inbounds [8 x i16], ptr %90, i64 0, i64 0
  %92 = load i16, ptr %91, align 4, !tbaa !13
  %93 = getelementptr inbounds %struct.nifti_1_header, ptr %8, i32 0, i32 0
  %94 = load i32, ptr %93, align 4, !tbaa !15
  %95 = call i32 @need_nhdr_swap(i16 noundef signext %92, i32 noundef %94)
  store i32 %95, ptr %12, align 4, !tbaa !9
  %96 = load i32, ptr %7, align 4, !tbaa !9
  %97 = icmp ne i32 %96, 0
  br i1 %97, label %98, label %106

98:                                               ; preds = %89
  %99 = load i32, ptr %12, align 4, !tbaa !9
  %100 = icmp slt i32 %99, 0
  br i1 %100, label %101, label %106

101:                                              ; preds = %98
  %102 = load ptr, ptr @stderr, align 8, !tbaa !5
  %103 = getelementptr inbounds [18 x i8], ptr %14, i64 0, i64 0
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %102, ptr noundef @.str.115, ptr noundef %103, ptr noundef @.str.175, ptr noundef %104) #6
  store ptr null, ptr %4, align 8
  store i32 1, ptr %15, align 4
  br label %202

106:                                              ; preds = %98, %89
  %107 = load i32, ptr %12, align 4, !tbaa !9
  %108 = icmp slt i32 %107, 0
  br i1 %108, label %109, label %116

109:                                              ; preds = %106
  store i32 0, ptr %12, align 4, !tbaa !9
  %110 = load i32, ptr @g_opts, align 4, !tbaa !11
  %111 = icmp sgt i32 %110, 1
  br i1 %111, label %112, label %115

112:                                              ; preds = %109
  %113 = load ptr, ptr @stderr, align 8, !tbaa !5
  %114 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %113, ptr noundef @.str.176) #6
  br label %115

115:                                              ; preds = %112, %109
  br label %116

116:                                              ; preds = %115, %106
  br label %117

117:                                              ; preds = %116
  %118 = load i32, ptr %12, align 4, !tbaa !9
  %119 = icmp ne i32 %118, 0
  br i1 %119, label %120, label %170

120:                                              ; preds = %117
  %121 = load i32, ptr @g_opts, align 4, !tbaa !11
  %122 = icmp sgt i32 %121, 3
  br i1 %122, label %123, label %125

123:                                              ; preds = %120
  %124 = call i32 @disp_nifti_1_header(ptr noundef @.str.177, ptr noundef %8)
  br label %125

125:                                              ; preds = %123, %120
  %126 = getelementptr inbounds %struct.nifti_1_header, ptr %8, i32 0, i32 42
  %127 = getelementptr inbounds [4 x i8], ptr %126, i64 0, i64 0
  %128 = load i8, ptr %127, align 4, !tbaa !18
  %129 = sext i8 %128 to i32
  %130 = icmp eq i32 %129, 110
  br i1 %130, label %131, label %167

131:                                              ; preds = %125
  %132 = getelementptr inbounds %struct.nifti_1_header, ptr %8, i32 0, i32 42
  %133 = getelementptr inbounds [4 x i8], ptr %132, i64 0, i64 3
  %134 = load i8, ptr %133, align 1, !tbaa !18
  %135 = sext i8 %134 to i32
  %136 = icmp eq i32 %135, 0
  br i1 %136, label %137, label %167

137:                                              ; preds = %131
  %138 = getelementptr inbounds %struct.nifti_1_header, ptr %8, i32 0, i32 42
  %139 = getelementptr inbounds [4 x i8], ptr %138, i64 0, i64 1
  %140 = load i8, ptr %139, align 1, !tbaa !18
  %141 = sext i8 %140 to i32
  %142 = icmp eq i32 %141, 105
  br i1 %142, label %149, label %143

143:                                              ; preds = %137
  %144 = getelementptr inbounds %struct.nifti_1_header, ptr %8, i32 0, i32 42
  %145 = getelementptr inbounds [4 x i8], ptr %144, i64 0, i64 1
  %146 = load i8, ptr %145, align 1, !tbaa !18
  %147 = sext i8 %146 to i32
  %148 = icmp eq i32 %147, 43
  br i1 %148, label %149, label %167

149:                                              ; preds = %143, %137
  %150 = getelementptr inbounds %struct.nifti_1_header, ptr %8, i32 0, i32 42
  %151 = getelementptr inbounds [4 x i8], ptr %150, i64 0, i64 2
  %152 = load i8, ptr %151, align 2, !tbaa !18
  %153 = sext i8 %152 to i32
  %154 = icmp sge i32 %153, 49
  br i1 %154, label %155, label %167

155:                                              ; preds = %149
  %156 = getelementptr inbounds %struct.nifti_1_header, ptr %8, i32 0, i32 42
  %157 = getelementptr inbounds [4 x i8], ptr %156, i64 0, i64 2
  %158 = load i8, ptr %157, align 2, !tbaa !18
  %159 = sext i8 %158 to i32
  %160 = icmp sle i32 %159, 57
  br i1 %160, label %161, label %167

161:                                              ; preds = %155
  %162 = getelementptr inbounds %struct.nifti_1_header, ptr %8, i32 0, i32 42
  %163 = getelementptr inbounds [4 x i8], ptr %162, i64 0, i64 2
  %164 = load i8, ptr %163, align 2, !tbaa !18
  %165 = sext i8 %164 to i32
  %166 = sub nsw i32 %165, 48
  br label %168

167:                                              ; preds = %155, %149, %143, %131, %125
  br label %168

168:                                              ; preds = %167, %161
  %169 = phi i32 [ %166, %161 ], [ 0, %167 ]
  call void @swap_nifti_header(ptr noundef %8, i32 noundef %169)
  br label %170

170:                                              ; preds = %168, %117
  %171 = load i32, ptr @g_opts, align 4, !tbaa !11
  %172 = icmp sgt i32 %171, 2
  br i1 %172, label %173, label %175

173:                                              ; preds = %170
  %174 = call i32 @disp_nifti_1_header(ptr noundef @.str.178, ptr noundef %8)
  br label %175

175:                                              ; preds = %173, %170
  %176 = load i32, ptr %7, align 4, !tbaa !9
  %177 = icmp ne i32 %176, 0
  br i1 %177, label %178, label %186

178:                                              ; preds = %175
  %179 = call i32 @nifti_hdr_looks_good(ptr noundef %8)
  %180 = icmp ne i32 %179, 0
  br i1 %180, label %186, label %181

181:                                              ; preds = %178
  %182 = load ptr, ptr @stderr, align 8, !tbaa !5
  %183 = getelementptr inbounds [18 x i8], ptr %14, i64 0, i64 0
  %184 = load ptr, ptr %5, align 8, !tbaa !5
  %185 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %182, ptr noundef @.str.115, ptr noundef %183, ptr noundef @.str.179, ptr noundef %184) #6
  store ptr null, ptr %4, align 8
  store i32 1, ptr %15, align 4
  br label %202

186:                                              ; preds = %178, %175
  %187 = call noalias ptr @malloc(i64 noundef 348) #7
  store ptr %187, ptr %9, align 8, !tbaa !5
  %188 = load ptr, ptr %9, align 8, !tbaa !5
  %189 = icmp ne ptr %188, null
  br i1 %189, label %193, label %190

190:                                              ; preds = %186
  %191 = load ptr, ptr @stderr, align 8, !tbaa !5
  %192 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %191, ptr noundef @.str.180) #6
  store ptr null, ptr %4, align 8
  store i32 1, ptr %15, align 4
  br label %202

193:                                              ; preds = %186
  %194 = load ptr, ptr %6, align 8, !tbaa !5
  %195 = icmp ne ptr %194, null
  br i1 %195, label %196, label %199

196:                                              ; preds = %193
  %197 = load i32, ptr %12, align 4, !tbaa !9
  %198 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %197, ptr %198, align 4, !tbaa !9
  br label %199

199:                                              ; preds = %196, %193
  %200 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %200, ptr align 4 %8, i64 348, i1 false)
  %201 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %201, ptr %4, align 8
  store i32 1, ptr %15, align 4
  br label %202

202:                                              ; preds = %199, %190, %181, %101, %88, %69, %53, %28
  call void @llvm.lifetime.end.p0(i64 18, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 348, ptr %8) #6
  %203 = load ptr, ptr %4, align 8
  ret ptr %203
}

; Function Attrs: nounwind uwtable
declare hidden i32 @has_ascii_header(ptr noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local i32 @nifti_hdr_looks_good(ptr noundef) #5

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { nounwind }
attributes #7 = { 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}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!16, !10, i64 0}
!16 = !{!"nifti_1_header", !10, i64 0, !7, i64 4, !7, i64 14, !10, i64 32, !14, i64 36, !7, i64 38, !7, i64 39, !7, i64 40, !17, i64 56, !17, i64 60, !17, i64 64, !14, i64 68, !14, i64 70, !14, i64 72, !14, i64 74, !7, i64 76, !17, i64 108, !17, i64 112, !17, i64 116, !14, i64 120, !7, i64 122, !7, i64 123, !17, i64 124, !17, i64 128, !17, i64 132, !17, i64 136, !10, i64 140, !10, i64 144, !7, i64 148, !7, i64 228, !14, i64 252, !14, i64 254, !17, i64 256, !17, i64 260, !17, i64 264, !17, i64 268, !17, i64 272, !17, i64 276, !7, i64 280, !7, i64 296, !7, i64 312, !7, i64 328, !7, i64 344}
!17 = !{!"float", !7, i64 0}
!18 = !{!7, !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"

%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 local_unnamed_addr global ptr, align 8
@g_opts = external hidden local_unnamed_addr global %struct.nifti_global_options, align 4
@.str.115 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.140 = external hidden unnamed_addr constant [3 x i8], align 1
@__const.nifti_read_header.fname = external hidden unnamed_addr constant [18 x i8], align 16
@.str.169 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.170 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.171 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.172 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.173 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.174 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.175 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.176 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.177 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.178 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.179 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.180 = external hidden unnamed_addr constant [51 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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

declare i32 @Xznzclose(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress 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) #5

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @nifti_is_gzfile(ptr noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
declare dso_local ptr @nifti_findhdrname(ptr noundef) local_unnamed_addr #6

declare ptr @znzopen(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare i64 @znzread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare hidden i32 @need_nhdr_swap(i16 noundef signext, i32 noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @nifti_read_header(ptr noundef %0, ptr noundef writeonly %1, i32 noundef %2) local_unnamed_addr #6 {
  %4 = alloca %struct.nifti_1_header, align 4
  %5 = alloca ptr, align 8
  %6 = alloca [18 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 348, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  call void @llvm.lifetime.start.p0(i64 18, ptr nonnull %6) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(18) %6, ptr noundef nonnull align 16 dereferenceable(18) @__const.nifti_read_header.fname, i64 18, i1 false)
  %7 = tail call ptr @nifti_findhdrname(ptr noundef %0)
  %8 = icmp eq ptr %7, null
  %9 = load i32, ptr @g_opts, align 4, !tbaa !5
  br i1 %8, label %10, label %15

10:                                               ; preds = %3
  %11 = icmp sgt i32 %9, 0
  br i1 %11, label %12, label %114

12:                                               ; preds = %10
  %13 = load ptr, ptr @stderr, align 8, !tbaa !10
  %14 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.115, ptr noundef nonnull %6, ptr noundef nonnull @.str.169, ptr noundef %0) #8
  br label %114

15:                                               ; preds = %3
  %16 = icmp sgt i32 %9, 1
  br i1 %16, label %17, label %20

17:                                               ; preds = %15
  %18 = load ptr, ptr @stderr, align 8, !tbaa !10
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.170, ptr noundef nonnull %6, ptr noundef nonnull %7) #8
  br label %20

20:                                               ; preds = %15, %17
  %21 = call i32 @nifti_is_gzfile(ptr noundef nonnull %7)
  %22 = call ptr @znzopen(ptr noundef nonnull %7, ptr noundef nonnull @.str.140, i32 noundef %21) #7
  store ptr %22, ptr %5, align 8, !tbaa !10
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %31

24:                                               ; preds = %20
  %25 = load i32, ptr @g_opts, align 4, !tbaa !5
  %26 = icmp sgt i32 %25, 0
  br i1 %26, label %27, label %30

27:                                               ; preds = %24
  %28 = load ptr, ptr @stderr, align 8, !tbaa !10
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str.115, ptr noundef nonnull %6, ptr noundef nonnull @.str.171, ptr noundef nonnull %7) #8
  br label %30

30:                                               ; preds = %27, %24
  call void @free(ptr noundef nonnull %7) #7
  br label %114

31:                                               ; preds = %20
  call void @free(ptr noundef nonnull %7) #7
  %32 = call i32 @has_ascii_header(ptr noundef nonnull %22)
  %33 = icmp eq i32 %32, 1
  br i1 %33, label %34, label %41

34:                                               ; preds = %31
  %35 = call i32 @Xznzclose(ptr noundef nonnull %5) #7
  %36 = load i32, ptr @g_opts, align 4, !tbaa !5
  %37 = icmp sgt i32 %36, 0
  br i1 %37, label %38, label %114

38:                                               ; preds = %34
  %39 = load ptr, ptr @stderr, align 8, !tbaa !10
  %40 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef nonnull @.str.115, ptr noundef nonnull %6, ptr noundef nonnull @.str.172, ptr noundef %0) #8
  br label %114

41:                                               ; preds = %31
  %42 = call i64 @znzread(ptr noundef nonnull %4, i64 noundef 1, i64 noundef 348, ptr noundef nonnull %22) #7
  %43 = trunc i64 %42 to i32
  %44 = call i32 @Xznzclose(ptr noundef nonnull %5) #7
  %45 = icmp slt i32 %43, 348
  br i1 %45, label %46, label %54

46:                                               ; preds = %41
  %47 = load i32, ptr @g_opts, align 4, !tbaa !5
  %48 = icmp sgt i32 %47, 0
  br i1 %48, label %49, label %114

49:                                               ; preds = %46
  %50 = load ptr, ptr @stderr, align 8, !tbaa !10
  %51 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef nonnull @.str.115, ptr noundef nonnull %6, ptr noundef nonnull @.str.173, ptr noundef %0) #8
  %52 = load ptr, ptr @stderr, align 8, !tbaa !10
  %53 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %52, ptr noundef nonnull @.str.174, i32 noundef %43, i32 noundef 348) #8
  br label %114

54:                                               ; preds = %41
  %55 = getelementptr inbounds i8, ptr %4, i64 40
  %56 = load i16, ptr %55, align 4, !tbaa !12
  %57 = load i32, ptr %4, align 4, !tbaa !14
  %58 = call i32 @need_nhdr_swap(i16 noundef signext %56, i32 noundef %57)
  %59 = icmp ne i32 %2, 0
  %60 = icmp slt i32 %58, 0
  %or.cond = select i1 %59, i1 %60, i1 false
  br i1 %or.cond, label %61, label %64

61:                                               ; preds = %54
  %62 = load ptr, ptr @stderr, align 8, !tbaa !10
  %63 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %62, ptr noundef nonnull @.str.115, ptr noundef nonnull %6, ptr noundef nonnull @.str.175, ptr noundef %0) #8
  br label %114

64:                                               ; preds = %54
  br i1 %60, label %65, label %71

65:                                               ; preds = %64
  %66 = load i32, ptr @g_opts, align 4, !tbaa !5
  %67 = icmp sgt i32 %66, 1
  br i1 %67, label %68, label %.thread.thread

68:                                               ; preds = %65
  %69 = load ptr, ptr @stderr, align 8, !tbaa !10
  %70 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %69, ptr noundef nonnull @.str.176) #8
  br label %.thread

71:                                               ; preds = %64
  %.not = icmp eq i32 %58, 0
  br i1 %.not, label %.thread, label %72

72:                                               ; preds = %71
  %73 = load i32, ptr @g_opts, align 4, !tbaa !5
  %74 = icmp sgt i32 %73, 3
  br i1 %74, label %75, label %77

75:                                               ; preds = %72
  %76 = call i32 @disp_nifti_1_header(ptr noundef nonnull @.str.177, ptr noundef nonnull %4)
  br label %77

77:                                               ; preds = %75, %72
  %78 = getelementptr inbounds i8, ptr %4, i64 344
  %79 = load i8, ptr %78, align 4, !tbaa !17
  %80 = icmp eq i8 %79, 110
  %81 = getelementptr inbounds i8, ptr %4, i64 347
  %82 = load i8, ptr %81, align 1
  %83 = icmp eq i8 %82, 0
  %or.cond6 = select i1 %80, i1 %83, i1 false
  br i1 %or.cond6, label %84, label %96

84:                                               ; preds = %77
  %85 = getelementptr inbounds i8, ptr %4, i64 345
  %86 = load i8, ptr %85, align 1
  %87 = icmp eq i8 %86, 105
  %88 = icmp eq i8 %86, 43
  %or.cond11 = or i1 %87, %88
  %89 = getelementptr inbounds i8, ptr %4, i64 346
  %90 = load i8, ptr %89, align 2
  %91 = add i8 %90, -49
  %92 = icmp ult i8 %91, 9
  %or.cond21 = select i1 %or.cond11, i1 %92, i1 false
  br i1 %or.cond21, label %93, label %96

93:                                               ; preds = %84
  %94 = zext nneg i8 %90 to i32
  %95 = add nsw i32 %94, -48
  br label %96

96:                                               ; preds = %77, %84, %93
  %97 = phi i32 [ %95, %93 ], [ 0, %84 ], [ 0, %77 ]
  call void @swap_nifti_header(ptr noundef nonnull %4, i32 noundef %97)
  br label %.thread

.thread:                                          ; preds = %68, %96, %71
  %.04759.ph = phi i32 [ 0, %68 ], [ 0, %71 ], [ %58, %96 ]
  %.pr = load i32, ptr @g_opts, align 4, !tbaa !5
  %98 = icmp sgt i32 %.pr, 2
  br i1 %98, label %99, label %.thread.thread

99:                                               ; preds = %.thread
  %100 = call i32 @disp_nifti_1_header(ptr noundef nonnull @.str.178, ptr noundef nonnull %4)
  br label %.thread.thread

.thread.thread:                                   ; preds = %65, %99, %.thread
  %.0475961 = phi i32 [ %.04759.ph, %99 ], [ %.04759.ph, %.thread ], [ 0, %65 ]
  br i1 %59, label %101, label %106

101:                                              ; preds = %.thread.thread
  %102 = call i32 @nifti_hdr_looks_good(ptr noundef nonnull %4)
  %.not54 = icmp eq i32 %102, 0
  br i1 %.not54, label %103, label %106

103:                                              ; preds = %101
  %104 = load ptr, ptr @stderr, align 8, !tbaa !10
  %105 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %104, ptr noundef nonnull @.str.115, ptr noundef nonnull %6, ptr noundef nonnull @.str.179, ptr noundef %0) #8
  br label %114

106:                                              ; preds = %101, %.thread.thread
  %107 = call noalias dereferenceable_or_null(348) ptr @malloc(i64 noundef 348) #9
  %.not55 = icmp eq ptr %107, null
  br i1 %.not55, label %108, label %111

108:                                              ; preds = %106
  %109 = load ptr, ptr @stderr, align 8, !tbaa !10
  %110 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %109, ptr noundef nonnull @.str.180) #8
  br label %114

111:                                              ; preds = %106
  %.not56 = icmp eq ptr %1, null
  br i1 %.not56, label %113, label %112

112:                                              ; preds = %111
  store i32 %.0475961, ptr %1, align 4, !tbaa !18
  br label %113

113:                                              ; preds = %112, %111
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(348) %107, ptr noundef nonnull align 4 dereferenceable(348) %4, i64 348, i1 false)
  br label %114

114:                                              ; preds = %46, %49, %34, %38, %10, %12, %113, %108, %103, %61, %30
  %.0 = phi ptr [ null, %30 ], [ null, %61 ], [ %107, %113 ], [ null, %108 ], [ null, %103 ], [ null, %12 ], [ null, %10 ], [ null, %38 ], [ null, %34 ], [ null, %49 ], [ null, %46 ]
  call void @llvm.lifetime.end.p0(i64 18, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 348, ptr nonnull %4) #7
  ret ptr %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @has_ascii_header(ptr noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
declare dso_local i32 @nifti_hdr_looks_good(ptr noundef) local_unnamed_addr #6

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 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 = { "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,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 #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 #7 = { nounwind }
attributes #8 = { cold nounwind }
attributes #9 = { 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !8, i64 0}
!14 = !{!15, !7, i64 0}
!15 = !{!"nifti_1_header", !7, i64 0, !8, i64 4, !8, i64 14, !7, i64 32, !13, i64 36, !8, i64 38, !8, i64 39, !8, i64 40, !16, i64 56, !16, i64 60, !16, i64 64, !13, i64 68, !13, i64 70, !13, i64 72, !13, i64 74, !8, i64 76, !16, i64 108, !16, i64 112, !16, i64 116, !13, i64 120, !8, i64 122, !8, i64 123, !16, i64 124, !16, i64 128, !16, i64 132, !16, i64 136, !7, i64 140, !7, i64 144, !8, i64 148, !8, i64 228, !13, i64 252, !13, i64 254, !16, i64 256, !16, i64 260, !16, i64 264, !16, i64 268, !16, i64 272, !16, i64 276, !8, i64 280, !8, i64 296, !8, i64 312, !8, i64 328, !8, i64 344}
!16 = !{!"float", !8, i64 0}
!17 = !{!8, !8, i64 0}
!18 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass