; LLVM IR from lichen-community-systems/signaletic :: libsignaletic/tests/vendor/unity/src (unity)

; 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"

; 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: inlinehint nounwind uwtable
declare i32 @putchar(i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @UnityPrintNumberHex(i64 noundef %0, i8 noundef signext %1) #2 {
  %3 = alloca i64, align 8
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  store i64 %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  %7 = load i8, ptr %4, align 1, !tbaa !9
  store i8 %7, ptr %6, align 1, !tbaa !9
  %8 = load i8, ptr %6, align 1, !tbaa !9
  %9 = sext i8 %8 to i32
  %10 = icmp ugt i32 %9, 16
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  store i8 16, ptr %6, align 1, !tbaa !9
  br label %12

12:                                               ; preds = %11, %2
  br label %13

13:                                               ; preds = %42, %12
  %14 = load i8, ptr %6, align 1, !tbaa !9
  %15 = sext i8 %14 to i32
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %17, label %43

17:                                               ; preds = %13
  %18 = load i8, ptr %6, align 1, !tbaa !9
  %19 = add i8 %18, -1
  store i8 %19, ptr %6, align 1, !tbaa !9
  %20 = load i64, ptr %3, align 8, !tbaa !5
  %21 = load i8, ptr %6, align 1, !tbaa !9
  %22 = sext i8 %21 to i32
  %23 = mul nsw i32 %22, 4
  %24 = zext i32 %23 to i64
  %25 = lshr i64 %20, %24
  %26 = trunc i64 %25 to i32
  %27 = and i32 %26, 15
  store i32 %27, ptr %5, align 4, !tbaa !10
  %28 = load i32, ptr %5, align 4, !tbaa !10
  %29 = icmp sle i32 %28, 9
  br i1 %29, label %30, label %36

30:                                               ; preds = %17
  %31 = load i32, ptr %5, align 4, !tbaa !10
  %32 = add nsw i32 48, %31
  %33 = trunc i32 %32 to i8
  %34 = sext i8 %33 to i32
  %35 = call i32 @putchar(i32 noundef %34)
  br label %42

36:                                               ; preds = %17
  %37 = load i32, ptr %5, align 4, !tbaa !10
  %38 = add nsw i32 55, %37
  %39 = trunc i32 %38 to i8
  %40 = sext i8 %39 to i32
  %41 = call i32 @putchar(i32 noundef %40)
  br label %42

42:                                               ; preds = %36, %30
  br label %13, !llvm.loop !12

43:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 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 }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !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"

; Function Attrs: inlinehint nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local void @UnityPrintNumberHex(i64 noundef %0, i8 noundef signext %1) local_unnamed_addr #1 {
  %.not = icmp eq i8 %1, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %3 = tail call i8 @llvm.umin.i8(i8 %1, i8 16)
  %umin = zext nneg i8 %3 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %umin, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %4 = shl nuw nsw i64 %indvars.iv.next, 2
  %5 = lshr i64 %0, %4
  %6 = trunc i64 %5 to i32
  %7 = and i32 %6, 15
  %8 = icmp ult i32 %7, 10
  %9 = add nuw nsw i32 %7, 55
  %10 = or disjoint i32 %7, 48
  %.sink = select i1 %8, i32 %10, i32 %9
  %11 = tail call i32 @putchar(i32 noundef %.sink)
  %12 = icmp ugt i64 %indvars.iv, 1
  br i1 %12, label %.lr.ph, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %2
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i8 @llvm.umin.i8(i8, i8) #2

attributes #0 = { inlinehint 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass