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

; 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_d(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 %109

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 %25, label %22

22:                                               ; preds = %17
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = icmp slt i32 %23, 0
  br i1 %24, label %25, label %28

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

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

42:                                               ; preds = %28
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %109

43:                                               ; preds = %28
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = icmp slt i32 %44, 0
  br i1 %45, label %46, label %55

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

55:                                               ; preds = %46, %43
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.s_pf, ptr %56, i32 0, i32 8
  %58 = load i32, ptr %57, align 8, !tbaa !13
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %72

60:                                               ; preds = %55
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = icmp sge i32 %61, 0
  br i1 %62, label %63, label %72

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

72:                                               ; preds = %63, %60, %55
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = load i32, ptr %6, align 4, !tbaa !9
  %75 = load i32, ptr %7, align 4, !tbaa !9
  %76 = call i32 @output_of_zeros(ptr noundef %73, i32 noundef %74, i32 noundef %75)
  %77 = icmp eq i32 %76, -1
  br i1 %77, label %78, label %79

78:                                               ; preds = %72
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %109

79:                                               ; preds = %72
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.s_pf, ptr %80, i32 0, i32 10
  %82 = load i32, ptr %81, align 8, !tbaa !16
  %83 = icmp ne i32 %82, 0
  br i1 %83, label %84, label %96

84:                                               ; preds = %79
  %85 = load i32, ptr %5, align 4, !tbaa !9
  %86 = icmp sge i32 %85, 0
  br i1 %86, label %87, label %96

87:                                               ; preds = %84
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.s_pf, ptr %88, i32 0, i32 2
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.s_pf, ptr %90, i32 0, i32 3
  %92 = load i32, ptr %91, align 4, !tbaa !14
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %91, align 4, !tbaa !14
  %94 = sext i32 %92 to i64
  %95 = getelementptr inbounds [1024 x i8], ptr %89, i64 0, i64 %94
  store i8 32, ptr %95, align 1, !tbaa !15
  br label %96

96:                                               ; preds = %87, %84, %79
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = load i32, ptr %5, align 4, !tbaa !9
  %99 = sitofp i32 %98 to double
  %100 = call double @ft_abs_d(double noundef %99)
  %101 = fptoui double %100 to i64
  call void @ft_itoa_base(ptr noundef %97, i64 noundef %101, i32 noundef 10, ptr noundef @.str)
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = load i32, ptr %6, align 4, !tbaa !9
  %104 = load i32, ptr %7, align 4, !tbaa !9
  %105 = call i32 @output_of_finite_spaces(ptr noundef %102, i32 noundef %103, i32 noundef %104)
  %106 = icmp eq i32 %105, -1
  br i1 %106, label %107, label %108

107:                                              ; preds = %96
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %109

108:                                              ; preds = %96
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %109

109:                                              ; preds = %108, %107, %78, %42, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %110 = load i32, ptr %3, align 4
  ret i32 %110
}

; 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_d(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 %48

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

20:                                               ; preds = %8
  br i1 %12, label %.sink.split, label %21

21:                                               ; preds = %20
  %22 = load i32, ptr %9, align 8, !tbaa !11
  %.not = icmp eq i32 %22, 0
  br i1 %.not, label %29, label %.sink.split

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

29:                                               ; preds = %.sink.split, %21
  %30 = tail call i32 @output_of_zeros(ptr noundef nonnull %0, i32 noundef %17, i32 noundef %spec.select) #2
  %31 = icmp eq i32 %30, -1
  br i1 %31, label %48, label %32

32:                                               ; preds = %29
  %33 = getelementptr inbounds i8, ptr %0, i64 1064
  %34 = load i32, ptr %33, align 8, !tbaa !14
  %35 = icmp eq i32 %34, 0
  %or.cond5.not = or i1 %12, %35
  br i1 %or.cond5.not, label %43, label %36

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

43:                                               ; preds = %36, %32
  %44 = tail call double @ft_abs_d(double noundef %13) #2
  %45 = fptoui double %44 to i64
  tail call void @ft_itoa_base(ptr noundef nonnull %0, i64 noundef %45, i32 noundef 10, ptr noundef nonnull @.str) #2
  %46 = tail call i32 @output_of_finite_spaces(ptr noundef nonnull %0, i32 noundef %17, i32 noundef %spec.select) #2
  %47 = icmp eq i32 %46, -1
  %. = sext i1 %47 to i32
  br label %48

48:                                               ; preds = %43, %29, %8, %5
  %.036 = phi i32 [ %7, %5 ], [ -1, %8 ], [ -1, %29 ], [ %., %43 ]
  ret i32 %.036
}

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,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass