; LLVM IR from nde-jesu/Doom_Nukem :: libft/srcs/display (ft_putnbr_fd)

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

@.str = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @ft_putnbr_fd(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  %5 = load i32, ptr %3, align 4, !tbaa !5
  %6 = icmp slt i32 %5, 0
  br i1 %6, label %7, label %16

7:                                                ; preds = %2
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = icmp eq i32 %8, -2147483648
  br i1 %9, label %10, label %12

10:                                               ; preds = %7
  %11 = load i32, ptr %4, align 4, !tbaa !5
  call void @ft_putstr_fd(ptr noundef @.str, i32 noundef %11)
  br label %31

12:                                               ; preds = %7
  %13 = load i32, ptr %4, align 4, !tbaa !5
  call void @ft_putchar_fd(i8 noundef signext 45, i32 noundef %13)
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = sub nsw i32 0, %14
  store i32 %15, ptr %3, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %12, %2
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = icmp sge i32 %17, 10
  br i1 %18, label %19, label %26

19:                                               ; preds = %16
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = sdiv i32 %20, 10
  %22 = load i32, ptr %4, align 4, !tbaa !5
  call void @ft_putnbr_fd(i32 noundef %21, i32 noundef %22)
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = srem i32 %23, 10
  %25 = load i32, ptr %4, align 4, !tbaa !5
  call void @ft_putnbr_fd(i32 noundef %24, i32 noundef %25)
  br label %31

26:                                               ; preds = %16
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = add nsw i32 %27, 48
  %29 = trunc i32 %28 to i8
  %30 = load i32, ptr %4, align 4, !tbaa !5
  call void @ft_putchar_fd(i8 noundef signext %29, i32 noundef %30)
  br label %31

31:                                               ; preds = %26, %19, %10
  ret void
}

declare void @ft_putstr_fd(ptr noundef, i32 noundef) #1

declare void @ft_putchar_fd(i8 noundef signext, i32 noundef) #1

attributes #0 = { 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 = { "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" }

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


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

@.str = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @ft_putnbr_fd(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  br label %tailrecurse

tailrecurse:                                      ; preds = %11, %2
  %.tr = phi i32 [ %0, %2 ], [ %13, %11 ]
  %3 = icmp slt i32 %.tr, 0
  br i1 %3, label %4, label %9

4:                                                ; preds = %tailrecurse
  %5 = icmp eq i32 %.tr, -2147483648
  br i1 %5, label %6, label %7

6:                                                ; preds = %4
  tail call void @ft_putstr_fd(ptr noundef nonnull @.str, i32 noundef %1) #2
  br label %17

7:                                                ; preds = %4
  tail call void @ft_putchar_fd(i8 noundef signext 45, i32 noundef %1) #2
  %8 = sub nsw i32 0, %.tr
  br label %9

9:                                                ; preds = %7, %tailrecurse
  %.0 = phi i32 [ %8, %7 ], [ %.tr, %tailrecurse ]
  %10 = icmp ugt i32 %.0, 9
  br i1 %10, label %11, label %14

11:                                               ; preds = %9
  %12 = udiv i32 %.0, 10
  tail call void @ft_putnbr_fd(i32 noundef %12, i32 noundef %1)
  %13 = urem i32 %.0, 10
  br label %tailrecurse

14:                                               ; preds = %9
  %15 = trunc nuw i32 %.0 to i8
  %16 = or disjoint i8 %15, 48
  tail call void @ft_putchar_fd(i8 noundef signext %16, i32 noundef %1) #2
  br label %17

17:                                               ; preds = %14, %6
  ret void
}

declare void @ft_putstr_fd(ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @ft_putchar_fd(i8 noundef signext, i32 noundef) local_unnamed_addr #1

attributes #0 = { 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 = { "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)"}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,SROAPass,TailCallElimPass