; 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] }
%struct.nifti_image = type { i32, i32, i32, i32, i32, i32, i32, i32, [8 x i32], i64, i32, i32, float, float, float, float, float, float, float, [8 x float], float, float, float, float, i32, i32, i32, i32, i32, i32, i32, i32, float, float, float, float, float, float, float, float, %struct.mat44, %struct.mat44, %struct.mat44, %struct.mat44, float, i32, i32, i32, i32, float, float, float, [16 x i8], [80 x i8], [24 x i8], ptr, ptr, i32, i32, i32, ptr, i32, ptr, i32 }
%struct.mat44 = type { [4 x [4 x float]] }

@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
@.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.173 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.174 = external hidden unnamed_addr constant [25 x i8], align 1
@__const.nifti_image_read.fname = external hidden unnamed_addr constant [17 x i8], align 16
@.str.187 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.188 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.189 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.190 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.191 = external hidden unnamed_addr constant [42 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
define dso_local ptr @nifti_image_read(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %struct.nifti_1_header, align 8
  %7 = alloca ptr, align 8
  %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 [17 x i8], align 16
  %14 = alloca ptr, align 8
  %15 = 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 348, 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 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
  call void @llvm.lifetime.start.p0(i64 17, ptr %13) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %13, ptr align 16 @__const.nifti_image_read.fname, i64 17, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  store ptr null, ptr %14, align 8, !tbaa !5
  %16 = load i32, ptr @g_opts, align 4, !tbaa !11
  %17 = icmp sgt i32 %16, 1
  br i1 %17, label %18, label %25

18:                                               ; preds = %2
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str.187, ptr noundef %20, i32 noundef %21) #5
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.188) #5
  br label %25

25:                                               ; preds = %18, %2
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = call ptr @nifti_findhdrname(ptr noundef %26)
  store ptr %27, ptr %14, align 8, !tbaa !5
  %28 = load ptr, ptr %14, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %30, label %39

30:                                               ; preds = %25
  %31 = load i32, ptr @g_opts, align 4, !tbaa !11
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %33, label %38

33:                                               ; preds = %30
  %34 = load ptr, ptr @stderr, align 8, !tbaa !5
  %35 = getelementptr inbounds [17 x i8], ptr %13, i64 0, i64 0
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef @.str.115, ptr noundef %35, ptr noundef @.str.169, ptr noundef %36) #5
  br label %38

38:                                               ; preds = %33, %30
  store ptr null, ptr %3, align 8
  store i32 1, ptr %15, align 4
  br label %185

39:                                               ; preds = %25
  %40 = load i32, ptr @g_opts, align 4, !tbaa !11
  %41 = icmp sgt i32 %40, 1
  br i1 %41, label %42, label %47

42:                                               ; preds = %39
  %43 = load ptr, ptr @stderr, align 8, !tbaa !5
  %44 = getelementptr inbounds [17 x i8], ptr %13, i64 0, i64 0
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  %46 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef @.str.170, ptr noundef %44, ptr noundef %45) #5
  br label %47

47:                                               ; preds = %42, %39
  br label %48

48:                                               ; preds = %47
  %49 = load ptr, ptr %14, align 8, !tbaa !5
  %50 = call i32 @nifti_is_gzfile(ptr noundef %49)
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %53

52:                                               ; preds = %48
  store i32 -1, ptr %11, align 4, !tbaa !9
  br label %56

53:                                               ; preds = %48
  %54 = load ptr, ptr %14, align 8, !tbaa !5
  %55 = call i32 @nifti_get_filesize(ptr noundef %54)
  store i32 %55, ptr %11, align 4, !tbaa !9
  br label %56

56:                                               ; preds = %53, %52
  %57 = load ptr, ptr %14, align 8, !tbaa !5
  %58 = load ptr, ptr %14, align 8, !tbaa !5
  %59 = call i32 @nifti_is_gzfile(ptr noundef %58)
  %60 = call ptr @znzopen(ptr noundef %57, ptr noundef @.str.140, i32 noundef %59)
  store ptr %60, ptr %8, align 8, !tbaa !5
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = icmp eq ptr %61, null
  br i1 %62, label %63, label %73

63:                                               ; preds = %56
  %64 = load i32, ptr @g_opts, align 4, !tbaa !11
  %65 = icmp sgt i32 %64, 0
  br i1 %65, label %66, label %71

66:                                               ; preds = %63
  %67 = load ptr, ptr @stderr, align 8, !tbaa !5
  %68 = getelementptr inbounds [17 x i8], ptr %13, i64 0, i64 0
  %69 = load ptr, ptr %14, align 8, !tbaa !5
  %70 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %67, ptr noundef @.str.115, ptr noundef %68, ptr noundef @.str.171, ptr noundef %69) #5
  br label %71

71:                                               ; preds = %66, %63
  %72 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free(ptr noundef %72) #5
  store ptr null, ptr %3, align 8
  store i32 1, ptr %15, align 4
  br label %185

73:                                               ; preds = %56
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = call i32 @has_ascii_header(ptr noundef %74)
  store i32 %75, ptr %9, align 4, !tbaa !9
  %76 = load i32, ptr %9, align 4, !tbaa !9
  %77 = icmp slt i32 %76, 0
  br i1 %77, label %78, label %89

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

81:                                               ; preds = %78
  %82 = load ptr, ptr @stderr, align 8, !tbaa !5
  %83 = getelementptr inbounds [17 x i8], ptr %13, i64 0, i64 0
  %84 = load ptr, ptr %14, align 8, !tbaa !5
  %85 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %82, ptr noundef @.str.115, ptr noundef %83, ptr noundef @.str.189, ptr noundef %84) #5
  br label %86

86:                                               ; preds = %81, %78
  %87 = call i32 @Xznzclose(ptr noundef %8)
  %88 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free(ptr noundef %88) #5
  store ptr null, ptr %3, align 8
  store i32 1, ptr %15, align 4
  br label %185

89:                                               ; preds = %73
  %90 = load i32, ptr %9, align 4, !tbaa !9
  %91 = icmp eq i32 %90, 1
  br i1 %91, label %92, label %98

92:                                               ; preds = %89
  %93 = load ptr, ptr %8, align 8, !tbaa !5
  %94 = load ptr, ptr %14, align 8, !tbaa !5
  %95 = load i32, ptr %11, align 4, !tbaa !9
  %96 = load i32, ptr %5, align 4, !tbaa !9
  %97 = call ptr @nifti_read_ascii_image(ptr noundef %93, ptr noundef %94, i32 noundef %95, i32 noundef %96)
  store ptr %97, ptr %3, align 8
  store i32 1, ptr %15, align 4
  br label %185

98:                                               ; preds = %89
  br label %99

99:                                               ; preds = %98
  %100 = load ptr, ptr %8, align 8, !tbaa !5
  %101 = call i64 @znzread(ptr noundef %6, i64 noundef 1, i64 noundef 348, ptr noundef %100)
  %102 = trunc i64 %101 to i32
  store i32 %102, ptr %10, align 4, !tbaa !9
  %103 = load i32, ptr %10, align 4, !tbaa !9
  %104 = icmp slt i32 %103, 348
  br i1 %104, label %105, label %119

105:                                              ; preds = %99
  %106 = load i32, ptr @g_opts, align 4, !tbaa !11
  %107 = icmp sgt i32 %106, 0
  br i1 %107, label %108, label %116

108:                                              ; preds = %105
  %109 = load ptr, ptr @stderr, align 8, !tbaa !5
  %110 = getelementptr inbounds [17 x i8], ptr %13, i64 0, i64 0
  %111 = load ptr, ptr %14, align 8, !tbaa !5
  %112 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %109, ptr noundef @.str.115, ptr noundef %110, ptr noundef @.str.173, ptr noundef %111) #5
  %113 = load ptr, ptr @stderr, align 8, !tbaa !5
  %114 = load i32, ptr %10, align 4, !tbaa !9
  %115 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %113, ptr noundef @.str.174, i32 noundef %114, i32 noundef 348) #5
  br label %116

116:                                              ; preds = %108, %105
  %117 = call i32 @Xznzclose(ptr noundef %8)
  %118 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free(ptr noundef %118) #5
  store ptr null, ptr %3, align 8
  store i32 1, ptr %15, align 4
  br label %185

119:                                              ; preds = %99
  %120 = load ptr, ptr %14, align 8, !tbaa !5
  %121 = call ptr @nifti_convert_nhdr2nim(ptr noundef byval(%struct.nifti_1_header) align 8 %6, ptr noundef %120)
  store ptr %121, ptr %7, align 8, !tbaa !5
  %122 = load ptr, ptr %7, align 8, !tbaa !5
  %123 = icmp eq ptr %122, null
  br i1 %123, label %124, label %135

124:                                              ; preds = %119
  %125 = call i32 @Xznzclose(ptr noundef %8)
  %126 = load i32, ptr @g_opts, align 4, !tbaa !11
  %127 = icmp sgt i32 %126, 0
  br i1 %127, label %128, label %133

128:                                              ; preds = %124
  %129 = load ptr, ptr @stderr, align 8, !tbaa !5
  %130 = getelementptr inbounds [17 x i8], ptr %13, i64 0, i64 0
  %131 = load ptr, ptr %14, align 8, !tbaa !5
  %132 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %129, ptr noundef @.str.115, ptr noundef %130, ptr noundef @.str.190, ptr noundef %131) #5
  br label %133

133:                                              ; preds = %128, %124
  %134 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free(ptr noundef %134) #5
  store ptr null, ptr %3, align 8
  store i32 1, ptr %15, align 4
  br label %185

135:                                              ; preds = %119
  %136 = load i32, ptr @g_opts, align 4, !tbaa !11
  %137 = icmp sgt i32 %136, 3
  br i1 %137, label %138, label %146

138:                                              ; preds = %135
  %139 = load ptr, ptr @stderr, align 8, !tbaa !5
  %140 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %139, ptr noundef @.str.191) #5
  %141 = load i32, ptr @g_opts, align 4, !tbaa !11
  %142 = icmp sgt i32 %141, 2
  br i1 %142, label %143, label %145

143:                                              ; preds = %138
  %144 = load ptr, ptr %7, align 8, !tbaa !5
  call void @nifti_image_infodump(ptr noundef %144)
  br label %145

145:                                              ; preds = %143, %138
  br label %146

146:                                              ; preds = %145, %135
  %147 = getelementptr inbounds %struct.nifti_1_header, ptr %6, i32 0, i32 42
  %148 = getelementptr inbounds [4 x i8], ptr %147, i64 0, i64 1
  %149 = load i8, ptr %148, align 1, !tbaa !13
  %150 = sext i8 %149 to i32
  %151 = icmp eq i32 %150, 43
  br i1 %151, label %152, label %159

152:                                              ; preds = %146
  %153 = load ptr, ptr %7, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.nifti_image, ptr %153, i32 0, i32 57
  %155 = load i32, ptr %154, align 8, !tbaa !14
  %156 = sext i32 %155 to i64
  %157 = sub i64 %156, 348
  %158 = trunc i64 %157 to i32
  store i32 %158, ptr %12, align 4, !tbaa !9
  br label %164

159:                                              ; preds = %146
  %160 = load i32, ptr %11, align 4, !tbaa !9
  %161 = sext i32 %160 to i64
  %162 = sub i64 %161, 348
  %163 = trunc i64 %162 to i32
  store i32 %163, ptr %12, align 4, !tbaa !9
  br label %164

164:                                              ; preds = %159, %152
  %165 = load ptr, ptr %7, align 8, !tbaa !5
  %166 = load ptr, ptr %8, align 8, !tbaa !5
  %167 = load i32, ptr %12, align 4, !tbaa !9
  %168 = call i32 @nifti_read_extensions(ptr noundef %165, ptr noundef %166, i32 noundef %167)
  %169 = call i32 @Xznzclose(ptr noundef %8)
  %170 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free(ptr noundef %170) #5
  %171 = load i32, ptr %5, align 4, !tbaa !9
  %172 = icmp ne i32 %171, 0
  br i1 %172, label %173, label %180

173:                                              ; preds = %164
  %174 = load ptr, ptr %7, align 8, !tbaa !5
  %175 = call i32 @nifti_image_load(ptr noundef %174)
  %176 = icmp slt i32 %175, 0
  br i1 %176, label %177, label %179

177:                                              ; preds = %173
  %178 = load ptr, ptr %7, align 8, !tbaa !5
  call void @nifti_image_free(ptr noundef %178)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %15, align 4
  br label %185

179:                                              ; preds = %173
  br label %183

180:                                              ; preds = %164
  %181 = load ptr, ptr %7, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.nifti_image, ptr %181, i32 0, i32 60
  store ptr null, ptr %182, align 8, !tbaa !19
  br label %183

183:                                              ; preds = %180, %179
  %184 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %184, ptr %3, align 8
  store i32 1, ptr %15, align 4
  br label %185

185:                                              ; preds = %183, %177, %133, %116, %92, %86, %71, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 17, ptr %13) #5
  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 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 348, ptr %6) #5
  %186 = load ptr, ptr %3, align 8
  ret ptr %186
}

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

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

declare i32 @Xznzclose(ptr 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 i32 @nifti_get_filesize(ptr noundef) #2

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @nifti_convert_nhdr2nim(ptr noundef byval(%struct.nifti_1_header) align 8, ptr noundef) #2

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @nifti_read_extensions(ptr noundef, ptr noundef, i32 noundef) #2

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

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 = { "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 }

!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 = !{!7, !7, i64 0}
!14 = !{!15, !10, i64 648}
!15 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !7, i64 32, !16, i64 64, !10, i64 72, !10, i64 76, !17, i64 80, !17, i64 84, !17, i64 88, !17, i64 92, !17, i64 96, !17, i64 100, !17, i64 104, !7, i64 108, !17, i64 140, !17, i64 144, !17, i64 148, !17, i64 152, !10, i64 156, !10, i64 160, !10, i64 164, !10, i64 168, !10, i64 172, !10, i64 176, !10, i64 180, !10, i64 184, !17, i64 188, !17, i64 192, !17, i64 196, !17, i64 200, !17, i64 204, !17, i64 208, !17, i64 212, !17, i64 216, !18, i64 220, !18, i64 284, !18, i64 348, !18, i64 412, !17, i64 476, !10, i64 480, !10, i64 484, !10, i64 488, !10, i64 492, !17, i64 496, !17, i64 500, !17, i64 504, !7, i64 508, !7, i64 524, !7, i64 604, !6, i64 632, !6, i64 640, !10, i64 648, !10, i64 652, !10, i64 656, !6, i64 664, !10, i64 672, !6, i64 680, !10, i64 688}
!16 = !{!"long", !7, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!"", !7, i64 0}
!19 = !{!15, !6, i64 664}


; 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
@.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.173 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.174 = external hidden unnamed_addr constant [25 x i8], align 1
@__const.nifti_image_read.fname = external hidden unnamed_addr constant [17 x i8], align 16
@.str.187 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.188 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.189 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.190 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.191 = external hidden unnamed_addr constant [42 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
define dso_local ptr @nifti_image_read(ptr noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = alloca %struct.nifti_1_header, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [17 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 348, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 17, ptr nonnull %5) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(17) %5, ptr noundef nonnull align 16 dereferenceable(17) @__const.nifti_image_read.fname, i64 17, i1 false)
  %6 = load i32, ptr @g_opts, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 1
  br i1 %7, label %8, label %13

8:                                                ; preds = %2
  %9 = load ptr, ptr @stderr, align 8, !tbaa !10
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.187, ptr noundef %0, i32 noundef %1) #7
  %11 = load ptr, ptr @stderr, align 8, !tbaa !10
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.188) #7
  br label %13

13:                                               ; preds = %8, %2
  %14 = tail call ptr @nifti_findhdrname(ptr noundef %0)
  %15 = icmp eq ptr %14, null
  %16 = load i32, ptr @g_opts, align 4, !tbaa !5
  br i1 %15, label %17, label %22

17:                                               ; preds = %13
  %18 = icmp sgt i32 %16, 0
  br i1 %18, label %19, label %108

19:                                               ; preds = %17
  %20 = load ptr, ptr @stderr, align 8, !tbaa !10
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef nonnull @.str.115, ptr noundef nonnull %5, ptr noundef nonnull @.str.169, ptr noundef %0) #7
  br label %108

22:                                               ; preds = %13
  %23 = icmp sgt i32 %16, 1
  br i1 %23, label %24, label %27

24:                                               ; preds = %22
  %25 = load ptr, ptr @stderr, align 8, !tbaa !10
  %26 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str.170, ptr noundef nonnull %5, ptr noundef nonnull %14) #7
  br label %27

27:                                               ; preds = %22, %24
  %28 = call i32 @nifti_is_gzfile(ptr noundef nonnull %14)
  %.not = icmp eq i32 %28, 0
  br i1 %.not, label %29, label %31

29:                                               ; preds = %27
  %30 = call i32 @nifti_get_filesize(ptr noundef nonnull %14)
  br label %31

