; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/ThirdParty/NIFTI/src/nifti/niftilib (nifti1_tool)

; 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.nt_opts = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [8 x i32], [8 x i32], i32, i32, i32, i32, ptr, %struct.str_list, %struct.int_list, %struct.str_list, %struct.str_list, %struct.str_list, [2048 x i8] }
%struct.int_list = type { i32, ptr }
%struct.str_list = type { i32, ptr }

@stderr = external global ptr, align 8
@g_debug = external hidden global i32, align 4
@.str.226 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.227 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.228 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.229 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.230 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.231 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.232 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.233 = external hidden unnamed_addr constant [38 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @act_add_exts(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store ptr null, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %11 = load i32, ptr @g_debug, align 4, !tbaa !9
  %12 = icmp sgt i32 %11, 2
  br i1 %12, label %13, label %33

13:                                               ; preds = %1
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.nt_opts, ptr %15, i32 0, i32 29
  %17 = getelementptr inbounds %struct.str_list, ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.nt_opts, ptr %19, i32 0, i32 33
  %21 = getelementptr inbounds %struct.str_list, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !14
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef @.str.226, i32 noundef %18, i32 noundef %22) #5
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.nt_opts, ptr %24, i32 0, i32 30
  %26 = getelementptr inbounds %struct.int_list, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !15
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.nt_opts, ptr %28, i32 0, i32 30
  %30 = getelementptr inbounds %struct.int_list, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !16
  %32 = call i32 @disp_raw_data(ptr noundef %27, i32 noundef 8, i32 noundef %31, i8 noundef signext 32, i32 noundef 1)
  br label %33

33:                                               ; preds = %13, %1
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.nt_opts, ptr %34, i32 0, i32 28
  %36 = load ptr, ptr %35, align 8, !tbaa !17
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %51

38:                                               ; preds = %33
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.nt_opts, ptr %39, i32 0, i32 33
  %41 = getelementptr inbounds %struct.str_list, ptr %40, i32 0, i32 0
  %42 = load i32, ptr %41, align 8, !tbaa !14
  %43 = icmp ne i32 %42, 1
  br i1 %43, label %44, label %51

44:                                               ; preds = %38
  %45 = load ptr, ptr @stderr, align 8, !tbaa !5
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.nt_opts, ptr %46, i32 0, i32 33
  %48 = getelementptr inbounds %struct.str_list, ptr %47, i32 0, i32 0
  %49 = load i32, ptr %48, align 8, !tbaa !14
  %50 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef @.str.227, i32 noundef %49) #5
  store i32 1, ptr %2, align 4
  store i32 1, ptr %10, align 4
  br label %234

51:                                               ; preds = %38, %33
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.nt_opts, ptr %52, i32 0, i32 29
  %54 = getelementptr inbounds %struct.str_list, ptr %53, i32 0, i32 0
  %55 = load i32, ptr %54, align 8, !tbaa !11
  %56 = icmp sle i32 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %51
  store i32 0, ptr %2, align 4
  store i32 1, ptr %10, align 4
  br label %234

58:                                               ; preds = %51
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %216, %58
  %60 = load i32, ptr %7, align 4, !tbaa !9
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.nt_opts, ptr %61, i32 0, i32 33
  %63 = getelementptr inbounds %struct.str_list, ptr %62, i32 0, i32 0
  %64 = load i32, ptr %63, align 8, !tbaa !14
  %65 = icmp slt i32 %60, %64
  br i1 %65, label %66, label %219

66:                                               ; preds = %59
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.nt_opts, ptr %68, i32 0, i32 33
  %70 = getelementptr inbounds %struct.str_list, ptr %69, i32 0, i32 1
  %71 = load ptr, ptr %70, align 8, !tbaa !18
  %72 = load i32, ptr %7, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds ptr, ptr %71, i64 %73
  %75 = load ptr, ptr %74, align 8, !tbaa !5
  %76 = call ptr @nt_image_read(ptr noundef %67, ptr noundef %75, i32 noundef 1)
  store ptr %76, ptr %4, align 8, !tbaa !5
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = icmp ne ptr %77, null
  br i1 %78, label %80, label %79

79:                                               ; preds = %66
  store i32 1, ptr %2, align 4
  store i32 1, ptr %10, align 4
  br label %234

80:                                               ; preds = %66
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %81

81:                                               ; preds = %137, %80
  %82 = load i32, ptr %8, align 4, !tbaa !9
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.nt_opts, ptr %83, i32 0, i32 29
  %85 = getelementptr inbounds %struct.str_list, ptr %84, i32 0, i32 0
  %86 = load i32, ptr %85, align 8, !tbaa !11
  %87 = icmp slt i32 %82, %86
  br i1 %87, label %88, label %140

88:                                               ; preds = %81
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.nt_opts, ptr %89, i32 0, i32 29
  %91 = getelementptr inbounds %struct.str_list, ptr %90, i32 0, i32 1
  %92 = load ptr, ptr %91, align 8, !tbaa !19
  %93 = load i32, ptr %8, align 4, !tbaa !9
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds ptr, ptr %92, i64 %94
  %96 = load ptr, ptr %95, align 8, !tbaa !5
  store ptr %96, ptr %5, align 8, !tbaa !5
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = call i64 @strlen(ptr noundef %97) #6
  %99 = trunc i64 %98 to i32
  store i32 %99, ptr %9, align 4, !tbaa !9
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = call i32 @strncmp(ptr noundef %100, ptr noundef @.str.228, i64 noundef 5) #6
  %102 = icmp ne i32 %101, 0
  br i1 %102, label %119, label %103

103:                                              ; preds = %88
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = getelementptr inbounds i8, ptr %104, i64 5
  %106 = call ptr @read_file_text(ptr noundef %105, ptr noundef %9)
  store ptr %106, ptr %6, align 8, !tbaa !5
  %107 = load ptr, ptr %6, align 8, !tbaa !5
  %108 = icmp ne ptr %107, null
  br i1 %108, label %109, label %112

109:                                              ; preds = %103
  %110 = load i32, ptr %9, align 4, !tbaa !9
  %111 = icmp sle i32 %110, 0
  br i1 %111, label %112, label %117

112:                                              ; preds = %109, %103
  %113 = load ptr, ptr @stderr, align 8, !tbaa !5
  %114 = load ptr, ptr %5, align 8, !tbaa !5
  %115 = getelementptr inbounds i8, ptr %114, i64 5
  %116 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %113, ptr noundef @.str.229, ptr noundef %115) #5
  br label %137

117:                                              ; preds = %109
  %118 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %118, ptr %5, align 8, !tbaa !5
  br label %119

119:                                              ; preds = %117, %88
  %120 = load ptr, ptr %4, align 8, !tbaa !5
  %121 = load ptr, ptr %5, align 8, !tbaa !5
  %122 = load i32, ptr %9, align 4, !tbaa !9
  %123 = load ptr, ptr %3, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.nt_opts, ptr %123, i32 0, i32 30
  %125 = getelementptr inbounds %struct.int_list, ptr %124, i32 0, i32 1
  %126 = load ptr, ptr %125, align 8, !tbaa !15
  %127 = load i32, ptr %8, align 4, !tbaa !9
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds i32, ptr %126, i64 %128
  %130 = load i32, ptr %129, align 4, !tbaa !9
  %131 = call i32 @nifti_add_extension(ptr noundef %120, ptr noundef %121, i32 noundef %122, i32 noundef %130)
  %132 = icmp ne i32 %131, 0
  br i1 %132, label %133, label %135

133:                                              ; preds = %119
  %134 = load ptr, ptr %4, align 8, !tbaa !5
  call void @nifti_image_free(ptr noundef %134)
  store i32 1, ptr %2, align 4
  store i32 1, ptr %10, align 4
  br label %234

135:                                              ; preds = %119
  %136 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %136) #5
  store ptr null, ptr %6, align 8, !tbaa !5
  br label %137

137:                                              ; preds = %135, %112
  %138 = load i32, ptr %8, align 4, !tbaa !9
  %139 = add nsw i32 %138, 1
  store i32 %139, ptr %8, align 4, !tbaa !9
  br label %81, !llvm.loop !20

140:                                              ; preds = %81
  %141 = load ptr, ptr %3, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.nt_opts, ptr %141, i32 0, i32 26
  %143 = load i32, ptr %142, align 8, !tbaa !22
  %144 = icmp ne i32 %143, 0
  br i1 %144, label %145, label %160

145:                                              ; preds = %140
  %146 = load ptr, ptr %4, align 8, !tbaa !5
  %147 = load ptr, ptr %3, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.nt_opts, ptr %147, i32 0, i32 34
  %149 = getelementptr inbounds [2048 x i8], ptr %148, i64 0, i64 0
  %150 = load ptr, ptr %3, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct.nt_opts, ptr %150, i32 0, i32 34
  %152 = getelementptr inbounds [2048 x i8], ptr %151, i64 0, i64 0
  %153 = call i64 @strlen(ptr noundef %152) #6
  %154 = trunc i64 %153 to i32
  %155 = call i32 @nifti_add_extension(ptr noundef %146, ptr noundef %149, i32 noundef %154, i32 noundef 6)
  %156 = icmp ne i32 %155, 0
  br i1 %156, label %157, label %160

157:                                              ; preds = %145
  %158 = load ptr, ptr @stderr, align 8, !tbaa !5
  %159 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %158, ptr noundef @.str.230) #5
  br label %160

160:                                              ; preds = %157, %145, %140
  %161 = load ptr, ptr %3, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.nt_opts, ptr %161, i32 0, i32 28
  %163 = load ptr, ptr %162, align 8, !tbaa !17
  %164 = icmp ne ptr %163, null
  br i1 %164, label %165, label %180

165:                                              ; preds = %160
  %166 = load ptr, ptr %4, align 8, !tbaa !5
  %167 = load ptr, ptr %3, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.nt_opts, ptr %167, i32 0, i32 28
  %169 = load ptr, ptr %168, align 8, !tbaa !17
  %170 = load ptr, ptr %3, align 8, !tbaa !5
  %171 = getelementptr inbounds %struct.nt_opts, ptr %170, i32 0, i32 27
  %172 = load i32, ptr %171, align 4, !tbaa !23
  %173 = icmp ne i32 %172, 0
  %174 = xor i1 %173, true
  %175 = zext i1 %174 to i32
  %176 = call i32 @nifti_set_filenames(ptr noundef %166, ptr noundef %169, i32 noundef %175, i32 noundef 1)
  %177 = icmp ne i32 %176, 0
  br i1 %177, label %178, label %180

178:                                              ; preds = %165
  %179 = load ptr, ptr %4, align 8, !tbaa !5
  call void @nifti_image_free(ptr noundef %179)
  store i32 1, ptr %2, align 4
  store i32 1, ptr %10, align 4
  br label %234

180:                                              ; preds = %165, %160
  %181 = load i32, ptr @g_debug, align 4, !tbaa !9
  %182 = icmp sgt i32 %181, 1
  br i1 %182, label %183, label %198

183:                                              ; preds = %180
  %184 = load ptr, ptr @stderr, align 8, !tbaa !5
  %185 = load ptr, ptr %3, align 8, !tbaa !5
  %186 = getelementptr inbounds %struct.nt_opts, ptr %185, i32 0, i32 33
  %187 = getelementptr inbounds %struct.str_list, ptr %186, i32 0, i32 1
  %188 = load ptr, ptr %187, align 8, !tbaa !18
  %189 = load i32, ptr %7, align 4, !tbaa !9
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds ptr, ptr %188, i64 %190
  %192 = load ptr, ptr %191, align 8, !tbaa !5
  %193 = load ptr, ptr %3, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.nt_opts, ptr %193, i32 0, i32 29
  %195 = getelementptr inbounds %struct.str_list, ptr %194, i32 0, i32 0
  %196 = load i32, ptr %195, align 8, !tbaa !11
  %197 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %184, ptr noundef @.str.231, ptr noundef %192, i32 noundef %196) #5
  br label %198

198:                                              ; preds = %183, %180
  %199 = load ptr, ptr %4, align 8, !tbaa !5
  %200 = call i32 @nifti_image_write_status(ptr noundef %199)
  %201 = icmp ne i32 %200, 0
  br i1 %201, label %202, label %214

