; 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] }

@stderr = external global ptr, align 8
@.str.437 = external hidden unnamed_addr constant [32 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @fill_field(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  %12 = load i32, ptr %8, align 4, !tbaa !9
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.field_s, ptr %13, i32 0, i32 0
  store i32 %12, ptr %14, align 4, !tbaa !11
  %15 = load i32, ptr %9, align 4, !tbaa !9
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.field_s, ptr %16, i32 0, i32 1
  store i32 %15, ptr %17, align 4, !tbaa !13
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.field_s, ptr %18, i32 0, i32 2
  store i32 1, ptr %19, align 4, !tbaa !14
  %20 = load i32, ptr %10, align 4, !tbaa !9
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.field_s, ptr %21, i32 0, i32 3
  store i32 %20, ptr %22, align 4, !tbaa !15
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.field_s, ptr %23, i32 0, i32 4
  %25 = getelementptr inbounds [20 x i8], ptr %24, i64 0, i64 0
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = call ptr @strncpy(ptr noundef %25, ptr noundef %26, i64 noundef 19) #2
  %28 = load i32, ptr %8, align 4, !tbaa !9
  switch i32 %28, label %41 [
    i32 0, label %29
    i32 256, label %29
    i32 -4095, label %29
    i32 4, label %32
    i32 8, label %35
    i32 16, label %35
    i32 -4079, label %38
    i32 -4078, label %38
    i32 -4077, label %38
  ]

29:                                               ; preds = %5, %5, %5
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.field_s, ptr %30, i32 0, i32 2
  store i32 1, ptr %31, align 4, !tbaa !14
  br label %45

32:                                               ; preds = %5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.field_s, ptr %33, i32 0, i32 2
  store i32 2, ptr %34, align 4, !tbaa !14
  br label %45

35:                                               ; preds = %5, %5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.field_s, ptr %36, i32 0, i32 2
  store i32 4, ptr %37, align 4, !tbaa !14
  br label %45

38:                                               ; preds = %5, %5, %5
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.field_s, ptr %39, i32 0, i32 2
  store i32 8, ptr %40, align 4, !tbaa !14
  br label %45

41:                                               ; preds = %5
  %42 = load ptr, ptr @stderr, align 8, !tbaa !5
  %43 = load i32, ptr %8, align 4, !tbaa !9
  %44 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef @.str.437, i32 noundef %43) #2
  store i32 1, ptr %6, align 4
  br label %46

45:                                               ; preds = %38, %35, %32, %29
  store i32 0, ptr %6, align 4
  br label %46

46:                                               ; preds = %45, %41
  %47 = load i32, ptr %6, align 4
  ret i32 %47
}

attributes #0 = { 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 = { 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 = !{!"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 0}
!12 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !7, i64 16}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 12}


; 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.437 = external hidden unnamed_addr constant [32 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: readwrite)
declare ptr @strncpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly, i64 noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind uwtable
define dso_local range(i32 0, 2) i32 @fill_field(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef readonly %4) local_unnamed_addr #2 {
  store i32 %1, ptr %0, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %2, ptr %6, align 4, !tbaa !10
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 1, ptr %7, align 4, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %3, ptr %8, align 4, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = tail call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %9, ptr noundef nonnull dereferenceable(1) %4, i64 noundef 19) #3
  switch i32 %1, label %15 [
    i32 0, label %11
    i32 256, label %11
    i32 -4095, label %11
    i32 4, label %12
    i32 8, label %13
    i32 16, label %13
    i32 -4079, label %14
    i32 -4078, label %14
    i32 -4077, label %14
  ]

11:                                               ; preds = %5, %5, %5
  store i32 1, ptr %7, align 4, !tbaa !11
  br label %18

12:                                               ; preds = %5
  store i32 2, ptr %7, align 4, !tbaa !11
  br label %18

13:                                               ; preds = %5, %5
  store i32 4, ptr %7, align 4, !tbaa !11
  br label %18

14:                                               ; preds = %5, %5, %5
  store i32 8, ptr %7, align 4, !tbaa !11
  br label %18

15:                                               ; preds = %5
  %16 = load ptr, ptr @stderr, align 8, !tbaa !13
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.437, i32 noundef %1) #4
  br label %18

18:                                               ; preds = %11, %12, %13, %14, %15
  %.0 = phi i32 [ 1, %15 ], [ 0, %14 ], [ 0, %13 ], [ 0, %12 ], [ 0, %11 ]
  ret i32 %.0
}

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


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