; 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.field_s = type { i32, i32, i32, i32, [20 x i8] }
%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 }
%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]] }

@g_nim_fields = external hidden global [63 x %struct.field_s], align 16
@stderr = external global ptr, align 8
@g_debug = external hidden global i32, align 4
@.str.230 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.232 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.287 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.288 = external hidden unnamed_addr constant [36 x i8], align 1
@__const.act_mod_nims.func = external hidden unnamed_addr constant [13 x i8], align 1
@.str.297 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.298 = external hidden unnamed_addr constant [40 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_mod_nims(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca [13 x i8], align 1
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 13, ptr %6) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %6, ptr align 1 @__const.act_mod_nims.func, i64 13, i1 false)
  %8 = load i32, ptr @g_debug, align 4, !tbaa !9
  %9 = icmp sgt i32 %8, 2
  br i1 %9, label %10, label %21

10:                                               ; preds = %1
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.nt_opts, ptr %12, i32 0, i32 31
  %14 = getelementptr inbounds %struct.str_list, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !11
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.nt_opts, ptr %16, i32 0, i32 33
  %18 = getelementptr inbounds %struct.str_list, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !14
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef @.str.297, i32 noundef %15, i32 noundef %19) #6
  br label %21

21:                                               ; preds = %10, %1
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.nt_opts, ptr %22, i32 0, i32 31
  %24 = getelementptr inbounds %struct.str_list, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !11
  %26 = icmp sle i32 %25, 0
  br i1 %26, label %33, label %27

27:                                               ; preds = %21
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.nt_opts, ptr %28, i32 0, i32 33
  %30 = getelementptr inbounds %struct.str_list, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !14
  %32 = icmp sle i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %27, %21
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %135

34:                                               ; preds = %27
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %131, %34
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.nt_opts, ptr %37, i32 0, i32 33
  %39 = getelementptr inbounds %struct.str_list, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !14
  %41 = icmp slt i32 %36, %40
  br i1 %41, label %42, label %134

42:                                               ; preds = %35
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.nt_opts, ptr %44, i32 0, i32 33
  %46 = getelementptr inbounds %struct.str_list, ptr %45, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !15
  %48 = load i32, ptr %5, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds ptr, ptr %47, i64 %49
  %51 = load ptr, ptr %50, align 8, !tbaa !5
  %52 = call ptr @nt_image_read(ptr noundef %43, ptr noundef %51, i32 noundef 1)
  store ptr %52, ptr %4, align 8, !tbaa !5
  %53 = load i32, ptr @g_debug, align 4, !tbaa !9
  %54 = icmp sgt i32 %53, 1
  br i1 %54, label %55, label %70

55:                                               ; preds = %42
  %56 = load ptr, ptr @stderr, align 8, !tbaa !5
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.nt_opts, ptr %57, i32 0, i32 31
  %59 = getelementptr inbounds %struct.str_list, ptr %58, i32 0, i32 0
  %60 = load i32, ptr %59, align 8, !tbaa !11
  %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 1
  %64 = load ptr, ptr %63, align 8, !tbaa !15
  %65 = load i32, ptr %5, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds ptr, ptr %64, i64 %66
  %68 = load ptr, ptr %67, align 8, !tbaa !5
  %69 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef @.str.298, i32 noundef %60, ptr noundef %68) #6
  br label %70

70:                                               ; preds = %55, %42
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = call i32 @modify_all_fields(ptr noundef %71, ptr noundef %72, ptr noundef @g_nim_fields, i32 noundef 63)
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %75, label %77

75:                                               ; preds = %70
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  call void @nifti_image_free(ptr noundef %76)
  store i32 1, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %135

77:                                               ; preds = %70
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.nt_opts, ptr %78, i32 0, i32 26
  %80 = load i32, ptr %79, align 8, !tbaa !16
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %82, label %97

82:                                               ; preds = %77
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.nt_opts, ptr %84, i32 0, i32 34
  %86 = getelementptr inbounds [2048 x i8], ptr %85, i64 0, i64 0
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.nt_opts, ptr %87, i32 0, i32 34
  %89 = getelementptr inbounds [2048 x i8], ptr %88, i64 0, i64 0
  %90 = call i64 @strlen(ptr noundef %89) #7
  %91 = trunc i64 %90 to i32
  %92 = call i32 @nifti_add_extension(ptr noundef %83, ptr noundef %86, i32 noundef %91, i32 noundef 6)
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %94, label %97

94:                                               ; preds = %82
  %95 = load ptr, ptr @stderr, align 8, !tbaa !5
  %96 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %95, ptr noundef @.str.230) #6
  br label %97

97:                                               ; preds = %94, %82, %77
  %98 = load ptr, ptr %3, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.nt_opts, ptr %98, i32 0, i32 28
  %100 = load ptr, ptr %99, align 8, !tbaa !17
  %101 = icmp ne ptr %100, null
  br i1 %101, label %102, label %118

102:                                              ; preds = %97
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  %104 = load ptr, ptr %3, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.nt_opts, ptr %104, i32 0, i32 28
  %106 = load ptr, ptr %105, align 8, !tbaa !17
  %107 = call i32 @nifti_set_filenames(ptr noundef %103, ptr noundef %106, i32 noundef 1, i32 noundef 1)
  %108 = icmp ne i32 %107, 0
  br i1 %108, label %109, label %117

109:                                              ; preds = %102
  %110 = load ptr, ptr @stderr, align 8, !tbaa !5
  %111 = getelementptr inbounds [13 x i8], ptr %6, i64 0, i64 0
  %112 = load ptr, ptr %3, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.nt_opts, ptr %112, i32 0, i32 28
  %114 = load ptr, ptr %113, align 8, !tbaa !17
  %115 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %110, ptr noundef @.str.287, ptr noundef %111, ptr noundef @.str.288, ptr noundef %114) #6
  %116 = load ptr, ptr %4, align 8, !tbaa !5
  call void @nifti_image_free(ptr noundef %116)
  store i32 1, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %135

117:                                              ; preds = %102
  br label %118

118:                                              ; preds = %117, %97
  %119 = load ptr, ptr %4, align 8, !tbaa !5
  %120 = call i32 @nifti_image_write_status(ptr noundef %119)
  %121 = icmp ne i32 %120, 0
  br i1 %121, label %122, label %129

122:                                              ; preds = %118
  %123 = load ptr, ptr @stderr, align 8, !tbaa !5
  %124 = load ptr, ptr %4, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.nifti_image, ptr %124, i32 0, i32 55
  %126 = load ptr, ptr %125, align 8, !tbaa !18
  %127 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %123, ptr noundef @.str.232, ptr noundef %126) #6
  %128 = load ptr, ptr %4, align 8, !tbaa !5
  call void @nifti_image_free(ptr noundef %128)
  store i32 1, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %135

129:                                              ; preds = %118
  %130 = load ptr, ptr %4, align 8, !tbaa !5
  call void @nifti_image_free(ptr noundef %130)
  br label %131

131:                                              ; preds = %129
  %132 = load i32, ptr %5, align 4, !tbaa !9
  %133 = add nsw i32 %132, 1
  store i32 %133, ptr %5, align 4, !tbaa !9
  br label %35, !llvm.loop !23

134:                                              ; preds = %35
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %135

135:                                              ; preds = %134, %122, %109, %75, %33
  call void @llvm.lifetime.end.p0(i64 13, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  %136 = load i32, ptr %2, align 4
  ret i32 %136
}

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

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

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

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

declare void @nifti_image_free(ptr noundef) #4

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

declare i32 @nifti_image_write_status(ptr 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) #5

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

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 "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 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 208}
!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 248}
!16 = !{!12, !10, i64 160}
!17 = !{!12, !6, i64 168}
!18 = !{!19, !6, i64 632}
!19 = !{!"", !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, !20, i64 64, !10, i64 72, !10, i64 76, !21, i64 80, !21, i64 84, !21, i64 88, !21, i64 92, !21, i64 96, !21, i64 100, !21, i64 104, !7, i64 108, !21, i64 140, !21, i64 144, !21, i64 148, !21, 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, !21, i64 188, !21, i64 192, !21, i64 196, !21, i64 200, !21, i64 204, !21, i64 208, !21, i64 212, !21, i64 216, !22, i64 220, !22, i64 284, !22, i64 348, !22, i64 412, !21, i64 476, !10, i64 480, !10, i64 484, !10, i64 488, !10, i64 492, !21, i64 496, !21, i64 500, !21, 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}
!20 = !{!"long", !7, i64 0}
!21 = !{!"float", !7, i64 0}
!22 = !{!"", !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


; 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.field_s = type { i32, i32, i32, i32, [20 x i8] }

@g_nim_fields = external hidden global [63 x %struct.field_s], align 16
@stderr = external local_unnamed_addr global ptr, align 8
@g_debug = external hidden local_unnamed_addr global i32, align 4
@.str.230 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.232 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.287 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.288 = external hidden unnamed_addr constant [36 x i8], align 1
@__const.act_mod_nims.func = external hidden unnamed_addr constant [13 x i8], align 1
@.str.297 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.298 = external hidden unnamed_addr constant [40 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_mod_nims(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca [13 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 13, ptr nonnull %2) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(13) %2, ptr noundef nonnull align 1 dereferenceable(13) @__const.act_mod_nims.func, i64 13, i1 false)
  %3 = load i32, ptr @g_debug, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 2
  br i1 %4, label %5, label %12

5:                                                ; preds = %1
  %6 = load ptr, ptr @stderr, align 8, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %0, i64 208
  %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.297, i32 noundef %8, i32 noundef %10) #7
  br label %12

12:                                               ; preds = %5, %1
  %13 = getelementptr inbounds i8, ptr %0, i64 208
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = icmp slt i32 %14, 1
  br i1 %15, label %.loopexit, label %16

16:                                               ; preds = %12
  %17 = getelementptr inbounds i8, ptr %0, i64 240
  %18 = load i32, ptr %17, align 8, !tbaa !14
  %19 = icmp slt i32 %18, 1
  br i1 %19, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %16
  %20 = getelementptr inbounds i8, ptr %0, i64 248
  %21 = getelementptr inbounds i8, ptr %0, i64 160
  %22 = getelementptr inbounds i8, ptr %0, i64 256
  %23 = getelementptr inbounds i8, ptr %0, i64 168
  br label %24

24:                                               ; preds = %.lr.ph, %65
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %65 ]
  %25 = load ptr, ptr %20, align 8, !tbaa !15
  %26 = getelementptr inbounds ptr, ptr %25, i64 %indvars.iv
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = tail call ptr @nt_image_read(ptr noundef nonnull %0, ptr noundef %27, i32 noundef 1)
  %29 = load i32, ptr @g_debug, align 4, !tbaa !5
  %30 = icmp sgt i32 %29, 1
  br i1 %30, label %31, label %38

31:                                               ; preds = %24
  %32 = load ptr, ptr @stderr, align 8, !tbaa !9
  %33 = load i32, ptr %13, align 8, !tbaa !11
  %34 = load ptr, ptr %20, align 8, !tbaa !15
  %35 = getelementptr inbounds ptr, ptr %34, i64 %indvars.iv
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  %37 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull @.str.298, i32 noundef %33, ptr noundef %36) #7
  br label %38

38:                                               ; preds = %31, %24
  %39 = tail call i32 @modify_all_fields(ptr noundef %28, ptr noundef nonnull %0, ptr noundef nonnull @g_nim_fields, i32 noundef 63)
  %.not = icmp eq i32 %39, 0
  br i1 %.not, label %41, label %40

40:                                               ; preds = %38
  tail call void @nifti_image_free(ptr noundef %28) #6
  br label %.loopexit

41:                                               ; preds = %38
  %42 = load i32, ptr %21, align 8, !tbaa !16
  %.not31 = icmp eq i32 %42, 0
  br i1 %.not31, label %50, label %43

43:                                               ; preds = %41
  %44 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %22) #8
  %45 = trunc i64 %44 to i32
  %46 = tail call i32 @nifti_add_extension(ptr noundef %28, ptr noundef nonnull %22, i32 noundef %45, i32 noundef 6) #6
  %.not32 = icmp eq i32 %46, 0
  br i1 %.not32, label %50, label %47

47:                                               ; preds = %43
  %48 = load ptr, ptr @stderr, align 8, !tbaa !9
  %49 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef nonnull @.str.230) #7
  br label %50

50:                                               ; preds = %47, %43, %41
  %51 = load ptr, ptr %23, align 8, !tbaa !17
  %.not33 = icmp eq ptr %51, null
  br i1 %.not33, label %58, label %52

52:                                               ; preds = %50
  %53 = tail call i32 @nifti_set_filenames(ptr noundef %28, ptr noundef nonnull %51, i32 noundef 1, i32 noundef 1) #6
  %.not34 = icmp eq i32 %53, 0
  br i1 %.not34, label %58, label %54

54:                                               ; preds = %52
  %55 = load ptr, ptr @stderr, align 8, !tbaa !9
  %56 = load ptr, ptr %23, align 8, !tbaa !17
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef nonnull @.str.287, ptr noundef nonnull %2, ptr noundef nonnull @.str.288, ptr noundef %56) #7
  call void @nifti_image_free(ptr noundef %28) #6
  br label %.loopexit

58:                                               ; preds = %52, %50
  %59 = tail call i32 @nifti_image_write_status(ptr noundef %28) #6
  %.not35 = icmp eq i32 %59, 0
  br i1 %.not35, label %65, label %60

60:                                               ; preds = %58
  %61 = load ptr, ptr @stderr, align 8, !tbaa !9
  %62 = getelementptr inbounds i8, ptr %28, i64 632
  %63 = load ptr, ptr %62, align 8, !tbaa !18
  %64 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %61, ptr noundef nonnull @.str.232, ptr noundef %63) #7
  tail call void @nifti_image_free(ptr noundef %28) #6
  br label %.loopexit

65:                                               ; preds = %58
  tail call void @nifti_image_free(ptr noundef %28) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %66 = load i32, ptr %17, align 8, !tbaa !14
  %67 = sext i32 %66 to i64
  %68 = icmp slt i64 %indvars.iv.next, %67
  br i1 %68, label %24, label %.loopexit, !llvm.loop !23

.loopexit:                                        ; preds = %65, %12, %16, %60, %54, %40
  %.029 = phi i32 [ 1, %40 ], [ 1, %54 ], [ 1, %60 ], [ 0, %16 ], [ 0, %12 ], [ 0, %65 ]
  call void @llvm.lifetime.end.p0(i64 13, ptr nonnull %2) #6
  ret i32 %.029
}

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

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

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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

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


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