; 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_global_options = type { i32, i32, i32 }

@stderr = external global ptr, align 8
@g_opts = external hidden global %struct.nifti_global_options, align 4
@__const.nifti_find_file_extension.extnii = external hidden unnamed_addr constant [8 x i8], align 1
@__const.nifti_find_file_extension.exthdr = external hidden unnamed_addr constant [8 x i8], align 1
@__const.nifti_find_file_extension.extimg = external hidden unnamed_addr constant [8 x i8], align 1
@__const.nifti_find_file_extension.extnia = external hidden unnamed_addr constant [8 x i8], align 1
@.str.103 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.104 = 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
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @nifti_find_file_extension(ptr noundef %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [8 x i8], align 1
  %6 = alloca i32, align 4
  %7 = alloca [8 x i8], align 1
  %8 = alloca [8 x i8], align 1
  %9 = alloca [8 x i8], align 1
  %10 = alloca [8 x i8], align 1
  %11 = alloca [4 x ptr], align 16
  %12 = 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 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %7, ptr align 1 @__const.nifti_find_file_extension.extnii, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %8, ptr align 1 @__const.nifti_find_file_extension.exthdr, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %9, ptr align 1 @__const.nifti_find_file_extension.extimg, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %10, ptr align 1 @__const.nifti_find_file_extension.extnia, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #6
  call void @llvm.memset.p0.i64(ptr align 16 %11, i8 0, i64 32, i1 false)
  %13 = getelementptr inbounds [8 x i8], ptr %7, i64 0, i64 0
  %14 = getelementptr inbounds [4 x ptr], ptr %11, i64 0, i64 0
  store ptr %13, ptr %14, align 16, !tbaa !5
  %15 = getelementptr inbounds [8 x i8], ptr %8, i64 0, i64 0
  %16 = getelementptr inbounds [4 x ptr], ptr %11, i64 0, i64 1
  store ptr %15, ptr %16, align 8, !tbaa !5
  %17 = getelementptr inbounds [8 x i8], ptr %9, i64 0, i64 0
  %18 = getelementptr inbounds [4 x ptr], ptr %11, i64 0, i64 2
  store ptr %17, ptr %18, align 16, !tbaa !5
  %19 = getelementptr inbounds [8 x i8], ptr %10, i64 0, i64 0
  %20 = getelementptr inbounds [4 x ptr], ptr %11, i64 0, i64 3
  store ptr %19, ptr %20, align 8, !tbaa !5
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %24, label %23

23:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %12, align 4
  br label %69

24:                                               ; preds = %1
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = call i64 @strlen(ptr noundef %25) #7
  %27 = trunc i64 %26 to i32
  store i32 %27, ptr %6, align 4, !tbaa !9
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = icmp slt i32 %28, 4
  br i1 %29, label %30, label %31

30:                                               ; preds = %24
  store ptr null, ptr %2, align 8
  store i32 1, ptr %12, align 4
  br label %69

31:                                               ; preds = %24
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds i8, ptr %32, i64 %34
  %36 = getelementptr inbounds i8, ptr %35, i64 -4
  store ptr %36, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds [8 x i8], ptr %5, i64 0, i64 0
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = call ptr @strncpy(ptr noundef %37, ptr noundef %38, i64 noundef 7) #6
  %40 = getelementptr inbounds [8 x i8], ptr %5, i64 0, i64 7
  store i8 0, ptr %40, align 1, !tbaa !11
  %41 = load i32, ptr getelementptr inbounds (%struct.nifti_global_options, ptr @g_opts, i32 0, i32 2), align 4, !tbaa !12
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %46

43:                                               ; preds = %31
  %44 = getelementptr inbounds [8 x i8], ptr %5, i64 0, i64 0
  %45 = call i32 @make_lowercase(ptr noundef %44)
  br label %46

46:                                               ; preds = %43, %31
  %47 = getelementptr inbounds [8 x i8], ptr %5, i64 0, i64 0
  %48 = getelementptr inbounds [4 x ptr], ptr %11, i64 0, i64 0
  %49 = call i32 @compare_strlist(ptr noundef %47, ptr noundef %48, i32 noundef 4)
  %50 = icmp sge i32 %49, 0
  br i1 %50, label %51, label %61

51:                                               ; preds = %46
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = call i32 @is_mixedcase(ptr noundef %52)
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %59

55:                                               ; preds = %51
  %56 = load ptr, ptr @stderr, align 8, !tbaa !5
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef @.str.103, ptr noundef %57) #6
  store ptr null, ptr %2, align 8
  store i32 1, ptr %12, align 4
  br label %69

59:                                               ; preds = %51
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %60, ptr %2, align 8
  store i32 1, ptr %12, align 4
  br label %69

61:                                               ; preds = %46
  %62 = load i32, ptr @g_opts, align 4, !tbaa !14
  %63 = icmp sgt i32 %62, 1
  br i1 %63, label %64, label %68

64:                                               ; preds = %61
  %65 = load ptr, ptr @stderr, align 8, !tbaa !5
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef @.str.104, ptr noundef %66) #6
  br label %68

68:                                               ; preds = %64, %61
  store ptr null, ptr %2, align 8
  store i32 1, ptr %12, align 4
  br label %69

69:                                               ; preds = %68, %59, %55, %30, %23
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  %70 = load ptr, ptr %2, align 8
  ret ptr %70
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

; Function Attrs: nounwind
declare ptr @strncpy(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @make_lowercase(ptr noundef) #4

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

; Function Attrs: nounwind uwtable
declare hidden i32 @is_mixedcase(ptr noundef) #4

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 8}
!13 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!14 = !{!13, !10, i64 0}


; 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_global_options = type { i32, i32, i32 }

@stderr = external local_unnamed_addr global ptr, align 8
@g_opts = external hidden local_unnamed_addr global %struct.nifti_global_options, align 4
@__const.nifti_find_file_extension.extnii = external hidden unnamed_addr constant [8 x i8], align 1
@__const.nifti_find_file_extension.exthdr = external hidden unnamed_addr constant [8 x i8], align 1
@__const.nifti_find_file_extension.extimg = external hidden unnamed_addr constant [8 x i8], align 1
@__const.nifti_find_file_extension.extnia = external hidden unnamed_addr constant [8 x i8], align 1
@.str.103 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.104 = 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: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @nifti_find_file_extension(ptr noundef %0) local_unnamed_addr #3 {
  %2 = alloca [8 x i8], align 1
  %3 = alloca [8 x i8], align 8
  %4 = alloca [8 x i8], align 8
  %5 = alloca [8 x i8], align 8
  %6 = alloca [8 x i8], align 8
  %7 = alloca [4 x ptr], align 16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %8 = load i64, ptr @__const.nifti_find_file_extension.extnii, align 1
  store i64 %8, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %9 = load i64, ptr @__const.nifti_find_file_extension.exthdr, align 1
  store i64 %9, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %10 = load i64, ptr @__const.nifti_find_file_extension.extimg, align 1
  store i64 %10, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %11 = load i64, ptr @__const.nifti_find_file_extension.extnia, align 1
  store i64 %11, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #5
  store ptr %3, ptr %7, align 16, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr %4, ptr %12, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %7, i64 16
  store ptr %5, ptr %13, align 16, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %7, i64 24
  store ptr %6, ptr %14, align 8, !tbaa !5
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %42, label %15

15:                                               ; preds = %1
  %16 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #6
  %17 = trunc i64 %16 to i32
  %18 = icmp slt i32 %17, 4
  br i1 %18, label %42, label %19

19:                                               ; preds = %15
  %20 = and i64 %16, 2147483647
  %21 = getelementptr inbounds i8, ptr %0, i64 %20
  %22 = getelementptr inbounds i8, ptr %21, i64 -4
  %23 = call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) %22, i64 noundef 7) #5
  %24 = getelementptr inbounds i8, ptr %2, i64 7
  store i8 0, ptr %24, align 1, !tbaa !9
  %25 = load i32, ptr getelementptr inbounds (i8, ptr @g_opts, i64 8), align 4, !tbaa !10
  %.not12 = icmp eq i32 %25, 0
  br i1 %.not12, label %28, label %26

26:                                               ; preds = %19
  %27 = call i32 @make_lowercase(ptr noundef nonnull %2)
  br label %28

28:                                               ; preds = %26, %19
  %29 = call i32 @compare_strlist(ptr noundef nonnull %2, ptr noundef nonnull %7, i32 noundef 4)
  %30 = icmp sgt i32 %29, -1
  br i1 %30, label %31, label %36

31:                                               ; preds = %28
  %32 = call i32 @is_mixedcase(ptr noundef nonnull %22)
  %.not13 = icmp eq i32 %32, 0
  br i1 %.not13, label %42, label %33

33:                                               ; preds = %31
  %34 = load ptr, ptr @stderr, align 8, !tbaa !5
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef nonnull @.str.103, ptr noundef nonnull %22) #7
  br label %42

36:                                               ; preds = %28
  %37 = load i32, ptr @g_opts, align 4, !tbaa !13
  %38 = icmp sgt i32 %37, 1
  br i1 %38, label %39, label %42

39:                                               ; preds = %36
  %40 = load ptr, ptr @stderr, align 8, !tbaa !5
  %41 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef nonnull @.str.104, ptr noundef nonnull %0) #7
  br label %42

42:                                               ; preds = %36, %39, %31, %15, %1, %33
  %.0 = phi ptr [ null, %33 ], [ null, %1 ], [ null, %15 ], [ %22, %31 ], [ null, %39 ], [ null, %36 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  ret ptr %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strncpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly, i64 noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden i32 @make_lowercase(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @compare_strlist(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @is_mixedcase(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 8}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!11, !12, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass