; 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.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]] }
%struct.nifti1_extension = type { i32, i32, ptr }

@stderr = external global ptr, align 8
@g_debug = external hidden global i32, align 4
@.str.244 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.245 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.246 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.247 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.248 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.249 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.250 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.251 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.252 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.253 = external hidden unnamed_addr constant [35 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: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #2

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

declare i32 @nifti_free_extensions(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @remove_ext_list(ptr noundef %0, ptr noundef %1, i32 noundef %2) #4 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %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
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.nifti_image, ptr %14, i32 0, i32 61
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = icmp sgt i32 %13, %16
  br i1 %17, label %18, label %28

18:                                               ; preds = %3
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.nifti_image, ptr %21, i32 0, i32 55
  %23 = load ptr, ptr %22, align 8, !tbaa !16
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.nifti_image, ptr %24, i32 0, i32 61
  %26 = load i32, ptr %25, align 8, !tbaa !11
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str.244, i32 noundef %20, ptr noundef %23, i32 noundef %26) #7
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %233

28:                                               ; preds = %3
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = icmp sle i32 %29, 0
  br i1 %30, label %31, label %35

31:                                               ; preds = %28
  %32 = load ptr, ptr @stderr, align 8, !tbaa !5
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef @.str.245, i32 noundef %33) #7
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %233

35:                                               ; preds = %28
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds ptr, ptr %36, i64 0
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = call i32 @atoi(ptr noundef %38) #8
  store i32 %39, ptr %11, align 4, !tbaa !9
  %40 = load i32, ptr %11, align 4, !tbaa !9
  %41 = icmp eq i32 %40, -1
  br i1 %41, label %42, label %57

42:                                               ; preds = %35
  %43 = load i32, ptr @g_debug, align 4, !tbaa !9
  %44 = icmp sgt i32 %43, 1
  br i1 %44, label %45, label %54

45:                                               ; preds = %42
  %46 = load ptr, ptr @stderr, align 8, !tbaa !5
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.nifti_image, ptr %47, i32 0, i32 61
  %49 = load i32, ptr %48, align 8, !tbaa !11
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.nifti_image, ptr %50, i32 0, i32 55
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef @.str.246, i32 noundef %49, ptr noundef %52) #7
  br label %54

54:                                               ; preds = %45, %42
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = call i32 @nifti_free_extensions(ptr noundef %55)
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %233

57:                                               ; preds = %35
  %58 = load i32, ptr @g_debug, align 4, !tbaa !9
  %59 = icmp sgt i32 %58, 2
  br i1 %59, label %60, label %67

60:                                               ; preds = %57
  %61 = load ptr, ptr @stderr, align 8, !tbaa !5
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.nifti_image, ptr %63, i32 0, i32 55
  %65 = load ptr, ptr %64, align 8, !tbaa !16
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %61, ptr noundef @.str.247, i32 noundef %62, ptr noundef %65) #7
  br label %67

67:                                               ; preds = %60, %57
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.nifti_image, ptr %68, i32 0, i32 61
  %70 = load i32, ptr %69, align 8, !tbaa !11
  %71 = sext i32 %70 to i64
  %72 = call noalias ptr @calloc(i64 noundef %71, i64 noundef 4) #9
  store ptr %72, ptr %8, align 8, !tbaa !5
  %73 = icmp ne ptr %72, null
  br i1 %73, label %80, label %74

74:                                               ; preds = %67
  %75 = load ptr, ptr @stderr, align 8, !tbaa !5
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.nifti_image, ptr %76, i32 0, i32 61
  %78 = load i32, ptr %77, align 8, !tbaa !11
  %79 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %75, ptr noundef @.str.248, i32 noundef %78) #7
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %233

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

81:                                               ; preds = %133, %80
  %82 = load i32, ptr %10, align 4, !tbaa !9
  %83 = load i32, ptr %7, align 4, !tbaa !9
  %84 = icmp slt i32 %82, %83
  br i1 %84, label %85, label %136

85:                                               ; preds = %81
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = load i32, ptr %10, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds ptr, ptr %86, i64 %88
  %90 = load ptr, ptr %89, align 8, !tbaa !5
  %91 = call i32 @atoi(ptr noundef %90) #8
  store i32 %91, ptr %11, align 4, !tbaa !9
  %92 = load i32, ptr %11, align 4, !tbaa !9
  %93 = icmp slt i32 %92, 0
  br i1 %93, label %100, label %94

94:                                               ; preds = %85
  %95 = load i32, ptr %11, align 4, !tbaa !9
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.nifti_image, ptr %96, i32 0, i32 61
  %98 = load i32, ptr %97, align 8, !tbaa !11
  %99 = icmp sge i32 %95, %98
  br i1 %99, label %100, label %113

100:                                              ; preds = %94, %85
  %101 = load ptr, ptr @stderr, align 8, !tbaa !5
  %102 = load i32, ptr %10, align 4, !tbaa !9
  %103 = load i32, ptr %11, align 4, !tbaa !9
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.nifti_image, ptr %104, i32 0, i32 61
  %106 = load i32, ptr %105, align 8, !tbaa !11
  %107 = sub nsw i32 %106, 1
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.nifti_image, ptr %108, i32 0, i32 55
  %110 = load ptr, ptr %109, align 8, !tbaa !16
  %111 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %101, ptr noundef @.str.249, i32 noundef %102, i32 noundef %103, i32 noundef %107, ptr noundef %110) #7
  %112 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %112) #7
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %233

113:                                              ; preds = %94
  %114 = load ptr, ptr %8, align 8, !tbaa !5
  %115 = load i32, ptr %11, align 4, !tbaa !9
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds i32, ptr %114, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !9
  %119 = icmp ne i32 %118, 0
  br i1 %119, label %120, label %126

120:                                              ; preds = %113
  %121 = load ptr, ptr @stderr, align 8, !tbaa !5
  %122 = load i32, ptr %10, align 4, !tbaa !9
  %123 = load i32, ptr %11, align 4, !tbaa !9
  %124 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %121, ptr noundef @.str.250, i32 noundef %122, i32 noundef %123) #7
  %125 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %125) #7
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %233

126:                                              ; preds = %113
  %127 = load ptr, ptr %8, align 8, !tbaa !5
  %128 = load i32, ptr %11, align 4, !tbaa !9
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds i32, ptr %127, i64 %129
  %131 = load i32, ptr %130, align 4, !tbaa !9
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %130, align 4, !tbaa !9
  br label %133

133:                                              ; preds = %126
  %134 = load i32, ptr %10, align 4, !tbaa !9
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %10, align 4, !tbaa !9
  br label %81, !llvm.loop !17

136:                                              ; preds = %81
  %137 = load ptr, ptr %5, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.nifti_image, ptr %137, i32 0, i32 61
  %139 = load i32, ptr %138, align 8, !tbaa !11
  %140 = sub nsw i32 %139, 1
  store i32 %140, ptr %10, align 4, !tbaa !9
  br label %141

141:                                              ; preds = %202, %136
  %142 = load i32, ptr %10, align 4, !tbaa !9
  %143 = icmp sge i32 %142, 0
  br i1 %143, label %144, label %205

144:                                              ; preds = %141
  %145 = load ptr, ptr %8, align 8, !tbaa !5
  %146 = load i32, ptr %10, align 4, !tbaa !9
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds i32, ptr %145, i64 %147
  %149 = load i32, ptr %148, align 4, !tbaa !9
  %150 = icmp ne i32 %149, 0
  br i1 %150, label %152, label %151

151:                                              ; preds = %144
  br label %202

152:                                              ; preds = %144
  %153 = load i32, ptr @g_debug, align 4, !tbaa !9
  %154 = icmp sgt i32 %153, 2
  br i1 %154, label %155, label %163

155:                                              ; preds = %152
  %156 = load ptr, ptr %5, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.nifti_image, ptr %156, i32 0, i32 62
  %158 = load ptr, ptr %157, align 8, !tbaa !19
  %159 = load i32, ptr %10, align 4, !tbaa !9
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds %struct.nifti1_extension, ptr %158, i64 %160
  %162 = call i32 @disp_nifti1_extension(ptr noundef @.str.251, ptr noundef %161, i32 noundef -1)
  br label %163

163:                                              ; preds = %155, %152
  %164 = load ptr, ptr %5, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.nifti_image, ptr %164, i32 0, i32 62
  %166 = load ptr, ptr %165, align 8, !tbaa !19
  %167 = load i32, ptr %10, align 4, !tbaa !9
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds %struct.nifti1_extension, ptr %166, i64 %168
  %170 = getelementptr inbounds %struct.nifti1_extension, ptr %169, i32 0, i32 2
  %171 = load ptr, ptr %170, align 8, !tbaa !20
  call void @free(ptr noundef %171) #7
  %172 = load i32, ptr %10, align 4, !tbaa !9
  %173 = add nsw i32 %172, 1
  store i32 %173, ptr %9, align 4, !tbaa !9
  br label %174

174:                                              ; preds = %194, %163
  %175 = load i32, ptr %9, align 4, !tbaa !9
  %176 = load ptr, ptr %5, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.nifti_image, ptr %176, i32 0, i32 61
  %178 = load i32, ptr %177, align 8, !tbaa !11
  %179 = icmp slt i32 %175, %178
  br i1 %179, label %180, label %197

180:                                              ; preds = %174
  %181 = load ptr, ptr %5, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.nifti_image, ptr %181, i32 0, i32 62
  %183 = load ptr, ptr %182, align 8, !tbaa !19
  %184 = load i32, ptr %9, align 4, !tbaa !9
  %185 = sub nsw i32 %184, 1
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds %struct.nifti1_extension, ptr %183, i64 %186
  %188 = load ptr, ptr %5, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.nifti_image, ptr %188, i32 0, i32 62
  %190 = load ptr, ptr %189, align 8, !tbaa !19
  %191 = load i32, ptr %9, align 4, !tbaa !9
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds %struct.nifti1_extension, ptr %190, i64 %192
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %187, ptr align 8 %193, i64 16, i1 false), !tbaa.struct !22
  br label %194

194:                                              ; preds = %180
  %195 = load i32, ptr %9, align 4, !tbaa !9
  %196 = add nsw i32 %195, 1
  store i32 %196, ptr %9, align 4, !tbaa !9
  br label %174, !llvm.loop !23

197:                                              ; preds = %174
  %198 = load ptr, ptr %5, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.nifti_image, ptr %198, i32 0, i32 61
  %200 = load i32, ptr %199, align 8, !tbaa !11
  %201 = add nsw i32 %200, -1
  store i32 %201, ptr %199, align 8, !tbaa !11
  br label %202

202:                                              ; preds = %197, %151
  %203 = load i32, ptr %10, align 4, !tbaa !9
  %204 = add nsw i32 %203, -1
  store i32 %204, ptr %10, align 4, !tbaa !9
  br label %141, !llvm.loop !24

205:                                              ; preds = %141
  %206 = load i32, ptr @g_debug, align 4, !tbaa !9
  %207 = icmp sgt i32 %206, 3
  br i1 %207, label %208, label %211

208:                                              ; preds = %205
  %209 = load ptr, ptr @stderr, align 8, !tbaa !5
  %210 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %209, ptr noundef @.str.252) #7
  br label %211

211:                                              ; preds = %208, %205
  %212 = load ptr, ptr %5, align 8, !tbaa !5
  %213 = getelementptr inbounds %struct.nifti_image, ptr %212, i32 0, i32 61
  %214 = load i32, ptr %213, align 8, !tbaa !11
  %215 = icmp eq i32 %214, 0
  br i1 %215, label %216, label %231

216:                                              ; preds = %211
  %217 = load i32, ptr @g_debug, align 4, !tbaa !9
  %218 = icmp sgt i32 %217, 1
  br i1 %218, label %219, label %225

219:                                              ; preds = %216
  %220 = load ptr, ptr @stderr, align 8, !tbaa !5
  %221 = load ptr, ptr %5, align 8, !tbaa !5
  %222 = getelementptr inbounds %struct.nifti_image, ptr %221, i32 0, i32 55
  %223 = load ptr, ptr %222, align 8, !tbaa !16
  %224 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %220, ptr noundef @.str.253, ptr noundef %223) #7
  br label %225

225:                                              ; preds = %219, %216
  %226 = load ptr, ptr %5, align 8, !tbaa !5
  %227 = getelementptr inbounds %struct.nifti_image, ptr %226, i32 0, i32 62
  %228 = load ptr, ptr %227, align 8, !tbaa !19
  call void @free(ptr noundef %228) #7
  %229 = load ptr, ptr %5, align 8, !tbaa !5
  %230 = getelementptr inbounds %struct.nifti_image, ptr %229, i32 0, i32 62
  store ptr null, ptr %230, align 8, !tbaa !19
  br label %231

231:                                              ; preds = %225, %211
  %232 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %232) #7
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %233

233:                                              ; preds = %231, %120, %100, %74, %54, %31, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  %234 = load i32, ptr %4, align 4
  ret i32 %234
}

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

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

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

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 = { inlinehint nounwind willreturn memory(read) 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 = { 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 allocsize(0,1) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { nounwind allocsize(0,1) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 672}
!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 632}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!12, !6, i64 680}
!20 = !{!21, !6, i64 8}
!21 = !{!"nifti1_extension", !10, i64 0, !10, i64 4, !6, i64 8}
!22 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 8, !5}
!23 = distinct !{!23, !18}
!24 = distinct !{!24, !18}


; 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.nifti1_extension = type { i32, i32, ptr }

@stderr = external local_unnamed_addr global ptr, align 8
@g_debug = external hidden local_unnamed_addr global i32, align 4
@.str.244 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.245 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.246 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.247 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.248 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.249 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.250 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.251 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.252 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.253 = external hidden unnamed_addr constant [35 x i8], align 1

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

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) 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 @nifti_free_extensions(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @remove_ext_list(ptr noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #4 {
  %4 = getelementptr inbounds i8, ptr %0, i64 672
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = icmp slt i32 %5, %2
  br i1 %6, label %7, label %12

7:                                                ; preds = %3
  %8 = load ptr, ptr @stderr, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %0, i64 632
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %8, ptr noundef nonnull @.str.244, i32 noundef %2, ptr noundef %10, i32 noundef %5) #7
  br label %117

12:                                               ; preds = %3
  %13 = icmp slt i32 %2, 1
  br i1 %13, label %14, label %17

14:                                               ; preds = %12
  %15 = load ptr, ptr @stderr, align 8, !tbaa !14
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.245, i32 noundef %2) #7
  br label %117

17:                                               ; preds = %12
  %18 = load ptr, ptr %1, align 8, !tbaa !14
  %19 = tail call i32 @atoi(ptr nocapture noundef %18) #8
  %20 = icmp eq i32 %19, -1
  %21 = load i32, ptr @g_debug, align 4, !tbaa !16
  br i1 %20, label %22, label %31

22:                                               ; preds = %17
  %23 = icmp sgt i32 %21, 1
  br i1 %23, label %24, label %29

24:                                               ; preds = %22
  %25 = load ptr, ptr @stderr, align 8, !tbaa !14
  %26 = getelementptr inbounds i8, ptr %0, i64 632
  %27 = load ptr, ptr %26, align 8, !tbaa !15
  %28 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str.246, i32 noundef %5, ptr noundef %27) #7
  br label %29

29:                                               ; preds = %24, %22
  %30 = tail call i32 @nifti_free_extensions(ptr noundef nonnull %0) #9
  br label %117

31:                                               ; preds = %17
  %32 = icmp sgt i32 %21, 2
  br i1 %32, label %33, label %38

33:                                               ; preds = %31
  %34 = load ptr, ptr @stderr, align 8, !tbaa !14
  %35 = getelementptr inbounds i8, ptr %0, i64 632
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef nonnull @.str.247, i32 noundef %2, ptr noundef %36) #7
  %.pre = load i32, ptr %4, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %33, %31
  %39 = phi i32 [ %.pre, %33 ], [ %5, %31 ]
  %40 = sext i32 %39 to i64
  %41 = tail call noalias ptr @calloc(i64 noundef %40, i64 noundef 4) #10
  %.not = icmp eq ptr %41, null
  br i1 %.not, label %42, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %38
  %wide.trip.count = zext nneg i32 %2 to i64
  br label %.lr.ph

42:                                               ; preds = %38
  %43 = load ptr, ptr @stderr, align 8, !tbaa !14
  %44 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef nonnull @.str.248, i32 noundef %39) #7
  br label %117

.preheader:                                       ; preds = %67
  %45 = icmp sgt i32 %39, 0
  br i1 %45, label %.lr.ph83, label %._crit_edge84

.lr.ph83:                                         ; preds = %.preheader
  %46 = getelementptr inbounds i8, ptr %0, i64 680
  %47 = zext nneg i32 %39 to i64
  br label %68

.lr.ph:                                           ; preds = %.lr.ph.preheader, %67
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %67 ]
  %48 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv
  %49 = load ptr, ptr %48, align 8, !tbaa !14
  %50 = tail call i32 @atoi(ptr nocapture noundef %49) #8
  %51 = icmp sgt i32 %50, -1
  %.not70 = icmp slt i32 %50, %39
  %or.cond = and i1 %51, %.not70
  br i1 %or.cond, label %59, label %52

52:                                               ; preds = %.lr.ph
  %53 = trunc nuw nsw i64 %indvars.iv to i32
  %54 = load ptr, ptr @stderr, align 8, !tbaa !14
  %55 = add nsw i32 %39, -1
  %56 = getelementptr inbounds i8, ptr %0, i64 632
  %57 = load ptr, ptr %56, align 8, !tbaa !15
  %58 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %54, ptr noundef nonnull @.str.249, i32 noundef %53, i32 noundef %50, i32 noundef %55, ptr noundef %57) #7
  tail call void @free(ptr noundef nonnull %41) #9
  br label %117

59:                                               ; preds = %.lr.ph
  %60 = zext nneg i32 %50 to i64
  %61 = getelementptr inbounds i32, ptr %41, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !16
  %.not71 = icmp eq i32 %62, 0
  br i1 %.not71, label %67, label %63

63:                                               ; preds = %59
  %64 = trunc nuw nsw i64 %indvars.iv to i32
  %65 = load ptr, ptr @stderr, align 8, !tbaa !14
  %66 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef nonnull @.str.250, i32 noundef %64, i32 noundef %50) #7
  tail call void @free(ptr noundef nonnull %41) #9
  br label %117

67:                                               ; preds = %59
  store i32 1, ptr %61, align 4, !tbaa !16
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader, label %.lr.ph, !llvm.loop !17

68:                                               ; preds = %.lr.ph83, %93
  %69 = phi i32 [ %39, %.lr.ph83 ], [ %94, %93 ]
  %indvars.iv92 = phi i64 [ %47, %.lr.ph83 ], [ %indvars.iv.next93, %93 ]
  %indvars.iv.next93 = add nsw i64 %indvars.iv92, -1
  %70 = getelementptr inbounds i32, ptr %41, i64 %indvars.iv.next93
  %71 = load i32, ptr %70, align 4, !tbaa !16
  %.not69 = icmp eq i32 %71, 0
  br i1 %.not69, label %93, label %72

72:                                               ; preds = %68
  %73 = load i32, ptr @g_debug, align 4, !tbaa !16
  %74 = icmp sgt i32 %73, 2
  br i1 %74, label %75, label %79

75:                                               ; preds = %72
  %76 = load ptr, ptr %46, align 8, !tbaa !19
  %77 = getelementptr inbounds %struct.nifti1_extension, ptr %76, i64 %indvars.iv.next93
  %78 = tail call i32 @disp_nifti1_extension(ptr noundef nonnull @.str.251, ptr noundef %77, i32 noundef -1)
  br label %79

79:                                               ; preds = %75, %72
  %80 = load ptr, ptr %46, align 8, !tbaa !19
  %81 = getelementptr inbounds %struct.nifti1_extension, ptr %80, i64 %indvars.iv.next93, i32 2
  %82 = load ptr, ptr %81, align 8, !tbaa !20
  tail call void @free(ptr noundef %82) #9
  %83 = load i32, ptr %4, align 8, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = icmp slt i64 %indvars.iv92, %84
  br i1 %85, label %.lr.ph79, label %._crit_edge

.lr.ph79:                                         ; preds = %79, %.lr.ph79
  %indvars.iv94 = phi i64 [ %indvars.iv.next95, %.lr.ph79 ], [ %indvars.iv92, %79 ]
  %86 = load ptr, ptr %46, align 8, !tbaa !19
  %87 = getelementptr %struct.nifti1_extension, ptr %86, i64 %indvars.iv94
  %88 = getelementptr i8, ptr %87, i64 -16
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %88, ptr noundef nonnull align 8 dereferenceable(16) %87, i64 16, i1 false), !tbaa.struct !22
  %indvars.iv.next95 = add nuw nsw i64 %indvars.iv94, 1
  %89 = load i32, ptr %4, align 8, !tbaa !5
  %90 = trunc nuw i64 %indvars.iv.next95 to i32
  %91 = icmp sgt i32 %89, %90
  br i1 %91, label %.lr.ph79, label %._crit_edge, !llvm.loop !23

._crit_edge:                                      ; preds = %.lr.ph79, %79
  %.lcssa = phi i32 [ %83, %79 ], [ %89, %.lr.ph79 ]
  %92 = add nsw i32 %.lcssa, -1
  store i32 %92, ptr %4, align 8, !tbaa !5
  br label %93

93:                                               ; preds = %68, %._crit_edge
  %94 = phi i32 [ %69, %68 ], [ %92, %._crit_edge ]
  %95 = icmp sgt i64 %indvars.iv92, 1
  br i1 %95, label %68, label %._crit_edge84, !llvm.loop !24

._crit_edge84:                                    ; preds = %93, %.preheader
  %96 = phi i32 [ %39, %.preheader ], [ %94, %93 ]
  %97 = load i32, ptr @g_debug, align 4, !tbaa !16
  %98 = icmp sgt i32 %97, 3
  br i1 %98, label %99, label %102

99:                                               ; preds = %._crit_edge84
  %100 = load ptr, ptr @stderr, align 8, !tbaa !14
  %101 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %100, ptr noundef nonnull @.str.252) #7
  %.pre98 = load i32, ptr %4, align 8, !tbaa !5
  br label %102

102:                                              ; preds = %99, %._crit_edge84
  %103 = phi i32 [ %.pre98, %99 ], [ %96, %._crit_edge84 ]
  %104 = icmp eq i32 %103, 0
  br i1 %104, label %105, label %116

105:                                              ; preds = %102
  %106 = load i32, ptr @g_debug, align 4, !tbaa !16
  %107 = icmp sgt i32 %106, 1
  br i1 %107, label %108, label %113

108:                                              ; preds = %105
  %109 = load ptr, ptr @stderr, align 8, !tbaa !14
  %110 = getelementptr inbounds i8, ptr %0, i64 632
  %111 = load ptr, ptr %110, align 8, !tbaa !15
  %112 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %109, ptr noundef nonnull @.str.253, ptr noundef %111) #7
  br label %113

113:                                              ; preds = %108, %105
  %114 = getelementptr inbounds i8, ptr %0, i64 680
  %115 = load ptr, ptr %114, align 8, !tbaa !19
  tail call void @free(ptr noundef %115) #9
  store ptr null, ptr %114, align 8, !tbaa !19
  br label %116

116:                                              ; preds = %113, %102
  tail call void @free(ptr noundef %41) #9
  br label %117

117:                                              ; preds = %116, %63, %52, %42, %29, %14, %7
  %.060 = phi i32 [ -1, %7 ], [ -1, %14 ], [ 0, %29 ], [ -1, %52 ], [ -1, %63 ], [ 0, %116 ], [ -1, %42 ]
  ret i32 %.060
}

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @disp_nifti1_extension(ptr noundef, ptr noundef, i32 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) #6

attributes #0 = { 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 #1 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 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 = { 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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { cold nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { nounwind }
attributes #10 = { nounwind allocsize(0,1) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 672}
!6 = !{!"", !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, !10, i64 64, !7, i64 72, !7, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !8, i64 108, !11, i64 140, !11, i64 144, !11, i64 148, !11, 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, !11, i64 188, !11, i64 192, !11, i64 196, !11, i64 200, !11, i64 204, !11, i64 208, !11, i64 212, !11, i64 216, !12, i64 220, !12, i64 284, !12, i64 348, !12, i64 412, !11, i64 476, !7, i64 480, !7, i64 484, !7, i64 488, !7, i64 492, !11, i64 496, !11, i64 500, !11, i64 504, !8, i64 508, !8, i64 524, !8, i64 604, !13, i64 632, !13, i64 640, !7, i64 648, !7, i64 652, !7, i64 656, !13, i64 664, !7, i64 672, !13, i64 680, !7, i64 688}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!"", !8, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!6, !13, i64 632}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!6, !13, i64 680}
!20 = !{!21, !13, i64 8}
!21 = !{!"nifti1_extension", !7, i64 0, !7, i64 4, !13, i64 8}
!22 = !{i64 0, i64 4, !16, i64 4, i64 4, !16, i64 8, i64 8, !14}
!23 = distinct !{!23, !18}
!24 = distinct !{!24, !18}


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