; LLVM IR from bnidia/push_swap :: libraries/libft (ft_printf_u)

; 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.s_pf = type { ptr, i32, [1024 x i8], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ft_u(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = call i32 @for_zero_put_empty_string(ptr noundef %9, i32 noundef %10)
  %12 = icmp sle i32 %11, 0
  br i1 %12, label %13, label %17

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.s_pf, ptr %14, i32 0, i32 12
  %16 = load i32, ptr %15, align 8, !tbaa !11
  store i32 %16, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %88

17:                                               ; preds = %2
  store i32 0, ptr %7, align 4, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.s_pf, ptr %18, i32 0, i32 8
  %20 = load i32, ptr %19, align 8, !tbaa !13
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %25

22:                                               ; preds = %17
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %7, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %22, %17
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = uitofp i32 %26 to double
  %28 = call double @ft_abs_d(double noundef %27)
  %29 = fptoui double %28 to i64
  %30 = call i64 @ft_numlen(i64 noundef %29, i32 noundef 10)
  %31 = trunc i64 %30 to i32
  store i32 %31, ptr %6, align 4, !tbaa !9
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load i32, ptr %7, align 4, !tbaa !9
  call void @reset_insignificant_values(ptr noundef %32, i32 noundef %33)
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = call i32 @output_of_initial_spaces(ptr noundef %34, i32 noundef %35, i32 noundef %36)
  %38 = icmp eq i32 %37, -1
  br i1 %38, label %39, label %40

39:                                               ; preds = %25
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %88

40:                                               ; preds = %25
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.s_pf, ptr %41, i32 0, i32 8
  %43 = load i32, ptr %42, align 8, !tbaa !13
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %54

45:                                               ; preds = %40
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.s_pf, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.s_pf, ptr %48, i32 0, i32 3
  %50 = load i32, ptr %49, align 4, !tbaa !14
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %49, align 4, !tbaa !14
  %52 = sext i32 %50 to i64
  %53 = getelementptr inbounds [1024 x i8], ptr %47, i64 0, i64 %52
  store i8 43, ptr %53, align 1, !tbaa !15
  br label %54

54:                                               ; preds = %45, %40
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = call i32 @output_of_zeros(ptr noundef %55, i32 noundef %56, i32 noundef %57)
  %59 = icmp eq i32 %58, -1
  br i1 %59, label %60, label %61

60:                                               ; preds = %54
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %88

61:                                               ; preds = %54
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.s_pf, ptr %62, i32 0, i32 10
  %64 = load i32, ptr %63, align 8, !tbaa !16
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %75

66:                                               ; preds = %61
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.s_pf, ptr %67, i32 0, i32 2
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.s_pf, ptr %69, i32 0, i32 3
  %71 = load i32, ptr %70, align 4, !tbaa !14
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %70, align 4, !tbaa !14
  %73 = sext i32 %71 to i64
  %74 = getelementptr inbounds [1024 x i8], ptr %68, i64 0, i64 %73
  store i8 32, ptr %74, align 1, !tbaa !15
  br label %75

75:                                               ; preds = %66, %61
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = load i32, ptr %5, align 4, !tbaa !9
  %78 = uitofp i32 %77 to double
  %79 = call double @ft_abs_d(double noundef %78)
  %80 = fptoui double %79 to i64
  call void @ft_itoa_base(ptr noundef %76, i64 noundef %80, i32 noundef 10, ptr noundef @.str)
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = load i32, ptr %6, align 4, !tbaa !9
  %83 = load i32, ptr %7, align 4, !tbaa !9
  %84 = call i32 @output_of_finite_spaces(ptr noundef %81, i32 noundef %82, i32 noundef %83)
  %85 = icmp eq i32 %84, -1
  br i1 %85, label %86, label %87

86:                                               ; preds = %75
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %88

87:                                               ; preds = %75
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %88

88:                                               ; preds = %87, %86, %60, %39, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %89 = load i32, ptr %3, align 4
  ret i32 %89
}

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

declare i32 @for_zero_put_empty_string(ptr noundef, i32 noundef) #2

declare i64 @ft_numlen(i64 noundef, i32 noundef) #2

declare double @ft_abs_d(double noundef) #2

declare void @reset_insignificant_values(ptr noundef, i32 noundef) #2

declare i32 @output_of_initial_spaces(ptr noundef, i32 noundef, i32 noundef) #2

declare i32 @output_of_zeros(ptr noundef, i32 noundef, i32 noundef) #2

declare void @ft_itoa_base(ptr noundef, i64 noundef, i32 noundef, ptr noundef) #2

declare i32 @output_of_finite_spaces(ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = !{!"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 1072}
!12 = !{!"s_pf", !6, i64 0, !10, i64 8, !7, i64 12, !10, i64 1036, !10, i64 1040, !10, i64 1044, !10, i64 1048, !10, i64 1052, !10, i64 1056, !10, i64 1060, !10, i64 1064, !10, i64 1068, !10, i64 1072}
!13 = !{!12, !10, i64 1056}
!14 = !{!12, !10, i64 1036}
!15 = !{!7, !7, i64 0}
!16 = !{!12, !10, i64 1064}


; 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 [11 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @ft_u(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = tail call i32 @for_zero_put_empty_string(ptr noundef %0, i32 noundef %1) #2
  %4 = icmp slt i32 %3, 1
  br i1 %4, label %5, label %8

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 1072
  %7 = load i32, ptr %6, align 8, !tbaa !5
  br label %45

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %0, i64 1056
  %10 = load i32, ptr %9, align 8, !tbaa !11
  %.not = icmp ne i32 %10, 0
  %spec.select = zext i1 %.not to i32
  %11 = uitofp i32 %1 to double
  %12 = tail call double @ft_abs_d(double noundef %11) #2
  %13 = fptoui double %12 to i64
  %14 = tail call i64 @ft_numlen(i64 noundef %13, i32 noundef 10) #2
  %15 = trunc i64 %14 to i32
  tail call void @reset_insignificant_values(ptr noundef %0, i32 noundef %spec.select) #2
  %16 = tail call i32 @output_of_initial_spaces(ptr noundef %0, i32 noundef %15, i32 noundef %spec.select) #2
  %17 = icmp eq i32 %16, -1
  br i1 %17, label %45, label %18

18:                                               ; preds = %8
  %19 = load i32, ptr %9, align 8, !tbaa !11
  %.not26 = icmp eq i32 %19, 0
  br i1 %.not26, label %27, label %20

20:                                               ; preds = %18
  %21 = getelementptr inbounds i8, ptr %0, i64 12
  %22 = getelementptr inbounds i8, ptr %0, i64 1036
  %23 = load i32, ptr %22, align 4, !tbaa !12
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %22, align 4, !tbaa !12
  %25 = sext i32 %23 to i64
  %26 = getelementptr inbounds [1024 x i8], ptr %21, i64 0, i64 %25
  store i8 43, ptr %26, align 1, !tbaa !13
  br label %27

27:                                               ; preds = %20, %18
  %28 = tail call i32 @output_of_zeros(ptr noundef nonnull %0, i32 noundef %15, i32 noundef %spec.select) #2
  %29 = icmp eq i32 %28, -1
  br i1 %29, label %45, label %30

30:                                               ; preds = %27
  %31 = getelementptr inbounds i8, ptr %0, i64 1064
  %32 = load i32, ptr %31, align 8, !tbaa !14
  %.not27 = icmp eq i32 %32, 0
  br i1 %.not27, label %40, label %33

33:                                               ; preds = %30
  %34 = getelementptr inbounds i8, ptr %0, i64 12
  %35 = getelementptr inbounds i8, ptr %0, i64 1036
  %36 = load i32, ptr %35, align 4, !tbaa !12
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %35, align 4, !tbaa !12
  %38 = sext i32 %36 to i64
  %39 = getelementptr inbounds [1024 x i8], ptr %34, i64 0, i64 %38
  store i8 32, ptr %39, align 1, !tbaa !13
  br label %40

40:                                               ; preds = %33, %30
  %41 = tail call double @ft_abs_d(double noundef %11) #2
  %42 = fptoui double %41 to i64
  tail call void @ft_itoa_base(ptr noundef nonnull %0, i64 noundef %42, i32 noundef 10, ptr noundef nonnull @.str) #2
  %43 = tail call i32 @output_of_finite_spaces(ptr noundef nonnull %0, i32 noundef %15, i32 noundef %spec.select) #2
  %44 = icmp eq i32 %43, -1
  %. = sext i1 %44 to i32
  br label %45

45:                                               ; preds = %40, %27, %8, %5
  %.025 = phi i32 [ %7, %5 ], [ -1, %8 ], [ -1, %27 ], [ %., %40 ]
  ret i32 %.025
}

declare i32 @for_zero_put_empty_string(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i64 @ft_numlen(i64 noundef, i32 noundef) local_unnamed_addr #1

declare double @ft_abs_d(double noundef) local_unnamed_addr #1

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

declare i32 @output_of_initial_spaces(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare i32 @output_of_zeros(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

declare i32 @output_of_finite_spaces(ptr noundef, i32 noundef, 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)"}
!5 = !{!6, !10, i64 1072}
!6 = !{!"s_pf", !7, i64 0, !10, i64 8, !8, i64 12, !10, i64 1036, !10, i64 1040, !10, i64 1044, !10, i64 1048, !10, i64 1052, !10, i64 1056, !10, i64 1060, !10, i64 1064, !10, i64 1068, !10, i64 1072}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 1056}
!12 = !{!6, !10, i64 1036}
!13 = !{!8, !8, i64 0}
!14 = !{!6, !10, i64 1064}


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