; 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
@__const.nifti_image_write_hdr_img2.func = external hidden unnamed_addr constant [27 x i8], align 16
@.str.235 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.236 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.237 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.238 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.239 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.240 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.241 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.242 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.243 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.244 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.245 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.246 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.247 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.248 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.249 = external hidden unnamed_addr constant [23 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: 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 uwtable
declare dso_local i32 @nifti_validfilename(ptr noundef) #4

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

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #5

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

declare i64 @znzseek(ptr noundef, i64 noundef, i32 noundef) #2

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @nifti_convert_nim2nhdr(ptr dead_on_unwind noalias writable sret(%struct.nifti_1_header) align 4, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @nifti_set_iname_offset(ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local ptr @nifti_image_write_hdr_img2(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #4 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca %struct.nifti_1_header, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca [27 x i8], align 16
  %18 = alloca i32, align 4
  %19 = alloca %struct.nifti_1_header, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 348, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store ptr null, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.start.p0(i64 27, ptr %17) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %17, ptr align 16 @__const.nifti_image_write_hdr_img2.func, i64 27, i1 false)
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = and i32 %20, 1
  store i32 %21, ptr %15, align 4, !tbaa !9
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = and i32 %22, 2
  store i32 %23, ptr %16, align 4, !tbaa !9
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %33, label %26

26:                                               ; preds = %5
  br label %27

27:                                               ; preds = %26
  %28 = load ptr, ptr @stderr, align 8, !tbaa !5
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str.235, ptr noundef @.str.236) #6
  %30 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %30, ptr %6, align 8
  store i32 1, ptr %18, align 4
  br label %321

31:                                               ; No predecessors!
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32, %5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.nifti_image, ptr %34, i32 0, i32 55
  %36 = load ptr, ptr %35, align 8, !tbaa !11
  %37 = call i32 @nifti_validfilename(ptr noundef %36)
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %46, label %39

39:                                               ; preds = %33
  br label %40

40:                                               ; preds = %39
  %41 = load ptr, ptr @stderr, align 8, !tbaa !5
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef @.str.235, ptr noundef @.str.237) #6
  %43 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %43, ptr %6, align 8
  store i32 1, ptr %18, align 4
  br label %321

44:                                               ; No predecessors!
  br label %45

45:                                               ; preds = %44
  br label %46

46:                                               ; preds = %45, %33
  %47 = load i32, ptr %15, align 4, !tbaa !9
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %64

49:                                               ; preds = %46
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.nifti_image, ptr %50, i32 0, i32 60
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = icmp ne ptr %52, null
  br i1 %53, label %64, label %54

54:                                               ; preds = %49
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = icmp ne ptr %55, null
  br i1 %56, label %64, label %57

57:                                               ; preds = %54
  br label %58

58:                                               ; preds = %57
  %59 = load ptr, ptr @stderr, align 8, !tbaa !5
  %60 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %59, ptr noundef @.str.235, ptr noundef @.str.238) #6
  %61 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %61, ptr %6, align 8
  store i32 1, ptr %18, align 4
  br label %321

62:                                               ; No predecessors!
  br label %63

63:                                               ; preds = %62
  br label %64

64:                                               ; preds = %63, %54, %49, %46
  %65 = load i32, ptr %15, align 4, !tbaa !9
  %66 = icmp ne i32 %65, 0
  br i1 %66, label %67, label %82

67:                                               ; preds = %64
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = icmp ne ptr %68, null
  br i1 %69, label %70, label %82

70:                                               ; preds = %67
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = load ptr, ptr %11, align 8, !tbaa !5
  %73 = call i32 @nifti_NBL_matches_nim(ptr noundef %71, ptr noundef %72)
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %82, label %75

75:                                               ; preds = %70
  br label %76

76:                                               ; preds = %75
  %77 = load ptr, ptr @stderr, align 8, !tbaa !5
  %78 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %77, ptr noundef @.str.235, ptr noundef @.str.239) #6
  %79 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %79, ptr %6, align 8
  store i32 1, ptr %18, align 4
  br label %321

80:                                               ; No predecessors!
  br label %81

81:                                               ; preds = %80
  br label %82

82:                                               ; preds = %81, %70, %67, %64
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  call void @nifti_set_iname_offset(ptr noundef %83)
  %84 = load i32, ptr @g_opts, align 4, !tbaa !17
  %85 = icmp sgt i32 %84, 1
  br i1 %85, label %86, label %104

86:                                               ; preds = %82
  %87 = load ptr, ptr @stderr, align 8, !tbaa !5
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.nifti_image, ptr %88, i32 0, i32 55
  %90 = load ptr, ptr %89, align 8, !tbaa !11
  %91 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %87, ptr noundef @.str.240, ptr noundef %90) #6
  %92 = load i32, ptr @g_opts, align 4, !tbaa !17
  %93 = icmp sgt i32 %92, 2
  br i1 %93, label %94, label %103

94:                                               ; preds = %86
  %95 = load ptr, ptr @stderr, align 8, !tbaa !5
  %96 = load ptr, ptr %7, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.nifti_image, ptr %96, i32 0, i32 47
  %98 = load i32, ptr %97, align 8, !tbaa !19
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.nifti_image, ptr %99, i32 0, i32 57
  %101 = load i32, ptr %100, align 8, !tbaa !20
  %102 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %95, ptr noundef @.str.241, i32 noundef %98, i32 noundef %101) #6
  br label %103

103:                                              ; preds = %94, %86
  br label %104

104:                                              ; preds = %103, %82
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.nifti_image, ptr %105, i32 0, i32 47
  %107 = load i32, ptr %106, align 8, !tbaa !19
  %108 = icmp eq i32 %107, 3
  br i1 %108, label %109, label %116

109:                                              ; preds = %104
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  %111 = load ptr, ptr %11, align 8, !tbaa !5
  %112 = load ptr, ptr %9, align 8, !tbaa !5
  %113 = load i32, ptr %15, align 4, !tbaa !9
  %114 = load i32, ptr %16, align 4, !tbaa !9
  %115 = call ptr @nifti_write_ascii_image(ptr noundef %110, ptr noundef %111, ptr noundef %112, i32 noundef %113, i32 noundef %114)
  store ptr %115, ptr %6, align 8
  store i32 1, ptr %18, align 4
  br label %321

116:                                              ; preds = %104
  call void @llvm.lifetime.start.p0(i64 348, ptr %19) #6
  %117 = load ptr, ptr %7, align 8, !tbaa !5
  call void @nifti_convert_nim2nhdr(ptr dead_on_unwind writable sret(%struct.nifti_1_header) align 4 %19, ptr noundef %117)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %19, i64 348, i1 false), !tbaa.struct !21
  call void @llvm.lifetime.end.p0(i64 348, ptr %19) #6
  %118 = load ptr, ptr %7, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.nifti_image, ptr %118, i32 0, i32 47
  %120 = load i32, ptr %119, align 8, !tbaa !19
  %121 = icmp ne i32 %120, 1
  br i1 %121, label %122, label %164

122:                                              ; preds = %116
  %123 = load ptr, ptr %7, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.nifti_image, ptr %123, i32 0, i32 56
  %125 = load ptr, ptr %124, align 8, !tbaa !26
  %126 = icmp ne ptr %125, null
  br i1 %126, label %127, label %142

127:                                              ; preds = %122
  %128 = load ptr, ptr %7, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.nifti_image, ptr %128, i32 0, i32 56
  %130 = load ptr, ptr %129, align 8, !tbaa !26
  %131 = load ptr, ptr %7, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.nifti_image, ptr %131, i32 0, i32 55
  %133 = load ptr, ptr %132, align 8, !tbaa !11
  %134 = call i32 @strcmp(ptr noundef %130, ptr noundef %133) #7
  %135 = icmp eq i32 %134, 0
  br i1 %135, label %136, label %142

136:                                              ; preds = %127
  %137 = load ptr, ptr %7, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.nifti_image, ptr %137, i32 0, i32 56
  %139 = load ptr, ptr %138, align 8, !tbaa !26
  call void @free(ptr noundef %139) #6
  %140 = load ptr, ptr %7, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.nifti_image, ptr %140, i32 0, i32 56
  store ptr null, ptr %141, align 8, !tbaa !26
  br label %142

142:                                              ; preds = %136, %127, %122
  %143 = load ptr, ptr %7, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.nifti_image, ptr %143, i32 0, i32 56
  %145 = load ptr, ptr %144, align 8, !tbaa !26
  %146 = icmp eq ptr %145, null
  br i1 %146, label %147, label %163

147:                                              ; preds = %142
  %148 = load ptr, ptr %7, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.nifti_image, ptr %148, i32 0, i32 55
  %150 = load ptr, ptr %149, align 8, !tbaa !11
  %151 = load ptr, ptr %7, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.nifti_image, ptr %151, i32 0, i32 47
  %153 = load i32, ptr %152, align 8, !tbaa !19
  %154 = call ptr @nifti_makeimgname(ptr noundef %150, i32 noundef %153, i32 noundef 0, i32 noundef 0)
  %155 = load ptr, ptr %7, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.nifti_image, ptr %155, i32 0, i32 56
  store ptr %154, ptr %156, align 8, !tbaa !26
  %157 = load ptr, ptr %7, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.nifti_image, ptr %157, i32 0, i32 56
  %159 = load ptr, ptr %158, align 8, !tbaa !26
  %160 = icmp eq ptr %159, null
  br i1 %160, label %161, label %162

161:                                              ; preds = %147
  store ptr null, ptr %6, align 8
  store i32 1, ptr %18, align 4
  br label %321

162:                                              ; preds = %147
  br label %163

163:                                              ; preds = %162, %142
  br label %164

164:                                              ; preds = %163, %116
  %165 = load ptr, ptr %10, align 8, !tbaa !5
  %166 = icmp eq ptr %165, null
  br i1 %166, label %180, label %167

167:                                              ; preds = %164
  %168 = load ptr, ptr %7, align 8, !tbaa !5
  %169 = getelementptr inbounds %struct.nifti_image, ptr %168, i32 0, i32 47
  %170 = load i32, ptr %169, align 8, !tbaa !19
  %171 = icmp eq i32 %170, 1
  br i1 %171, label %172, label %180

172:                                              ; preds = %167
  %173 = load i32, ptr @g_opts, align 4, !tbaa !17
  %174 = icmp sgt i32 %173, 2
  br i1 %174, label %175, label %178

175:                                              ; preds = %172
  %176 = load ptr, ptr @stderr, align 8, !tbaa !5
  %177 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %176, ptr noundef @.str.242) #6
  br label %178

178:                                              ; preds = %175, %172
  %179 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %179, ptr %13, align 8, !tbaa !5
  br label %211

180:                                              ; preds = %167, %164
  %181 = load i32, ptr @g_opts, align 4, !tbaa !17
  %182 = icmp sgt i32 %181, 2
  br i1 %182, label %183, label %190

183:                                              ; preds = %180
  %184 = load ptr, ptr @stderr, align 8, !tbaa !5
  %185 = load ptr, ptr %7, align 8, !tbaa !5
  %186 = getelementptr inbounds %struct.nifti_image, ptr %185, i32 0, i32 55
  %187 = load ptr, ptr %186, align 8, !tbaa !11
  %188 = load ptr, ptr %9, align 8, !tbaa !5
  %189 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %184, ptr noundef @.str.243, ptr noundef %187, ptr noundef %188) #6
  br label %190

190:                                              ; preds = %183, %180
  %191 = load ptr, ptr %7, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.nifti_image, ptr %191, i32 0, i32 55
  %193 = load ptr, ptr %192, align 8, !tbaa !11
  %194 = load ptr, ptr %9, align 8, !tbaa !5
  %195 = load ptr, ptr %7, align 8, !tbaa !5
  %196 = getelementptr inbounds %struct.nifti_image, ptr %195, i32 0, i32 55
  %197 = load ptr, ptr %196, align 8, !tbaa !11
  %198 = call i32 @nifti_is_gzfile(ptr noundef %197)
  %199 = call ptr @znzopen(ptr noundef %193, ptr noundef %194, i32 noundef %198)
  store ptr %199, ptr %13, align 8, !tbaa !5
  %200 = load ptr, ptr %13, align 8, !tbaa !5
  %201 = icmp eq ptr %200, null
  br i1 %201, label %202, label %210

202:                                              ; preds = %190
  %203 = load ptr, ptr @stderr, align 8, !tbaa !5
  %204 = getelementptr inbounds [27 x i8], ptr %17, i64 0, i64 0
  %205 = load ptr, ptr %7, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct.nifti_image, ptr %205, i32 0, i32 55
  %207 = load ptr, ptr %206, align 8, !tbaa !11
  %208 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %203, ptr noundef @.str.115, ptr noundef %204, ptr noundef @.str.244, ptr noundef %207) #6
  %209 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %209, ptr %6, align 8
  store i32 1, ptr %18, align 4
  br label %321

210:                                              ; preds = %190
  br label %211

211:                                              ; preds = %210, %178
  %212 = load ptr, ptr %13, align 8, !tbaa !5
  %213 = call i64 @znzwrite(ptr noundef %12, i64 noundef 1, i64 noundef 348, ptr noundef %212)
  store i64 %213, ptr %14, align 8, !tbaa !27
  %214 = load i64, ptr %14, align 8, !tbaa !27
  %215 = icmp ult i64 %214, 348
  br i1 %215, label %216, label %225

216:                                              ; preds = %211
  %217 = load ptr, ptr @stderr, align 8, !tbaa !5
  %218 = getelementptr inbounds [27 x i8], ptr %17, i64 0, i64 0
  %219 = load ptr, ptr %7, align 8, !tbaa !5
  %220 = getelementptr inbounds %struct.nifti_image, ptr %219, i32 0, i32 55
  %221 = load ptr, ptr %220, align 8, !tbaa !11
  %222 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %217, ptr noundef @.str.115, ptr noundef %218, ptr noundef @.str.245, ptr noundef %221) #6
  %223 = call i32 @Xznzclose(ptr noundef %13)
  %224 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %224, ptr %6, align 8
  store i32 1, ptr %18, align 4
  br label %321

225:                                              ; preds = %211
  %226 = load ptr, ptr %7, align 8, !tbaa !5
  %227 = getelementptr inbounds %struct.nifti_image, ptr %226, i32 0, i32 47
  %228 = load i32, ptr %227, align 8, !tbaa !19
  %229 = icmp ne i32 %228, 0
  br i1 %229, label %230, label %234

230:                                              ; preds = %225
  %231 = load ptr, ptr %13, align 8, !tbaa !5
  %232 = load ptr, ptr %7, align 8, !tbaa !5
  %233 = call i32 @nifti_write_extensions(ptr noundef %231, ptr noundef %232)
  br label %234

234:                                              ; preds = %230, %225
  %235 = load i32, ptr %15, align 4, !tbaa !9
  %236 = icmp ne i32 %235, 0
  br i1 %236, label %249, label %237

237:                                              ; preds = %234
  %238 = load i32, ptr %16, align 4, !tbaa !9
  %239 = icmp ne i32 %238, 0
  br i1 %239, label %249, label %240

240:                                              ; preds = %237
  %241 = load i32, ptr @g_opts, align 4, !tbaa !17
  %242 = icmp sgt i32 %241, 2
  br i1 %242, label %243, label %246

243:                                              ; preds = %240
  %244 = load ptr, ptr @stderr, align 8, !tbaa !5
  %245 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %244, ptr noundef @.str.246) #6
  br label %246

246:                                              ; preds = %243, %240
  %247 = call i32 @Xznzclose(ptr noundef %13)
  %248 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %248, ptr %6, align 8
  store i32 1, ptr %18, align 4
  br label %321

249:                                              ; preds = %237, %234
  %250 = load ptr, ptr %7, align 8, !tbaa !5
  %251 = getelementptr inbounds %struct.nifti_image, ptr %250, i32 0, i32 47
  %252 = load i32, ptr %251, align 8, !tbaa !19
  %253 = icmp ne i32 %252, 1
  br i1 %253, label %254, label %296

254:                                              ; preds = %249
  %255 = call i32 @Xznzclose(ptr noundef %13)
  %256 = load ptr, ptr %10, align 8, !tbaa !5
  %257 = icmp eq ptr %256, null
  br i1 %257, label %266, label %258

258:                                              ; preds = %254
  %259 = load i32, ptr @g_opts, align 4, !tbaa !17
  %260 = icmp sgt i32 %259, 2
  br i1 %260, label %261, label %264

261:                                              ; preds = %258
  %262 = load ptr, ptr @stderr, align 8, !tbaa !5
  %263 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %262, ptr noundef @.str.247) #6
  br label %264

264:                                              ; preds = %261, %258
  %265 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %265, ptr %13, align 8, !tbaa !5
  br label %295

266:                                              ; preds = %254
  %267 = load i32, ptr @g_opts, align 4, !tbaa !17
  %268 = icmp sgt i32 %267, 2
  br i1 %268, label %269, label %275

269:                                              ; preds = %266
  %270 = load ptr, ptr @stderr, align 8, !tbaa !5
  %271 = load ptr, ptr %7, align 8, !tbaa !5
  %272 = getelementptr inbounds %struct.nifti_image, ptr %271, i32 0, i32 56
  %273 = load ptr, ptr %272, align 8, !tbaa !26
  %274 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %270, ptr noundef @.str.248, ptr noundef %273) #6
  br label %275

275:                                              ; preds = %269, %266
  %276 = load ptr, ptr %7, align 8, !tbaa !5
  %277 = getelementptr inbounds %struct.nifti_image, ptr %276, i32 0, i32 56
  %278 = load ptr, ptr %277, align 8, !tbaa !26
  %279 = load ptr, ptr %9, align 8, !tbaa !5
  %280 = load ptr, ptr %7, align 8, !tbaa !5
  %281 = getelementptr inbounds %struct.nifti_image, ptr %280, i32 0, i32 56
  %282 = load ptr, ptr %281, align 8, !tbaa !26
  %283 = call i32 @nifti_is_gzfile(ptr noundef %282)
  %284 = call ptr @znzopen(ptr noundef %278, ptr noundef %279, i32 noundef %283)
  store ptr %284, ptr %13, align 8, !tbaa !5
  %285 = load ptr, ptr %13, align 8, !tbaa !5
  %286 = icmp eq ptr %285, null
  br i1 %286, label %287, label %294

287:                                              ; preds = %275
  br label %288

288:                                              ; preds = %287
  %289 = load ptr, ptr @stderr, align 8, !tbaa !5
  %290 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %289, ptr noundef @.str.235, ptr noundef @.str.249) #6
  %291 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %291, ptr %6, align 8
  store i32 1, ptr %18, align 4
  br label %321

292:                                              ; No predecessors!
  br label %293

293:                                              ; preds = %292
  br label %294

294:                                              ; preds = %293, %275
  br label %295

295:                                              ; preds = %294, %264
  br label %296

296:                                              ; preds = %295, %249
  %297 = load ptr, ptr %13, align 8, !tbaa !5
  %298 = load ptr, ptr %7, align 8, !tbaa !5
  %299 = getelementptr inbounds %struct.nifti_image, ptr %298, i32 0, i32 57
  %300 = load i32, ptr %299, align 8, !tbaa !20
  %301 = sext i32 %300 to i64
  %302 = call i64 @znzseek(ptr noundef %297, i64 noundef %301, i32 noundef 0)
  %303 = icmp slt i64 %302, 0
  br i1 %303, label %304, label %306

304:                                              ; preds = %296
  %305 = call i32 @Xznzclose(ptr noundef %13)
  store ptr null, ptr %6, align 8
  store i32 1, ptr %18, align 4
  br label %321

306:                                              ; preds = %296
  %307 = load i32, ptr %15, align 4, !tbaa !9
  %308 = icmp ne i32 %307, 0
  br i1 %308, label %309, label %314

309:                                              ; preds = %306
  %310 = load ptr, ptr %13, align 8, !tbaa !5
  %311 = load ptr, ptr %7, align 8, !tbaa !5
  %312 = load ptr, ptr %11, align 8, !tbaa !5
  %313 = call i32 @nifti_write_all_data(ptr noundef %310, ptr noundef %311, ptr noundef %312)
  br label %314

314:                                              ; preds = %309, %306
  %315 = load i32, ptr %16, align 4, !tbaa !9
  %316 = icmp ne i32 %315, 0
  br i1 %316, label %319, label %317

317:                                              ; preds = %314
  %318 = call i32 @Xznzclose(ptr noundef %13)
  br label %319

319:                                              ; preds = %317, %314
  %320 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %320, ptr %6, align 8
  store i32 1, ptr %18, align 4
  br label %321

321:                                              ; preds = %319, %304, %288, %246, %216, %202, %161, %109, %76, %58, %40, %27
  call void @llvm.lifetime.end.p0(i64 27, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 348, ptr %12) #6
  %322 = load ptr, ptr %6, align 8
  ret ptr %322
}

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

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

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

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

!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, !6, i64 632}
!12 = !{!"", !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, !13, i64 64, !10, i64 72, !10, i64 76, !14, i64 80, !14, i64 84, !14, i64 88, !14, i64 92, !14, i64 96, !14, i64 100, !14, i64 104, !7, i64 108, !14, i64 140, !14, i64 144, !14, i64 148, !14, 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, !14, i64 188, !14, i64 192, !14, i64 196, !14, i64 200, !14, i64 204, !14, i64 208, !14, i64 212, !14, i64 216, !15, i64 220, !15, i64 284, !15, i64 348, !15, i64 412, !14, i64 476, !10, i64 480, !10, i64 484, !10, i64 488, !10, i64 492, !14, i64 496, !14, i64 500, !14, 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}
!13 = !{!"long", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!"", !7, i64 0}
!16 = !{!12, !6, i64 664}
!17 = !{!18, !10, i64 0}
!18 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!19 = !{!12, !10, i64 488}
!20 = !{!12, !10, i64 648}
!21 = !{i64 0, i64 4, !9, i64 4, i64 10, !22, i64 14, i64 18, !22, i64 32, i64 4, !9, i64 36, i64 2, !23, i64 38, i64 1, !22, i64 39, i64 1, !22, i64 40, i64 16, !22, i64 56, i64 4, !25, i64 60, i64 4, !25, i64 64, i64 4, !25, i64 68, i64 2, !23, i64 70, i64 2, !23, i64 72, i64 2, !23, i64 74, i64 2, !23, i64 76, i64 32, !22, i64 108, i64 4, !25, i64 112, i64 4, !25, i64 116, i64 4, !25, i64 120, i64 2, !23, i64 122, i64 1, !22, i64 123, i64 1, !22, i64 124, i64 4, !25, i64 128, i64 4, !25, i64 132, i64 4, !25, i64 136, i64 4, !25, i64 140, i64 4, !9, i64 144, i64 4, !9, i64 148, i64 80, !22, i64 228, i64 24, !22, i64 252, i64 2, !23, i64 254, i64 2, !23, i64 256, i64 4, !25, i64 260, i64 4, !25, i64 264, i64 4, !25, i64 268, i64 4, !25, i64 272, i64 4, !25, i64 276, i64 4, !25, i64 280, i64 16, !22, i64 296, i64 16, !22, i64 312, i64 16, !22, i64 328, i64 16, !22, i64 344, i64 4, !22}
!22 = !{!7, !7, i64 0}
!23 = !{!24, !24, i64 0}
!24 = !{!"short", !7, i64 0}
!25 = !{!14, !14, i64 0}
!26 = !{!12, !6, i64 640}
!27 = !{!13, !13, 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
@__const.nifti_image_write_hdr_img2.func = external hidden unnamed_addr constant [27 x i8], align 16
@.str.235 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.236 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.237 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.238 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.239 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.240 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.241 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.242 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.243 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.244 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.245 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.246 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.247 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.248 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.249 = external hidden unnamed_addr constant [23 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 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_validfilename(ptr noundef) local_unnamed_addr #5

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #6

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

declare i64 @znzseek(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #3

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @nifti_convert_nim2nhdr(ptr dead_on_unwind noalias writable sret(%struct.nifti_1_header) align 4, ptr noundef) local_unnamed_addr #5

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

; Function Attrs: nounwind uwtable
define dso_local ptr @nifti_image_write_hdr_img2(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #5 {
  %6 = alloca %struct.nifti_1_header, align 4
  %7 = alloca ptr, align 8
  %8 = alloca [27 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 348, ptr nonnull %6) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #7
  call void @llvm.lifetime.start.p0(i64 27, ptr nonnull %8) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(27) %8, ptr noundef nonnull align 16 dereferenceable(27) @__const.nifti_image_write_hdr_img2.func, i64 27, i1 false)
  %9 = and i32 %1, 1
  %10 = and i32 %1, 2
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %11, label %14

11:                                               ; preds = %5
  %12 = load ptr, ptr @stderr, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.235, ptr noundef nonnull @.str.236) #8
  br label %167

14:                                               ; preds = %5
  %15 = getelementptr inbounds i8, ptr %0, i64 632
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = tail call i32 @nifti_validfilename(ptr noundef %16)
  %.not69 = icmp eq i32 %17, 0
  br i1 %.not69, label %18, label %21

18:                                               ; preds = %14
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.235, ptr noundef nonnull @.str.237) #8
  br label %167

21:                                               ; preds = %14
  %.not78 = icmp eq i32 %9, 0
  br i1 %.not78, label %.thread, label %22

22:                                               ; preds = %21
  %23 = getelementptr inbounds i8, ptr %0, i64 664
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  %25 = icmp ne ptr %24, null
  %26 = icmp ne ptr %4, null
  %or.cond = or i1 %26, %25
  br i1 %or.cond, label %30, label %27

27:                                               ; preds = %22
  %28 = load ptr, ptr @stderr, align 8, !tbaa !5
  %29 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str.235, ptr noundef nonnull @.str.238) #8
  br label %167

30:                                               ; preds = %22
  %.not79 = icmp eq ptr %4, null
  br i1 %.not79, label %.thread, label %31

31:                                               ; preds = %30
  %32 = tail call i32 @nifti_NBL_matches_nim(ptr noundef nonnull %0, ptr noundef nonnull %4)
  %.not70 = icmp eq i32 %32, 0
  br i1 %.not70, label %33, label %.thread

33:                                               ; preds = %31
  %34 = load ptr, ptr @stderr, align 8, !tbaa !5
  %35 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef nonnull @.str.235, ptr noundef nonnull @.str.239) #8
  br label %167

.thread:                                          ; preds = %21, %31, %30
  tail call void @nifti_set_iname_offset(ptr noundef nonnull %0)
  %36 = load i32, ptr @g_opts, align 4, !tbaa !16
  %37 = icmp sgt i32 %36, 1
  br i1 %37, label %38, label %51

38:                                               ; preds = %.thread
  %39 = load ptr, ptr @stderr, align 8, !tbaa !5
  %40 = load ptr, ptr %15, align 8, !tbaa !9
  %41 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef nonnull @.str.240, ptr noundef %40) #8
  %42 = load i32, ptr @g_opts, align 4, !tbaa !16
  %43 = icmp sgt i32 %42, 2
  br i1 %43, label %44, label %51

44:                                               ; preds = %38
  %45 = load ptr, ptr @stderr, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %0, i64 488
  %47 = load i32, ptr %46, align 8, !tbaa !18
  %48 = getelementptr inbounds i8, ptr %0, i64 648
  %49 = load i32, ptr %48, align 8, !tbaa !19
  %50 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef nonnull @.str.241, i32 noundef %47, i32 noundef %49) #8
  br label %51

51:                                               ; preds = %38, %44, %.thread
  %52 = getelementptr inbounds i8, ptr %0, i64 488
  %53 = load i32, ptr %52, align 8, !tbaa !18
  %54 = icmp eq i32 %53, 3
  br i1 %54, label %55, label %57

55:                                               ; preds = %51
  %56 = tail call ptr @nifti_write_ascii_image(ptr noundef nonnull %0, ptr noundef %4, ptr noundef %2, i32 noundef %9, i32 noundef %10)
  br label %167

57:                                               ; preds = %51
  call void @nifti_convert_nim2nhdr(ptr dead_on_unwind nonnull writable sret(%struct.nifti_1_header) align 4 %6, ptr noundef nonnull %0)
  %58 = load i32, ptr %52, align 8, !tbaa !18
  %.not71 = icmp eq i32 %58, 1
  br i1 %.not71, label %70, label %59

59:                                               ; preds = %57
  %60 = getelementptr inbounds i8, ptr %0, i64 640
  %61 = load ptr, ptr %60, align 8, !tbaa !20
  %.not72 = icmp eq ptr %61, null
  %.pre80 = load ptr, ptr %15, align 8, !tbaa !9
  br i1 %.not72, label %.thread77, label %62

62:                                               ; preds = %59
  %63 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %61, ptr noundef nonnull dereferenceable(1) %.pre80) #9
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %65, label %70

65:                                               ; preds = %62
  call void @free(ptr noundef nonnull %61) #7
  store ptr null, ptr %60, align 8, !tbaa !20
  %.pre = load ptr, ptr %15, align 8, !tbaa !9
  %.pre81 = load i32, ptr %52, align 8, !tbaa !18
  br label %.thread77

.thread77:                                        ; preds = %59, %65
  %66 = phi i32 [ %58, %59 ], [ %.pre81, %65 ]
  %67 = phi ptr [ %.pre80, %59 ], [ %.pre, %65 ]
  %68 = call ptr @nifti_makeimgname(ptr noundef %67, i32 noundef %66, i32 noundef 0, i32 noundef 0)
  store ptr %68, ptr %60, align 8, !tbaa !20
  %69 = icmp eq ptr %68, null
  br i1 %69, label %167, label %70

70:                                               ; preds = %62, %.thread77, %57
  %71 = icmp eq ptr %3, null
  br i1 %71, label %82, label %72

72:                                               ; preds = %70
  %73 = load i32, ptr %52, align 8, !tbaa !18
  %74 = icmp eq i32 %73, 1
  br i1 %74, label %75, label %82

75:                                               ; preds = %72
  %76 = load i32, ptr @g_opts, align 4, !tbaa !16
  %77 = icmp sgt i32 %76, 2
  br i1 %77, label %78, label %81

78:                                               ; preds = %75
  %79 = load ptr, ptr @stderr, align 8, !tbaa !5
  %80 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %79, ptr noundef nonnull @.str.242) #8
  br label %81

81:                                               ; preds = %78, %75
  store ptr %3, ptr %7, align 8, !tbaa !5
  br label %97

82:                                               ; preds = %72, %70
  %83 = load i32, ptr @g_opts, align 4, !tbaa !16
  %84 = icmp sgt i32 %83, 2
  %.pre83 = load ptr, ptr %15, align 8, !tbaa !9
  br i1 %84, label %85, label %88

85:                                               ; preds = %82
  %86 = load ptr, ptr @stderr, align 8, !tbaa !5
  %87 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %86, ptr noundef nonnull @.str.243, ptr noundef %.pre83, ptr noundef %2) #8
  %.pre82 = load ptr, ptr %15, align 8, !tbaa !9
  br label %88

88:                                               ; preds = %85, %82
  %89 = phi ptr [ %.pre82, %85 ], [ %.pre83, %82 ]
  %90 = call i32 @nifti_is_gzfile(ptr noundef %89)
  %91 = call ptr @znzopen(ptr noundef %89, ptr noundef %2, i32 noundef %90) #7
  store ptr %91, ptr %7, align 8, !tbaa !5
  %92 = icmp eq ptr %91, null
  br i1 %92, label %93, label %97

93:                                               ; preds = %88
  %94 = load ptr, ptr @stderr, align 8, !tbaa !5
  %95 = load ptr, ptr %15, align 8, !tbaa !9
  %96 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %94, ptr noundef nonnull @.str.115, ptr noundef nonnull %8, ptr noundef nonnull @.str.244, ptr noundef %95) #8
  br label %167

97:                                               ; preds = %88, %81
  %98 = phi ptr [ %91, %88 ], [ %3, %81 ]
  %99 = call i64 @znzwrite(ptr noundef nonnull %6, i64 noundef 1, i64 noundef 348, ptr noundef nonnull %98) #7
  %100 = icmp ult i64 %99, 348
  br i1 %100, label %101, label %107

101:                                              ; preds = %97
  %102 = load ptr, ptr @stderr, align 8, !tbaa !5
  %103 = load ptr, ptr %15, align 8, !tbaa !9
  %104 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %102, ptr noundef nonnull @.str.115, ptr noundef nonnull %8, ptr noundef nonnull @.str.245, ptr noundef %103) #8
  %105 = call i32 @Xznzclose(ptr noundef nonnull %7) #7
  %106 = load ptr, ptr %7, align 8, !tbaa !5
  br label %167

107:                                              ; preds = %97
  %108 = load i32, ptr %52, align 8, !tbaa !18
  %.not73 = icmp eq i32 %108, 0
  br i1 %.not73, label %111, label %109

109:                                              ; preds = %107
  %110 = call i32 @nifti_write_extensions(ptr noundef nonnull %98, ptr noundef nonnull %0)
  br label %111

111:                                              ; preds = %109, %107
  %.not74 = icmp eq i32 %10, 0
  %112 = and i32 %1, 3
  %or.cond5.not = icmp eq i32 %112, 0
  br i1 %or.cond5.not, label %113, label %122

113:                                              ; preds = %111
  %114 = load i32, ptr @g_opts, align 4, !tbaa !16
  %115 = icmp sgt i32 %114, 2
  br i1 %115, label %116, label %119

116:                                              ; preds = %113
  %117 = load ptr, ptr @stderr, align 8, !tbaa !5
  %118 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %117, ptr noundef nonnull @.str.246) #8
  br label %119

119:                                              ; preds = %116, %113
  %120 = call i32 @Xznzclose(ptr noundef nonnull %7) #7
  %121 = load ptr, ptr %7, align 8, !tbaa !5
  br label %167

122:                                              ; preds = %111
  %123 = load i32, ptr %52, align 8, !tbaa !18
  %.not75 = icmp eq i32 %123, 1
  br i1 %.not75, label %._crit_edge, label %124

._crit_edge:                                      ; preds = %122
  %.pre84 = load ptr, ptr %7, align 8, !tbaa !5
  br label %149

124:                                              ; preds = %122
  %125 = call i32 @Xznzclose(ptr noundef nonnull %7) #7
  %126 = load i32, ptr @g_opts, align 4, !tbaa !16
  %127 = icmp sgt i32 %126, 2
  br i1 %71, label %133, label %128

128:                                              ; preds = %124
  br i1 %127, label %129, label %132

129:                                              ; preds = %128
  %130 = load ptr, ptr @stderr, align 8, !tbaa !5
  %131 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %130, ptr noundef nonnull @.str.247) #8
  br label %132

132:                                              ; preds = %129, %128
  store ptr %3, ptr %7, align 8, !tbaa !5
  br label %149

133:                                              ; preds = %124
  br i1 %127, label %134, label %139

134:                                              ; preds = %133
  %135 = load ptr, ptr @stderr, align 8, !tbaa !5
  %136 = getelementptr inbounds i8, ptr %0, i64 640
  %137 = load ptr, ptr %136, align 8, !tbaa !20
  %138 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %135, ptr noundef nonnull @.str.248, ptr noundef %137) #8
  br label %139

139:                                              ; preds = %134, %133
  %140 = getelementptr inbounds i8, ptr %0, i64 640
  %141 = load ptr, ptr %140, align 8, !tbaa !20
  %142 = call i32 @nifti_is_gzfile(ptr noundef %141)
  %143 = call ptr @znzopen(ptr noundef %141, ptr noundef %2, i32 noundef %142) #7
  store ptr %143, ptr %7, align 8, !tbaa !5
  %144 = icmp eq ptr %143, null
  br i1 %144, label %145, label %149

145:                                              ; preds = %139
  %146 = load ptr, ptr @stderr, align 8, !tbaa !5
  %147 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %146, ptr noundef nonnull @.str.235, ptr noundef nonnull @.str.249) #8
  %148 = load ptr, ptr %7, align 8, !tbaa !5
  br label %167

149:                                              ; preds = %._crit_edge, %132, %139
  %150 = phi ptr [ %.pre84, %._crit_edge ], [ %3, %132 ], [ %143, %139 ]
  %151 = getelementptr inbounds i8, ptr %0, i64 648
  %152 = load i32, ptr %151, align 8, !tbaa !19
  %153 = sext i32 %152 to i64
  %154 = call i64 @znzseek(ptr noundef %150, i64 noundef %153, i32 noundef 0) #7
  %155 = icmp slt i64 %154, 0
  br i1 %155, label %156, label %158

156:                                              ; preds = %149
  %157 = call i32 @Xznzclose(ptr noundef nonnull %7) #7
  br label %167

158:                                              ; preds = %149
  br i1 %.not78, label %162, label %159

159:                                              ; preds = %158
  %160 = load ptr, ptr %7, align 8, !tbaa !5
  %161 = call i32 @nifti_write_all_data(ptr noundef %160, ptr noundef nonnull %0, ptr noundef %4)
  br label %162

162:                                              ; preds = %159, %158
  br i1 %.not74, label %163, label %165

163:                                              ; preds = %162
  %164 = call i32 @Xznzclose(ptr noundef nonnull %7) #7
  br label %165

165:                                              ; preds = %163, %162
  %166 = load ptr, ptr %7, align 8, !tbaa !5
  br label %167

167:                                              ; preds = %.thread77, %165, %156, %145, %119, %101, %93, %55, %33, %27, %18, %11
  %.0 = phi ptr [ %56, %55 ], [ null, %93 ], [ %106, %101 ], [ %148, %145 ], [ null, %156 ], [ %166, %165 ], [ %121, %119 ], [ null, %33 ], [ null, %27 ], [ null, %18 ], [ null, %11 ], [ null, %.thread77 ]
  call void @llvm.lifetime.end.p0(i64 27, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 348, ptr nonnull %6) #7
  ret ptr %.0
}

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

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

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

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 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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }

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


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MemCpyOptPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass