; 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_1_header = type { i32, [10 x i8], [18 x i8], i32, i16, i8, i8, [8 x i16], float, float, float, i16, i16, i16, i16, [8 x float], float, float, float, i16, i8, i8, float, float, float, float, i32, i32, [80 x i8], [24 x i8], i16, i16, float, float, float, float, float, float, [4 x float], [4 x float], [4 x float], [16 x i8], [4 x i8] }
%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]] }

@.str.219 = external hidden unnamed_addr constant [4 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 ptr @strcpy(ptr noundef, ptr noundef) #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @nifti_convert_nhdr2nim(ptr noundef byval(%struct.nifti_1_header) align 8, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @nifti_simple_init_nim() #2 {
  %1 = alloca ptr, align 8
  %2 = alloca %struct.nifti_1_header, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 348, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.memset.p0.i64(ptr align 4 %2, i8 0, i64 348, i1 false)
  %5 = getelementptr inbounds %struct.nifti_1_header, ptr %2, i32 0, i32 0
  store i32 348, ptr %5, align 4, !tbaa !5
  %6 = getelementptr inbounds %struct.nifti_1_header, ptr %2, i32 0, i32 5
  store i8 114, ptr %6, align 2, !tbaa !12
  %7 = getelementptr inbounds %struct.nifti_1_header, ptr %2, i32 0, i32 7
  %8 = getelementptr inbounds [8 x i16], ptr %7, i64 0, i64 0
  store i16 3, ptr %8, align 4, !tbaa !13
  %9 = getelementptr inbounds %struct.nifti_1_header, ptr %2, i32 0, i32 7
  %10 = getelementptr inbounds [8 x i16], ptr %9, i64 0, i64 1
  store i16 1, ptr %10, align 2, !tbaa !13
  %11 = getelementptr inbounds %struct.nifti_1_header, ptr %2, i32 0, i32 7
  %12 = getelementptr inbounds [8 x i16], ptr %11, i64 0, i64 2
  store i16 1, ptr %12, align 4, !tbaa !13
  %13 = getelementptr inbounds %struct.nifti_1_header, ptr %2, i32 0, i32 7
  %14 = getelementptr inbounds [8 x i16], ptr %13, i64 0, i64 3
  store i16 1, ptr %14, align 2, !tbaa !13
  %15 = getelementptr inbounds %struct.nifti_1_header, ptr %2, i32 0, i32 7
  %16 = getelementptr inbounds [8 x i16], ptr %15, i64 0, i64 4
  store i16 0, ptr %16, align 4, !tbaa !13
  %17 = getelementptr inbounds %struct.nifti_1_header, ptr %2, i32 0, i32 15
  %18 = getelementptr inbounds [8 x float], ptr %17, i64 0, i64 0
  store float 0.000000e+00, ptr %18, align 4, !tbaa !14
  %19 = getelementptr inbounds %struct.nifti_1_header, ptr %2, i32 0, i32 15
  %20 = getelementptr inbounds [8 x float], ptr %19, i64 0, i64 1
  store float 1.000000e+00, ptr %20, align 4, !tbaa !14
  %21 = getelementptr inbounds %struct.nifti_1_header, ptr %2, i32 0, i32 15
  %22 = getelementptr inbounds [8 x float], ptr %21, i64 0, i64 2
  store float 1.000000e+00, ptr %22, align 4, !tbaa !14
  %23 = getelementptr inbounds %struct.nifti_1_header, ptr %2, i32 0, i32 15
  %24 = getelementptr inbounds [8 x float], ptr %23, i64 0, i64 3
  store float 1.000000e+00, ptr %24, align 4, !tbaa !14
  %25 = getelementptr inbounds %struct.nifti_1_header, ptr %2, i32 0, i32 12
  store i16 16, ptr %25, align 2, !tbaa !15
  %26 = getelementptr inbounds %struct.nifti_1_header, ptr %2, i32 0, i32 12
  %27 = load i16, ptr %26, align 2, !tbaa !15
  %28 = sext i16 %27 to i32
  call void @nifti_datatype_sizes(i32 noundef %28, ptr noundef %3, ptr noundef %4)
  %29 = load i32, ptr %3, align 4, !tbaa !16
  %30 = mul nsw i32 8, %29
  %31 = trunc i32 %30 to i16
  %32 = getelementptr inbounds %struct.nifti_1_header, ptr %2, i32 0, i32 13
  store i16 %31, ptr %32, align 4, !tbaa !17
  %33 = getelementptr inbounds %struct.nifti_1_header, ptr %2, i32 0, i32 42
  %34 = getelementptr inbounds [4 x i8], ptr %33, i64 0, i64 0
  %35 = call ptr @strcpy(ptr noundef %34, ptr noundef @.str.219) #4
  %36 = call ptr @nifti_convert_nhdr2nim(ptr noundef byval(%struct.nifti_1_header) align 8 %2, ptr noundef null)
  store ptr %36, ptr %1, align 8, !tbaa !18
  %37 = load ptr, ptr %1, align 8, !tbaa !18
  %38 = getelementptr inbounds %struct.nifti_image, ptr %37, i32 0, i32 55
  store ptr null, ptr %38, align 8, !tbaa !20
  %39 = load ptr, ptr %1, align 8, !tbaa !18
  %40 = getelementptr inbounds %struct.nifti_image, ptr %39, i32 0, i32 56
  store ptr null, ptr %40, align 8, !tbaa !24
  %41 = load ptr, ptr %1, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 348, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret ptr %41
}

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 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 0}
!6 = !{!"nifti_1_header", !7, i64 0, !8, i64 4, !8, i64 14, !7, i64 32, !10, i64 36, !8, i64 38, !8, i64 39, !8, i64 40, !11, i64 56, !11, i64 60, !11, i64 64, !10, i64 68, !10, i64 70, !10, i64 72, !10, i64 74, !8, i64 76, !11, i64 108, !11, i64 112, !11, i64 116, !10, i64 120, !8, i64 122, !8, i64 123, !11, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !7, i64 140, !7, i64 144, !8, i64 148, !8, i64 228, !10, i64 252, !10, i64 254, !11, i64 256, !11, i64 260, !11, i64 264, !11, i64 268, !11, i64 272, !11, i64 276, !8, i64 280, !8, i64 296, !8, i64 312, !8, i64 328, !8, i64 344}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !8, i64 38}
!13 = !{!10, !10, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!6, !10, i64 70}
!16 = !{!7, !7, i64 0}
!17 = !{!6, !10, i64 72}
!18 = !{!19, !19, i64 0}
!19 = !{!"any pointer", !8, i64 0}
!20 = !{!21, !19, i64 632}
!21 = !{!"", !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, !22, 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, !23, i64 220, !23, i64 284, !23, i64 348, !23, 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, !19, i64 632, !19, i64 640, !7, i64 648, !7, i64 652, !7, i64 656, !19, i64 664, !7, i64 672, !19, i64 680, !7, i64 688}
!22 = !{!"long", !8, i64 0}
!23 = !{!"", !8, i64 0}
!24 = !{!21, !19, i64 640}


; 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_1_header = type { i32, [10 x i8], [18 x i8], i32, i16, i8, i8, [8 x i16], float, float, float, i16, i16, i16, i16, [8 x float], float, float, float, i16, i8, i8, float, float, float, float, i32, i32, [80 x i8], [24 x i8], i16, i16, float, float, float, float, float, float, [4 x float], [4 x float], [4 x float], [16 x i8], [4 x i8] }

@.str.219 = external hidden unnamed_addr constant [4 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: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @nifti_convert_nhdr2nim(ptr noundef byval(%struct.nifti_1_header) align 8, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @nifti_simple_init_nim() local_unnamed_addr #2 {
  %1 = alloca %struct.nifti_1_header, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 348, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(348) %1, i8 0, i64 348, i1 false)
  store i32 348, ptr %1, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 38
  store i8 114, ptr %4, align 2, !tbaa !12
  %5 = getelementptr inbounds i8, ptr %1, i64 40
  store <4 x i16> <i16 3, i16 1, i16 1, i16 1>, ptr %5, align 8, !tbaa !13
  %6 = getelementptr inbounds i8, ptr %1, i64 76
  store <4 x float> <float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, ptr %6, align 4, !tbaa !14
  %7 = getelementptr inbounds i8, ptr %1, i64 70
  store i16 16, ptr %7, align 2, !tbaa !15
  call void @nifti_datatype_sizes(i32 noundef 16, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %8 = load i32, ptr %2, align 4, !tbaa !16
  %.tr = trunc i32 %8 to i16
  %9 = shl i16 %.tr, 3
  %10 = getelementptr inbounds i8, ptr %1, i64 72
  store i16 %9, ptr %10, align 8, !tbaa !17
  %11 = getelementptr inbounds i8, ptr %1, i64 344
  %12 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %11, ptr noundef nonnull dereferenceable(1) @.str.219) #4
  %13 = call ptr @nifti_convert_nhdr2nim(ptr noundef nonnull byval(%struct.nifti_1_header) align 8 %1, ptr noundef null)
  %14 = getelementptr inbounds i8, ptr %13, i64 632
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %14, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 348, ptr nonnull %1) #4
  ret ptr %13
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 0}
!6 = !{!"nifti_1_header", !7, i64 0, !8, i64 4, !8, i64 14, !7, i64 32, !10, i64 36, !8, i64 38, !8, i64 39, !8, i64 40, !11, i64 56, !11, i64 60, !11, i64 64, !10, i64 68, !10, i64 70, !10, i64 72, !10, i64 74, !8, i64 76, !11, i64 108, !11, i64 112, !11, i64 116, !10, i64 120, !8, i64 122, !8, i64 123, !11, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !7, i64 140, !7, i64 144, !8, i64 148, !8, i64 228, !10, i64 252, !10, i64 254, !11, i64 256, !11, i64 260, !11, i64 264, !11, i64 268, !11, i64 272, !11, i64 276, !8, i64 280, !8, i64 296, !8, i64 312, !8, i64 328, !8, i64 344}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !8, i64 38}
!13 = !{!10, !10, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!6, !10, i64 70}
!16 = !{!7, !7, i64 0}
!17 = !{!6, !10, i64 72}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SLPVectorizerPass,SROAPass