202:                                              ; preds = %198
  %203 = load ptr, ptr @stderr, align 8, !tbaa !5
  %204 = load ptr, ptr %3, align 8, !tbaa !5
  %205 = getelementptr inbounds %struct.nt_opts, ptr %204, i32 0, i32 33
  %206 = getelementptr inbounds %struct.str_list, ptr %205, i32 0, i32 1
  %207 = load ptr, ptr %206, align 8, !tbaa !18
  %208 = load i32, ptr %7, align 4, !tbaa !9
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds ptr, ptr %207, i64 %209
  %211 = load ptr, ptr %210, align 8, !tbaa !5
  %212 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %203, ptr noundef @.str.232, ptr noundef %211) #5
  %213 = load ptr, ptr %4, align 8, !tbaa !5
  call void @nifti_image_free(ptr noundef %213)
  store i32 1, ptr %2, align 4
  store i32 1, ptr %10, align 4
  br label %234

214:                                              ; preds = %198
  %215 = load ptr, ptr %4, align 8, !tbaa !5
  call void @nifti_image_free(ptr noundef %215)
  br label %216

216:                                              ; preds = %214
  %217 = load i32, ptr %7, align 4, !tbaa !9
  %218 = add nsw i32 %217, 1
  store i32 %218, ptr %7, align 4, !tbaa !9
  br label %59, !llvm.loop !24

219:                                              ; preds = %59
  %220 = load i32, ptr @g_debug, align 4, !tbaa !9
  %221 = icmp sgt i32 %220, 0
  br i1 %221, label %222, label %233

222:                                              ; preds = %219
  %223 = load ptr, ptr @stderr, align 8, !tbaa !5
  %224 = load ptr, ptr %3, align 8, !tbaa !5
  %225 = getelementptr inbounds %struct.nt_opts, ptr %224, i32 0, i32 29
  %226 = getelementptr inbounds %struct.str_list, ptr %225, i32 0, i32 0
  %227 = load i32, ptr %226, align 8, !tbaa !11
  %228 = load ptr, ptr %3, align 8, !tbaa !5
  %229 = getelementptr inbounds %struct.nt_opts, ptr %228, i32 0, i32 33
  %230 = getelementptr inbounds %struct.str_list, ptr %229, i32 0, i32 0
  %231 = load i32, ptr %230, align 8, !tbaa !14
  %232 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %223, ptr noundef @.str.233, i32 noundef %227, i32 noundef %231) #5
  br label %233

233:                                              ; preds = %222, %219
  store i32 0, ptr %2, align 4
  store i32 1, ptr %10, align 4
  br label %234

234:                                              ; preds = %233, %202, %178, %133, %79, %57, %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  %235 = load i32, ptr %2, align 4
  ret i32 %235
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strncmp(ptr noundef, ptr noundef, i64 noundef) #2

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @disp_raw_data(ptr noundef, i32 noundef, i32 noundef, i8 noundef signext, i32 noundef) #1

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

; Function Attrs: nounwind uwtable
declare hidden ptr @read_file_text(ptr noundef, ptr noundef) #1