31:                                               ; preds = %27, %29
  %.038 = phi i32 [ %30, %29 ], [ -1, %27 ]
  %32 = call i32 @nifti_is_gzfile(ptr noundef nonnull %14)
  %33 = call ptr @znzopen(ptr noundef nonnull %14, ptr noundef nonnull @.str.140, i32 noundef %32) #6
  store ptr %33, ptr %4, align 8, !tbaa !10
  %34 = icmp eq ptr %33, null
  br i1 %34, label %35, label %42

35:                                               ; preds = %31
  %36 = load i32, ptr @g_opts, align 4, !tbaa !5
  %37 = icmp sgt i32 %36, 0
  br i1 %37, label %38, label %41

38:                                               ; preds = %35
  %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 %5, ptr noundef nonnull @.str.171, ptr noundef nonnull %14) #7
  br label %41

41:                                               ; preds = %38, %35
  call void @free(ptr noundef nonnull %14) #6
  br label %108

42:                                               ; preds = %31
  %43 = call i32 @has_ascii_header(ptr noundef nonnull %33)
  %44 = icmp slt i32 %43, 0
  br i1 %44, label %45, label %53

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

48:                                               ; preds = %45
  %49 = load ptr, ptr @stderr, align 8, !tbaa !10
  %50 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef nonnull @.str.115, ptr noundef nonnull %5, ptr noundef nonnull @.str.189, ptr noundef nonnull %14) #7
  br label %51

51:                                               ; preds = %48, %45
  %52 = call i32 @Xznzclose(ptr noundef nonnull %4) #6
  call void @free(ptr noundef nonnull %14) #6
  br label %108

53:                                               ; preds = %42
  %54 = icmp eq i32 %43, 1
  br i1 %54, label %55, label %57

55:                                               ; preds = %53
  %56 = call ptr @nifti_read_ascii_image(ptr noundef nonnull %33, ptr noundef nonnull %14, i32 noundef %.038, i32 noundef %1)
  br label %108

57:                                               ; preds = %53
  %58 = call i64 @znzread(ptr noundef nonnull %3, i64 noundef 1, i64 noundef 348, ptr noundef nonnull %33) #6
  %59 = trunc i64 %58 to i32
  %60 = icmp slt i32 %59, 348
  br i1 %60, label %61, label %71

61:                                               ; preds = %57
  %62 = load i32, ptr @g_opts, align 4, !tbaa !5
  %63 = icmp sgt i32 %62, 0
  br i1 %63, label %64, label %69

64:                                               ; preds = %61
  %65 = load ptr, ptr @stderr, align 8, !tbaa !10
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef nonnull @.str.115, ptr noundef nonnull %5, ptr noundef nonnull @.str.173, ptr noundef nonnull %14) #7
  %67 = load ptr, ptr @stderr, align 8, !tbaa !10
  %68 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %67, ptr noundef nonnull @.str.174, i32 noundef %59, i32 noundef 348) #7
  br label %69

69:                                               ; preds = %64, %61
  %70 = call i32 @Xznzclose(ptr noundef nonnull %4) #6
  call void @free(ptr noundef nonnull %14) #6
  br label %108

71:                                               ; preds = %57
  %72 = call ptr @nifti_convert_nhdr2nim(ptr noundef nonnull byval(%struct.nifti_1_header) align 8 %3, ptr noundef nonnull %14)
  %73 = icmp eq ptr %72, null
  br i1 %73, label %74, label %82

74:                                               ; preds = %71
  %75 = call i32 @Xznzclose(ptr noundef nonnull %4) #6
  %76 = load i32, ptr @g_opts, align 4, !tbaa !5
  %77 = icmp sgt i32 %76, 0
  br i1 %77, label %78, label %81

78:                                               ; preds = %74
  %79 = load ptr, ptr @stderr, align 8, !tbaa !10
  %80 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %79, ptr noundef nonnull @.str.115, ptr noundef nonnull %5, ptr noundef nonnull @.str.190, ptr noundef nonnull %14) #7
  br label %81

81:                                               ; preds = %78, %74
  call void @free(ptr noundef nonnull %14) #6
  br label %108

82:                                               ; preds = %71
  %83 = load i32, ptr @g_opts, align 4, !tbaa !5
  %84 = icmp sgt i32 %83, 3
  br i1 %84, label %85, label %91

85:                                               ; preds = %82
  %86 = load ptr, ptr @stderr, align 8, !tbaa !10
  %87 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %86, ptr noundef nonnull @.str.191) #7
  %88 = load i32, ptr @g_opts, align 4, !tbaa !5
  %89 = icmp sgt i32 %88, 2
  br i1 %89, label %90, label %91

90:                                               ; preds = %85
  call void @nifti_image_infodump(ptr noundef nonnull %72)
  br label %91

91:                                               ; preds = %85, %90, %82
  %92 = getelementptr inbounds i8, ptr %3, i64 345
  %93 = load i8, ptr %92, align 1, !tbaa !12
  %94 = icmp eq i8 %93, 43
  br i1 %94, label %95, label %98

95:                                               ; preds = %91
  %96 = getelementptr inbounds i8, ptr %72, i64 648
  %97 = load i32, ptr %96, align 8, !tbaa !13
  br label %98

98:                                               ; preds = %91, %95
  %.0.in = phi i32 [ %97, %95 ], [ %.038, %91 ]
  %.0 = add i32 %.0.in, -348
  %99 = load ptr, ptr %4, align 8, !tbaa !10
  %100 = call i32 @nifti_read_extensions(ptr noundef nonnull %72, ptr noundef %99, i32 noundef %.0)
  %101 = call i32 @Xznzclose(ptr noundef nonnull %4) #6
  call void @free(ptr noundef nonnull %14) #6
  %.not45 = icmp eq i32 %1, 0
  br i1 %.not45, label %106, label %102

102:                                              ; preds = %98
  %103 = call i32 @nifti_image_load(ptr noundef nonnull %72)
  %104 = icmp slt i32 %103, 0
  br i1 %104, label %105, label %108

105:                                              ; preds = %102
  call void @nifti_image_free(ptr noundef nonnull %72)
  br label %108

106:                                              ; preds = %98
  %107 = getelementptr inbounds i8, ptr %72, i64 664
  store ptr null, ptr %107, align 8, !tbaa !18
  br label %108

108:                                              ; preds = %106, %102, %17, %19, %105, %81, %69, %55, %51, %41
  %.039 = phi ptr [ null, %41 ], [ null, %51 ], [ %56, %55 ], [ null, %69 ], [ null, %81 ], [ null, %105 ], [ null, %19 ], [ null, %17 ], [ %72, %102 ], [ %72, %106 ]
  call void @llvm.lifetime.end.p0(i64 17, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 348, ptr nonnull %3) #6
  ret ptr %.039
}

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

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

declare i32 @Xznzclose(ptr 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 i32 @nifti_get_filesize(ptr noundef) local_unnamed_addr #2

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @nifti_convert_nhdr2nim(ptr noundef byval(%struct.nifti_1_header) align 8, ptr noundef) local_unnamed_addr #2

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @nifti_read_extensions(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

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 = { 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 #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
attributes #7 = { 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, !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 = !{!8, !8, i64 0}
!13 = !{!14, !7, i64 648}
!14 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !8, i64 32, !15, i64 64, !7, i64 72, !7, i64 76, !16, i64 80, !16, i64 84, !16, i64 88, !16, i64 92, !16, i64 96, !16, i64 100, !16, i64 104, !8, i64 108, !16, i64 140, !16, i64 144, !16, i64 148, !16, i64 152, !7, i64 156, !7, i64 160, !7, i64 164, !7, i64 168, !7, i64 172, !7, i64 176, !7, i64 180, !7, i64 184, !16, i64 188, !16, i64 192, !16, i64 196, !16, i64 200, !16, i64 204, !16, i64 208, !16, i64 212, !16, i64 216, !17, i64 220, !17, i64 284, !17, i64 348, !17, i64 412, !16, i64 476, !7, i64 480, !7, i64 484, !7, i64 488, !7, i64 492, !16, i64 496, !16, i64 500, !16, i64 504, !8, i64 508, !8, i64 524, !8, i64 604, !11, i64 632, !11, i64 640, !7, i64 648, !7, i64 652, !7, i64 656, !11, i64 664, !7, i64 672, !11, i64 680, !7, i64 688}
!15 = !{!"long", !8, i64 0}
!16 = !{!"float", !8, i64 0}
!17 = !{!"", !8, i64 0}
!18 = !{!14, !11, i64 664}


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