; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/ThirdParty/MINC/src/libminc/libcommon (minc_error)

; 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.anon.0 = type { i32, [128 x i8], ptr }
%struct.mierror_entry = type { i32, ptr }

@minc_routine_name = external hidden global ptr, align 8
@stderr = external global ptr, align 8
@_MI2_log = external hidden global %struct.anon.0, align 8
@mierror_table = external hidden global [109 x %struct.mierror_entry], align 16
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [2 x i8], align 1

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

declare i32 @fflush(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

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

15:                                               ; preds = %4
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  store ptr %16, ptr getelementptr inbounds (%struct.anon.0, ptr @_MI2_log, i32 0, i32 2), align 8, !tbaa !11
  br label %17

17:                                               ; preds = %15, %4
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = sub i32 %18, 10000
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds [109 x %struct.mierror_entry], ptr @mierror_table, i64 0, i64 %20
  %22 = getelementptr inbounds %struct.mierror_entry, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 16, !tbaa !13
  store i32 %23, ptr %10, align 4, !tbaa !9
  %24 = load i32, ptr %8, align 4, !tbaa !9
  %25 = sub i32 %24, 10000
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds [109 x %struct.mierror_entry], ptr @mierror_table, i64 0, i64 %26
  %28 = getelementptr inbounds %struct.mierror_entry, ptr %27, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  store ptr %29, ptr %11, align 8, !tbaa !5
  %30 = load i32, ptr %10, align 4, !tbaa !9
  %31 = load i32, ptr @_MI2_log, align 8, !tbaa !16
  %32 = icmp sle i32 %30, %31
  br i1 %32, label %36, label %33

33:                                               ; preds = %17
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %60

36:                                               ; preds = %33, %17
  %37 = load i8, ptr getelementptr inbounds (%struct.anon.0, ptr @_MI2_log, i32 0, i32 1), align 4, !tbaa !17
  %38 = sext i8 %37 to i32
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %45

40:                                               ; preds = %36
  %41 = load ptr, ptr getelementptr inbounds (%struct.anon.0, ptr @_MI2_log, i32 0, i32 2), align 8, !tbaa !11
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef @.str.10, ptr noundef %42, i32 noundef %43, ptr noundef getelementptr inbounds (%struct.anon.0, ptr @_MI2_log, i32 0, i32 1)) #5
  br label %45

45:                                               ; preds = %40, %36
  %46 = load ptr, ptr getelementptr inbounds (%struct.anon.0, ptr @_MI2_log, i32 0, i32 2), align 8, !tbaa !11
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = load i32, ptr %7, align 4, !tbaa !9
  %49 = load ptr, ptr @minc_routine_name, align 8, !tbaa !5
  %50 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef @.str.11, ptr noundef %47, i32 noundef %48, ptr noundef %49) #5
  %51 = load ptr, ptr getelementptr inbounds (%struct.anon.0, ptr @_MI2_log, i32 0, i32 2), align 8, !tbaa !11
  %52 = load ptr, ptr %11, align 8, !tbaa !5
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = call i32 @vfprintf(ptr noundef %51, ptr noundef %52, ptr noundef %53) #5
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.va_end.p0(ptr %55)
  %56 = load ptr, ptr getelementptr inbounds (%struct.anon.0, ptr @_MI2_log, i32 0, i32 2), align 8, !tbaa !11
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef @.str.12) #5
  %58 = load ptr, ptr getelementptr inbounds (%struct.anon.0, ptr @_MI2_log, i32 0, i32 2), align 8, !tbaa !11
  %59 = call i32 @fflush(ptr noundef %58)
  br label %60

60:                                               ; preds = %45, %33
  %61 = load i32, ptr %10, align 4, !tbaa !9
  %62 = icmp eq i32 %61, 0
  br i1 %62, label %63, label %64

63:                                               ; preds = %60
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %65

64:                                               ; preds = %60
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %65

65:                                               ; preds = %64, %63
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %66 = load i32, ptr %5, align 4
  ret i32 %66
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.va_end.p0(ptr) #4

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

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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind willreturn }
attributes #5 = { 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, !6, i64 136}
!12 = !{!"", !10, i64 0, !7, i64 4, !6, i64 136}
!13 = !{!14, !10, i64 0}
!14 = !{!"mierror_entry", !10, i64 0, !6, i64 8}
!15 = !{!14, !6, i64 8}
!16 = !{!12, !10, i64 0}
!17 = !{!7, !7, 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.anon.0 = type { i32, [128 x i8], ptr }
%struct.mierror_entry = type { i32, ptr }

@minc_routine_name = external hidden local_unnamed_addr global ptr, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@_MI2_log = external hidden global %struct.anon.0, align 8
@mierror_table = external hidden local_unnamed_addr global [109 x %struct.mierror_entry], align 16
@.str.10 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [2 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: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local noundef i32 @v_mi2log_message(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = load ptr, ptr getelementptr inbounds (i8, ptr @_MI2_log, i64 136), align 8, !tbaa !5
  %6 = icmp eq ptr %5, null
  br i1 %6, label %7, label %9

7:                                                ; preds = %4
  %8 = load ptr, ptr @stderr, align 8, !tbaa !11
  store ptr %8, ptr getelementptr inbounds (i8, ptr @_MI2_log, i64 136), align 8, !tbaa !5
  br label %9

9:                                                ; preds = %7, %4
  %10 = phi ptr [ %8, %7 ], [ %5, %4 ]
  %11 = add i32 %2, -10000
  %12 = zext i32 %11 to i64
  %13 = getelementptr inbounds [109 x %struct.mierror_entry], ptr @mierror_table, i64 0, i64 %12
  %14 = load i32, ptr %13, align 16, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %13, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  %17 = load i32, ptr @_MI2_log, align 8, !tbaa !15
  %18 = icmp sle i32 %14, %17
  %19 = icmp eq i32 %14, 0
  %or.cond = or i1 %19, %18
  br i1 %or.cond, label %20, label %34

20:                                               ; preds = %9
  %21 = load i8, ptr getelementptr inbounds (i8, ptr @_MI2_log, i64 4), align 4, !tbaa !16
  %.not = icmp eq i8 %21, 0
  br i1 %.not, label %24, label %22

22:                                               ; preds = %20
  %23 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.10, ptr noundef %0, i32 noundef %1, ptr noundef nonnull getelementptr inbounds (i8, ptr @_MI2_log, i64 4)) #3
  %.pre = load ptr, ptr getelementptr inbounds (i8, ptr @_MI2_log, i64 136), align 8, !tbaa !5
  br label %24

24:                                               ; preds = %22, %20
  %25 = phi ptr [ %.pre, %22 ], [ %10, %20 ]
  %26 = load ptr, ptr @minc_routine_name, align 8, !tbaa !11
  %27 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str.11, ptr noundef %0, i32 noundef %1, ptr noundef %26) #3
  %28 = load ptr, ptr getelementptr inbounds (i8, ptr @_MI2_log, i64 136), align 8, !tbaa !5
  %29 = tail call i32 @vfprintf(ptr noundef %28, ptr noundef %16, ptr noundef %3) #3
  tail call void @llvm.va_end.p0(ptr %3)
  %30 = load ptr, ptr getelementptr inbounds (i8, ptr @_MI2_log, i64 136), align 8, !tbaa !5
  %31 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.12) #3
  %32 = load ptr, ptr getelementptr inbounds (i8, ptr @_MI2_log, i64 136), align 8, !tbaa !5
  %33 = tail call i32 @fflush(ptr noundef %32)
  br label %34

34:                                               ; preds = %24, %9
  ret i32 -1
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.va_end.p0(ptr) #2

; Function Attrs: nofree nounwind
declare noundef i32 @vfprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ptr noundef) local_unnamed_addr #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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #3 = { 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, !10, i64 136}
!6 = !{!"", !7, i64 0, !8, i64 4, !10, i64 136}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"mierror_entry", !7, i64 0, !10, i64 8}
!14 = !{!13, !10, i64 8}
!15 = !{!6, !7, i64 0}
!16 = !{!8, !8, i64 0}


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