declare i32 @nifti_add_extension(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #4

declare void @nifti_image_free(ptr noundef) #4

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

declare i32 @nifti_set_filenames(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #4

declare i32 @nifti_image_write_status(ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #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 = { nounwind }
attributes #6 = { 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, !10, i64 176}
!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, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !7, i64 88, !7, i64 120, !10, i64 152, !10, i64 156, !10, i64 160, !10, i64 164, !6, i64 168, !13, i64 176, !13, i64 192, !13, i64 208, !13, i64 224, !13, i64 240, !7, i64 256}
!13 = !{!"", !10, i64 0, !6, i64 8}
!14 = !{!12, !10, i64 240}
!15 = !{!12, !6, i64 200}
!16 = !{!12, !10, i64 192}
!17 = !{!12, !6, i64 168}
!18 = !{!12, !6, i64 248}
!19 = !{!12, !6, i64 184}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!12, !10, i64 160}
!23 = !{!12, !10, i64 164}
!24 = distinct !{!24, !21}


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

@stderr = external local_unnamed_addr global ptr, align 8
@g_debug = external hidden local_unnamed_addr global i32, align 4
@.str.226 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.227 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.228 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.229 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.230 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.231 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.232 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.233 = external hidden unnamed_addr constant [38 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @act_add_exts(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %3 = load i32, ptr @g_debug, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 2
  br i1 %4, label %5, label %17

5:                                                ; preds = %1
  %6 = load ptr, ptr @stderr, align 8, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %0, i64 176
  %8 = load i32, ptr %7, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %0, i64 240
  %10 = load i32, ptr %9, align 8, !tbaa !14
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef nonnull @.str.226, i32 noundef %8, i32 noundef %10) #7
  %12 = getelementptr inbounds i8, ptr %0, i64 192
  %13 = getelementptr inbounds i8, ptr %0, i64 200
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %15 = load i32, ptr %12, align 8, !tbaa !16
  %16 = tail call i32 @disp_raw_data(ptr noundef %14, i32 noundef 8, i32 noundef %15, i8 noundef signext 32, i32 noundef 1)
  br label %17

17:                                               ; preds = %5, %1
  %18 = getelementptr inbounds i8, ptr %0, i64 168
  %19 = load ptr, ptr %18, align 8, !tbaa !17
  %.not = icmp eq ptr %19, null
  br i1 %.not, label %26, label %20

20:                                               ; preds = %17
  %21 = getelementptr inbounds i8, ptr %0, i64 240
  %22 = load i32, ptr %21, align 8, !tbaa !14
  %.not61 = icmp eq i32 %22, 1
  br i1 %.not61, label %26, label %23

23:                                               ; preds = %20
  %24 = load ptr, ptr @stderr, align 8, !tbaa !9
  %25 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef nonnull @.str.227, i32 noundef %22) #7
  br label %.loopexit

26:                                               ; preds = %20, %17
  %27 = getelementptr inbounds i8, ptr %0, i64 176
  %28 = load i32, ptr %27, align 8, !tbaa !11
  %29 = icmp slt i32 %28, 1
  br i1 %29, label %.loopexit, label %.preheader71

.preheader71:                                     ; preds = %26
  %30 = getelementptr inbounds i8, ptr %0, i64 240
  %31 = load i32, ptr %30, align 8, !tbaa !14
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %.lr.ph93, label %._crit_edge94

.lr.ph93:                                         ; preds = %.preheader71
  %33 = getelementptr inbounds i8, ptr %0, i64 248
  %34 = getelementptr inbounds i8, ptr %0, i64 184
  %35 = getelementptr inbounds i8, ptr %0, i64 200
  %36 = getelementptr inbounds i8, ptr %0, i64 160
  %37 = getelementptr inbounds i8, ptr %0, i64 256
  %38 = getelementptr inbounds i8, ptr %0, i64 164
  br label %39

39:                                               ; preds = %.lr.ph93, %106
  %indvars.iv108 = phi i64 [ 0, %.lr.ph93 ], [ %indvars.iv.next109, %106 ]
  %.05391 = phi ptr [ null, %.lr.ph93 ], [ %.1.lcssa, %106 ]
  %40 = load ptr, ptr %33, align 8, !tbaa !18
  %41 = getelementptr inbounds ptr, ptr %40, i64 %indvars.iv108
  %42 = load ptr, ptr %41, align 8, !tbaa !9
  %43 = call ptr @nt_image_read(ptr noundef nonnull %0, ptr noundef %42, i32 noundef 1)
  %.not62 = icmp eq ptr %43, null
  br i1 %.not62, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %39
  %44 = load i32, ptr %27, align 8, !tbaa !11
  %45 = icmp sgt i32 %44, 0
  br i1 %45, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader, %69
  %indvars.iv = phi i64 [ %indvars.iv.next, %69 ], [ 0, %.preheader ]
  %.189 = phi ptr [ %.3, %69 ], [ %.05391, %.preheader ]
  %46 = load ptr, ptr %34, align 8, !tbaa !19
  %47 = getelementptr inbounds ptr, ptr %46, i64 %indvars.iv
  %48 = load ptr, ptr %47, align 8, !tbaa !9
  %49 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %48) #8
  %50 = trunc i64 %49 to i32
  store i32 %50, ptr %2, align 4, !tbaa !5
  %51 = call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %48, ptr noundef nonnull dereferenceable(1) @.str.228, i64 noundef 5) #8
  %.not69 = icmp eq i32 %51, 0
  br i1 %.not69, label %52, label %61

52:                                               ; preds = %.lr.ph
  %53 = getelementptr inbounds i8, ptr %48, i64 5
  %54 = call ptr @read_file_text(ptr noundef nonnull %53, ptr noundef nonnull %2)
  %55 = icmp eq ptr %54, null
  %56 = load i32, ptr %2, align 4
  %57 = icmp slt i32 %56, 1
  %or.cond = select i1 %55, i1 true, i1 %57
  br i1 %or.cond, label %58, label %61

58:                                               ; preds = %52
  %59 = load ptr, ptr @stderr, align 8, !tbaa !9
  %60 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %59, ptr noundef nonnull @.str.229, ptr noundef nonnull %53) #7
  br label %69

61:                                               ; preds = %52, %.lr.ph
  %62 = phi i32 [ %50, %.lr.ph ], [ %56, %52 ]
  %.054 = phi ptr [ %48, %.lr.ph ], [ %54, %52 ]
  %.2 = phi ptr [ %.189, %.lr.ph ], [ %54, %52 ]
  %63 = load ptr, ptr %35, align 8, !tbaa !15
  %64 = getelementptr inbounds i32, ptr %63, i64 %indvars.iv
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = call i32 @nifti_add_extension(ptr noundef nonnull %43, ptr noundef %.054, i32 noundef %62, i32 noundef %65) #6
  %.not70 = icmp eq i32 %66, 0
  br i1 %.not70, label %68, label %67

67:                                               ; preds = %61
  call void @nifti_image_free(ptr noundef nonnull %43) #6
  br label %.loopexit

68:                                               ; preds = %61
  call void @free(ptr noundef %.2) #6
  br label %69

69:                                               ; preds = %68, %58
  %.3 = phi ptr [ null, %68 ], [ %54, %58 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %70 = load i32, ptr %27, align 8, !tbaa !11
  %71 = sext i32 %70 to i64
  %72 = icmp slt i64 %indvars.iv.next, %71
  br i1 %72, label %.lr.ph, label %._crit_edge, !llvm.loop !20

._crit_edge:                                      ; preds = %69, %.preheader
  %.1.lcssa = phi ptr [ %.05391, %.preheader ], [ %.3, %69 ]
  %73 = load i32, ptr %36, align 8, !tbaa !22
  %.not63 = icmp eq i32 %73, 0
  br i1 %.not63, label %81, label %74

74:                                               ; preds = %._crit_edge
  %75 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %37) #8
  %76 = trunc i64 %75 to i32
  %77 = call i32 @nifti_add_extension(ptr noundef nonnull %43, ptr noundef nonnull %37, i32 noundef %76, i32 noundef 6) #6
  %.not64 = icmp eq i32 %77, 0
  br i1 %.not64, label %81, label %78

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

81:                                               ; preds = %78, %74, %._crit_edge
  %82 = load ptr, ptr %18, align 8, !tbaa !17
  %.not65 = icmp eq ptr %82, null
  br i1 %.not65, label %88, label %83

83:                                               ; preds = %81
  %84 = load i32, ptr %38, align 4, !tbaa !23
  %.not66 = icmp eq i32 %84, 0
  %85 = zext i1 %.not66 to i32
  %86 = call i32 @nifti_set_filenames(ptr noundef nonnull %43, ptr noundef nonnull %82, i32 noundef %85, i32 noundef 1) #6
  %.not67 = icmp eq i32 %86, 0
  br i1 %.not67, label %88, label %87

87:                                               ; preds = %83
  call void @nifti_image_free(ptr noundef nonnull %43) #6
  br label %.loopexit

88:                                               ; preds = %83, %81
  %89 = load i32, ptr @g_debug, align 4, !tbaa !5
  %90 = icmp sgt i32 %89, 1
  br i1 %90, label %91, label %98

91:                                               ; preds = %88
  %92 = load ptr, ptr @stderr, align 8, !tbaa !9
  %93 = load ptr, ptr %33, align 8, !tbaa !18
  %94 = getelementptr inbounds ptr, ptr %93, i64 %indvars.iv108
  %95 = load ptr, ptr %94, align 8, !tbaa !9
  %96 = load i32, ptr %27, align 8, !tbaa !11
  %97 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %92, ptr noundef nonnull @.str.231, ptr noundef %95, i32 noundef %96) #7
  br label %98

98:                                               ; preds = %91, %88
  %99 = call i32 @nifti_image_write_status(ptr noundef nonnull %43) #6
  %.not68 = icmp eq i32 %99, 0
  br i1 %.not68, label %106, label %100

100:                                              ; preds = %98
  %101 = load ptr, ptr @stderr, align 8, !tbaa !9
  %102 = load ptr, ptr %33, align 8, !tbaa !18
  %103 = getelementptr inbounds ptr, ptr %102, i64 %indvars.iv108
  %104 = load ptr, ptr %103, align 8, !tbaa !9
  %105 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %101, ptr noundef nonnull @.str.232, ptr noundef %104) #7
  call void @nifti_image_free(ptr noundef nonnull %43) #6
  br label %.loopexit

106:                                              ; preds = %98
  call void @nifti_image_free(ptr noundef nonnull %43) #6
  %indvars.iv.next109 = add nuw nsw i64 %indvars.iv108, 1
  %107 = load i32, ptr %30, align 8, !tbaa !14
  %108 = sext i32 %107 to i64
  %109 = icmp slt i64 %indvars.iv.next109, %108
  br i1 %109, label %39, label %._crit_edge94, !llvm.loop !24

._crit_edge94:                                    ; preds = %106, %.preheader71
  %.lcssa = phi i32 [ %31, %.preheader71 ], [ %107, %106 ]
  %110 = load i32, ptr @g_debug, align 4, !tbaa !5
  %111 = icmp sgt i32 %110, 0
  br i1 %111, label %112, label %.loopexit

112:                                              ; preds = %._crit_edge94
  %113 = load ptr, ptr @stderr, align 8, !tbaa !9
  %114 = load i32, ptr %27, align 8, !tbaa !11
  %115 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %113, ptr noundef nonnull @.str.233, i32 noundef %114, i32 noundef %.lcssa) #7
  br label %.loopexit

.loopexit:                                        ; preds = %39, %._crit_edge94, %112, %26, %100, %87, %67, %23
  %.055 = phi i32 [ 1, %23 ], [ 1, %67 ], [ 1, %87 ], [ 1, %100 ], [ 0, %26 ], [ 0, %112 ], [ 0, %._crit_edge94 ], [ 1, %39 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  ret i32 %.055
}

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @disp_raw_data(ptr noundef, i32 noundef, i32 noundef, i8 noundef signext, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare hidden ptr @read_file_text(ptr noundef, ptr noundef) local_unnamed_addr #1

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

declare void @nifti_image_free(ptr noundef) local_unnamed_addr #4

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

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

declare i32 @nifti_image_write_status(ptr noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #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 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 #6 = { nounwind }
attributes #7 = { cold nounwind }
attributes #8 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 176}
!12 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48, !6, i64 52, !6, i64 56, !6, i64 60, !6, i64 64, !6, i64 68, !6, i64 72, !6, i64 76, !6, i64 80, !6, i64 84, !7, i64 88, !7, i64 120, !6, i64 152, !6, i64 156, !6, i64 160, !6, i64 164, !10, i64 168, !13, i64 176, !13, i64 192, !13, i64 208, !13, i64 224, !13, i64 240, !7, i64 256}
!13 = !{!"", !6, i64 0, !10, i64 8}
!14 = !{!12, !6, i64 240}
!15 = !{!12, !10, i64 200}
!16 = !{!12, !6, i64 192}
!17 = !{!12, !10, i64 168}
!18 = !{!12, !10, i64 248}
!19 = !{!12, !10, i64 184}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!12, !6, i64 160}
!23 = !{!12, !6, i64 164}
!24 = distinct !{!24, !21}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass