; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/ThirdParty/MINC/src/libminc/nifti (nifti1_io)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.nifti_type_ele = type { i32, i32, i32, ptr }

@nifti_type_list = external hidden global [43 x %struct.nifti_type_ele], align 16

; 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 @nifti_datatype_is_valid(i32 noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 43, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %9 = load i32, ptr %5, align 4, !tbaa !5
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %15

11:                                               ; preds = %2
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %35

15:                                               ; preds = %11, %2
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = sub nsw i32 %16, 1
  store i32 %17, ptr %7, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %31, %15
  %19 = load i32, ptr %7, align 4, !tbaa !5
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %21, label %34

21:                                               ; preds = %18
  %22 = load i32, ptr %7, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [43 x %struct.nifti_type_ele], ptr @nifti_type_list, i64 0, i64 %23
  %25 = getelementptr inbounds %struct.nifti_type_ele, ptr %24, i32 0, i32 0
  %26 = load i32, ptr %25, align 8, !tbaa !9
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = icmp eq i32 %26, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %21
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %35

30:                                               ; preds = %21
  br label %31

31:                                               ; preds = %30
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = add nsw i32 %32, -1
  store i32 %33, ptr %7, align 4, !tbaa !5
  br label %18, !llvm.loop !12

34:                                               ; preds = %18
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %35

35:                                               ; preds = %34, %29, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %36 = load i32, ptr %3, align 4
  ret i32 %36
}

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 }

!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, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !11, i64 16}
!11 = !{!"any pointer", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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.nifti_type_ele = type { i32, i32, i32, ptr }

@nifti_type_list = external hidden local_unnamed_addr global [43 x %struct.nifti_type_ele], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local range(i32 0, 2) i32 @nifti_datatype_is_valid(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = icmp ne i32 %1, 0
  %4 = icmp eq i32 %0, 1
  %or.cond = and i1 %4, %3
  br i1 %or.cond, label %.loopexit, label %.preheader.preheader

.preheader.preheader:                             ; preds = %2
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 1008), align 16, !tbaa !5
  %6 = icmp eq i32 %5, %0
  %7 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 984), align 8
  %8 = icmp eq i32 %7, %0
  %or.cond12 = select i1 %6, i1 true, i1 %8
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 960), align 16
  %10 = icmp eq i32 %9, %0
  %or.cond14 = select i1 %or.cond12, i1 true, i1 %10
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 936), align 8
  %12 = icmp eq i32 %11, %0
  %or.cond16 = select i1 %or.cond14, i1 true, i1 %12
  %13 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 912), align 16
  %14 = icmp eq i32 %13, %0
  %or.cond18 = select i1 %or.cond16, i1 true, i1 %14
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 888), align 8
  %16 = icmp eq i32 %15, %0
  %or.cond20 = select i1 %or.cond18, i1 true, i1 %16
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 864), align 16
  %18 = icmp eq i32 %17, %0
  %or.cond22 = select i1 %or.cond20, i1 true, i1 %18
  %19 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 840), align 8
  %20 = icmp eq i32 %19, %0
  %or.cond24 = select i1 %or.cond22, i1 true, i1 %20
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 816), align 16
  %22 = icmp eq i32 %21, %0
  %or.cond26 = select i1 %or.cond24, i1 true, i1 %22
  %23 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 792), align 8
  %24 = icmp eq i32 %23, %0
  %or.cond28 = select i1 %or.cond26, i1 true, i1 %24
  %25 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 768), align 16
  %26 = icmp eq i32 %25, %0
  %or.cond30 = select i1 %or.cond28, i1 true, i1 %26
  %27 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 744), align 8
  %28 = icmp eq i32 %27, %0
  %or.cond32 = select i1 %or.cond30, i1 true, i1 %28
  %29 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 720), align 16
  %30 = icmp eq i32 %29, %0
  %or.cond34 = select i1 %or.cond32, i1 true, i1 %30
  %31 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 696), align 8
  %32 = icmp eq i32 %31, %0
  %or.cond36 = select i1 %or.cond34, i1 true, i1 %32
  %33 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 672), align 16
  %34 = icmp eq i32 %33, %0
  %or.cond38 = select i1 %or.cond36, i1 true, i1 %34
  %35 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 648), align 8
  %36 = icmp eq i32 %35, %0
  %or.cond40 = select i1 %or.cond38, i1 true, i1 %36
  %37 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 624), align 16
  %38 = icmp eq i32 %37, %0
  %or.cond42 = select i1 %or.cond40, i1 true, i1 %38
  %39 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 600), align 8
  %40 = icmp eq i32 %39, %0
  %or.cond44 = select i1 %or.cond42, i1 true, i1 %40
  %41 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 576), align 16
  %42 = icmp eq i32 %41, %0
  %or.cond46 = select i1 %or.cond44, i1 true, i1 %42
  %43 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 552), align 8
  %44 = icmp eq i32 %43, %0
  %or.cond48 = select i1 %or.cond46, i1 true, i1 %44
  %45 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 528), align 16
  %46 = icmp eq i32 %45, %0
  %or.cond50 = select i1 %or.cond48, i1 true, i1 %46
  %47 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 504), align 8
  %48 = icmp eq i32 %47, %0
  %or.cond52 = select i1 %or.cond50, i1 true, i1 %48
  %49 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 480), align 16
  %50 = icmp eq i32 %49, %0
  %or.cond54 = select i1 %or.cond52, i1 true, i1 %50
  %51 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 456), align 8
  %52 = icmp eq i32 %51, %0
  %or.cond56 = select i1 %or.cond54, i1 true, i1 %52
  %53 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 432), align 16
  %54 = icmp eq i32 %53, %0
  %or.cond58 = select i1 %or.cond56, i1 true, i1 %54
  %55 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 408), align 8
  %56 = icmp eq i32 %55, %0
  %or.cond60 = select i1 %or.cond58, i1 true, i1 %56
  %57 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 384), align 16
  %58 = icmp eq i32 %57, %0
  %or.cond62 = select i1 %or.cond60, i1 true, i1 %58
  %59 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 360), align 8
  %60 = icmp eq i32 %59, %0
  %or.cond64 = select i1 %or.cond62, i1 true, i1 %60
  %61 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 336), align 16
  %62 = icmp eq i32 %61, %0
  %or.cond66 = select i1 %or.cond64, i1 true, i1 %62
  %63 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 312), align 8
  %64 = icmp eq i32 %63, %0
  %or.cond68 = select i1 %or.cond66, i1 true, i1 %64
  %65 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 288), align 16
  %66 = icmp eq i32 %65, %0
  %or.cond70 = select i1 %or.cond68, i1 true, i1 %66
  %67 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 264), align 8
  %68 = icmp eq i32 %67, %0
  %or.cond72 = select i1 %or.cond70, i1 true, i1 %68
  %69 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 240), align 16
  %70 = icmp eq i32 %69, %0
  %or.cond74 = select i1 %or.cond72, i1 true, i1 %70
  %71 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 216), align 8
  %72 = icmp eq i32 %71, %0
  %or.cond76 = select i1 %or.cond74, i1 true, i1 %72
  %73 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 192), align 16
  %74 = icmp eq i32 %73, %0
  %or.cond78 = select i1 %or.cond76, i1 true, i1 %74
  %75 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 168), align 8
  %76 = icmp eq i32 %75, %0
  %or.cond80 = select i1 %or.cond78, i1 true, i1 %76
  %77 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 144), align 16
  %78 = icmp eq i32 %77, %0
  %or.cond82 = select i1 %or.cond80, i1 true, i1 %78
  %79 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 120), align 8
  %80 = icmp eq i32 %79, %0
  %or.cond84 = select i1 %or.cond82, i1 true, i1 %80
  %81 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 96), align 16
  %82 = icmp eq i32 %81, %0
  %or.cond86 = select i1 %or.cond84, i1 true, i1 %82
  %83 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 72), align 8
  %84 = icmp eq i32 %83, %0
  %or.cond88 = select i1 %or.cond86, i1 true, i1 %84
  %85 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 48), align 16
  %86 = icmp eq i32 %85, %0
  %or.cond90 = select i1 %or.cond88, i1 true, i1 %86
  %87 = load i32, ptr getelementptr inbounds (i8, ptr @nifti_type_list, i64 24), align 8
  %88 = icmp eq i32 %87, %0
  %or.cond92 = select i1 %or.cond90, i1 true, i1 %88
  %spec.select = zext i1 %or.cond92 to i32
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.preheader, %2
  %.09 = phi i32 [ 0, %2 ], [ %spec.select, %.preheader.preheader ]
  ret i32 %.09
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) 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" }

!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 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass