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

@stderr = external global ptr, align 8
@.str.304 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.305 = 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
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @modify_all_fields(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.nt_opts, ptr %14, i32 0, i32 31
  %16 = getelementptr inbounds %struct.str_list, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !11
  %18 = icmp sle i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %4
  store i32 0, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %110

20:                                               ; preds = %4
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.nt_opts, ptr %21, i32 0, i32 31
  %23 = getelementptr inbounds %struct.str_list, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !11
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.nt_opts, ptr %25, i32 0, i32 32
  %27 = getelementptr inbounds %struct.str_list, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !14
  %29 = icmp ne i32 %24, %28
  br i1 %29, label %30, label %41

30:                                               ; preds = %20
  %31 = load ptr, ptr @stderr, align 8, !tbaa !5
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.nt_opts, ptr %32, i32 0, i32 31
  %34 = getelementptr inbounds %struct.str_list, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 8, !tbaa !11
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.nt_opts, ptr %36, i32 0, i32 32
  %38 = getelementptr inbounds %struct.str_list, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !14
  %40 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str.304, i32 noundef %35, i32 noundef %39) #4
  store i32 1, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %110

41:                                               ; preds = %20
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %106, %41
  %43 = load i32, ptr %12, align 4, !tbaa !9
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.nt_opts, ptr %44, i32 0, i32 31
  %46 = getelementptr inbounds %struct.str_list, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 8, !tbaa !11
  %48 = icmp slt i32 %43, %47
  br i1 %48, label %49, label %109

49:                                               ; preds = %42
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %50, ptr %10, align 8, !tbaa !5
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %71, %49
  %52 = load i32, ptr %11, align 4, !tbaa !9
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %55, label %76

55:                                               ; preds = %51
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.nt_opts, ptr %56, i32 0, i32 31
  %58 = getelementptr inbounds %struct.str_list, ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !15
  %60 = load i32, ptr %12, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds ptr, ptr %59, i64 %61
  %63 = load ptr, ptr %62, align 8, !tbaa !5
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.field_s, ptr %64, i32 0, i32 4
  %66 = getelementptr inbounds [20 x i8], ptr %65, i64 0, i64 0
  %67 = call i32 @strcmp(ptr noundef %63, ptr noundef %66) #5
  %68 = icmp eq i32 %67, 0
  br i1 %68, label %69, label %70

69:                                               ; preds = %55
  br label %76

70:                                               ; preds = %55
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %11, align 4, !tbaa !9
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %11, align 4, !tbaa !9
  %74 = load ptr, ptr %10, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.field_s, ptr %74, i32 1
  store ptr %75, ptr %10, align 8, !tbaa !5
  br label %51, !llvm.loop !16

76:                                               ; preds = %69, %51
  %77 = load i32, ptr %11, align 4, !tbaa !9
  %78 = load i32, ptr %9, align 4, !tbaa !9
  %79 = icmp eq i32 %77, %78
  br i1 %79, label %80, label %91

80:                                               ; preds = %76
  %81 = load ptr, ptr @stderr, align 8, !tbaa !5
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.nt_opts, ptr %82, i32 0, i32 31
  %84 = getelementptr inbounds %struct.str_list, ptr %83, i32 0, i32 1
  %85 = load ptr, ptr %84, align 8, !tbaa !15
  %86 = load i32, ptr %12, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds ptr, ptr %85, i64 %87
  %89 = load ptr, ptr %88, align 8, !tbaa !5
  %90 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %81, ptr noundef @.str.305, ptr noundef %89) #4
  store i32 1, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %110

91:                                               ; preds = %76
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = load ptr, ptr %10, align 8, !tbaa !5
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.nt_opts, ptr %94, i32 0, i32 32
  %96 = getelementptr inbounds %struct.str_list, ptr %95, i32 0, i32 1
  %97 = load ptr, ptr %96, align 8, !tbaa !18
  %98 = load i32, ptr %12, align 4, !tbaa !9
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds ptr, ptr %97, i64 %99
  %101 = load ptr, ptr %100, align 8, !tbaa !5
  %102 = call i32 @modify_field(ptr noundef %92, ptr noundef %93, ptr noundef %101)
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %104, label %105

104:                                              ; preds = %91
  store i32 1, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %110

105:                                              ; preds = %91
  br label %106

106:                                              ; preds = %105
  %107 = load i32, ptr %12, align 4, !tbaa !9
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %12, align 4, !tbaa !9
  br label %42, !llvm.loop !19

109:                                              ; preds = %42
  store i32 0, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %110

110:                                              ; preds = %109, %104, %80, %30, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %111 = load i32, ptr %5, align 4
  ret i32 %111
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind 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 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 #4 = { nounwind }
attributes #5 = { 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 224}
!15 = !{!12, !6, i64 216}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!12, !6, i64 232}
!19 = distinct !{!19, !17}


; 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
@.str.304 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.305 = external hidden unnamed_addr constant [38 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: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #1

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

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %1, i64 224
  %10 = load i32, ptr %9, align 8, !tbaa !12
  %.not = icmp eq i32 %6, %10
  br i1 %.not, label %.preheader.lr.ph, label %35

.preheader.lr.ph:                                 ; preds = %8
  %11 = getelementptr inbounds i8, ptr %1, i64 216
  %12 = icmp sgt i32 %3, 0
  %13 = getelementptr inbounds i8, ptr %1, i64 232
  br i1 %12, label %.preheader.us, label %.preheader.lr.ph.split

.preheader.us:                                    ; preds = %.preheader.lr.ph, %30
  %indvars.iv52 = phi i64 [ %indvars.iv.next53, %30 ], [ 0, %.preheader.lr.ph ]
  %14 = load ptr, ptr %11, align 8, !tbaa !13
  %15 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv52
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  br label %17

17:                                               ; preds = %.preheader.us, %21
  %.02433.us = phi i32 [ 0, %.preheader.us ], [ %22, %21 ]
  %.02532.us = phi ptr [ %2, %.preheader.us ], [ %23, %21 ]
  %18 = getelementptr inbounds i8, ptr %.02532.us, i64 16
  %19 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %16, ptr noundef nonnull dereferenceable(1) %18) #3
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %._crit_edge.us, label %21

21:                                               ; preds = %17
  %22 = add nuw nsw i32 %.02433.us, 1
  %23 = getelementptr inbounds i8, ptr %.02532.us, i64 36
  %exitcond.not = icmp eq i32 %22, %3
  br i1 %exitcond.not, label %.split.us.loopexit, label %17, !llvm.loop !15

._crit_edge.us:                                   ; preds = %17
  %24 = icmp eq i32 %.02433.us, %3
  br i1 %24, label %.split.us.loopexit, label %25

25:                                               ; preds = %._crit_edge.us
  %26 = load ptr, ptr %13, align 8, !tbaa !17
  %27 = getelementptr inbounds ptr, ptr %26, i64 %indvars.iv52
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  %29 = tail call i32 @modify_field(ptr noundef %0, ptr noundef %.02532.us, ptr noundef %28)
  %.not29.us = icmp eq i32 %29, 0
  br i1 %.not29.us, label %30, label %.loopexit

30:                                               ; preds = %25
  %indvars.iv.next53 = add nuw nsw i64 %indvars.iv52, 1
  %31 = load i32, ptr %5, align 8, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = icmp slt i64 %indvars.iv.next53, %32
  br i1 %33, label %.preheader.us, label %.loopexit, !llvm.loop !18

.preheader.lr.ph.split:                           ; preds = %.preheader.lr.ph
  %34 = icmp eq i32 %3, 0
  br i1 %34, label %.preheader.lr.ph.split..split.us_crit_edge, label %.preheader

.preheader.lr.ph.split..split.us_crit_edge:       ; preds = %.preheader.lr.ph.split
  %.pre = load ptr, ptr %11, align 8, !tbaa !13
  br label %.split.us

35:                                               ; preds = %8
  %36 = load ptr, ptr @stderr, align 8, !tbaa !14
  %37 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef nonnull @.str.304, i32 noundef %6, i32 noundef %10) #4
  br label %.loopexit

.preheader:                                       ; preds = %.preheader.lr.ph.split, %48
  %indvars.iv = phi i64 [ %indvars.iv.next, %48 ], [ 0, %.preheader.lr.ph.split ]
  %38 = load ptr, ptr %13, align 8, !tbaa !17
  %39 = getelementptr inbounds ptr, ptr %38, i64 %indvars.iv
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  %41 = tail call i32 @modify_field(ptr noundef %0, ptr noundef %2, ptr noundef %40)
  %.not29 = icmp eq i32 %41, 0
  br i1 %.not29, label %48, label %.loopexit

.split.us.loopexit:                               ; preds = %._crit_edge.us, %21
  %42 = and i64 %indvars.iv52, 4294967295
  br label %.split.us

.split.us:                                        ; preds = %.preheader.lr.ph.split..split.us_crit_edge, %.split.us.loopexit
  %43 = phi ptr [ %.pre, %.preheader.lr.ph.split..split.us_crit_edge ], [ %14, %.split.us.loopexit ]
  %.us-phi = phi i64 [ 0, %.preheader.lr.ph.split..split.us_crit_edge ], [ %42, %.split.us.loopexit ]
  %44 = load ptr, ptr @stderr, align 8, !tbaa !14
  %45 = getelementptr inbounds ptr, ptr %43, i64 %.us-phi
  %46 = load ptr, ptr %45, align 8, !tbaa !14
  %47 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef nonnull @.str.305, ptr noundef %46) #4
  br label %.loopexit

48:                                               ; preds = %.preheader
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %49 = load i32, ptr %5, align 8, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = icmp slt i64 %indvars.iv.next, %50
  br i1 %51, label %.preheader, label %.loopexit, !llvm.loop !18

.loopexit:                                        ; preds = %.preheader, %48, %25, %30, %4, %.split.us, %35
  %.026 = phi i32 [ 1, %35 ], [ 1, %.split.us ], [ 0, %4 ], [ 1, %25 ], [ 0, %30 ], [ 1, %.preheader ], [ 0, %48 ]
  ret i32 %.026
}

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

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 = { 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 #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind willreturn memory(read) }
attributes #4 = { cold nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 208}
!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, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !7, i64 64, !7, i64 68, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !8, i64 88, !8, i64 120, !7, i64 152, !7, i64 156, !7, i64 160, !7, i64 164, !10, i64 168, !11, i64 176, !11, i64 192, !11, i64 208, !11, i64 224, !11, i64 240, !8, i64 256}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"", !7, i64 0, !10, i64 8}
!12 = !{!6, !7, i64 224}
!13 = !{!6, !10, i64 216}
!14 = !{!10, !10, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!6, !10, i64 232}
!18 = distinct !{!18, !16}


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