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

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

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

15:                                               ; preds = %3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.s_pf, ptr %16, i32 0, i32 6
  %18 = load i32, ptr %17, align 8, !tbaa !13
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %21, label %29

21:                                               ; preds = %15, %3
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.s_pf, ptr %22, i32 0, i32 5
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = sub nsw i32 %24, %25
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = sub nsw i32 %26, %27
  store i32 %28, ptr %8, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %21, %15
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.s_pf, ptr %30, i32 0, i32 5
  %32 = load i32, ptr %31, align 4, !tbaa !11
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.s_pf, ptr %33, i32 0, i32 6
  %35 = load i32, ptr %34, align 8, !tbaa !13
  %36 = icmp sgt i32 %32, %35
  br i1 %36, label %37, label %53

37:                                               ; preds = %29
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.s_pf, ptr %38, i32 0, i32 6
  %40 = load i32, ptr %39, align 8, !tbaa !13
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = icmp sgt i32 %40, %41
  br i1 %42, label %43, label %53

43:                                               ; preds = %37
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.s_pf, ptr %44, i32 0, i32 5
  %46 = load i32, ptr %45, align 4, !tbaa !11
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.s_pf, ptr %47, i32 0, i32 6
  %49 = load i32, ptr %48, align 8, !tbaa !13
  %50 = sub nsw i32 %46, %49
  %51 = load i32, ptr %7, align 4, !tbaa !9
  %52 = sub nsw i32 %50, %51
  store i32 %52, ptr %8, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %43, %37, %29
  br label %54

54:                                               ; preds = %78, %53
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = icmp sgt i32 %55, 0
  br i1 %56, label %57, label %63

57:                                               ; preds = %54
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.s_pf, ptr %58, i32 0, i32 7
  %60 = load i32, ptr %59, align 4, !tbaa !14
  %61 = icmp ne i32 %60, 0
  %62 = xor i1 %61, true
  br label %63

63:                                               ; preds = %57, %54
  %64 = phi i1 [ false, %54 ], [ %62, %57 ]
  br i1 %64, label %65, label %81

65:                                               ; preds = %63
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.s_pf, ptr %66, i32 0, i32 2
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.s_pf, ptr %68, i32 0, i32 3
  %70 = load i32, ptr %69, align 4, !tbaa !15
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %69, align 4, !tbaa !15
  %72 = sext i32 %70 to i64
  %73 = getelementptr inbounds [1024 x i8], ptr %67, i64 0, i64 %72
  store i8 32, ptr %73, align 1, !tbaa !16
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = call i32 @ft_print_out(ptr noundef %74)
  %76 = icmp eq i32 %75, -1
  br i1 %76, label %77, label %78

77:                                               ; preds = %65
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %82

78:                                               ; preds = %65
  %79 = load i32, ptr %8, align 4, !tbaa !9
  %80 = add nsw i32 %79, -1
  store i32 %80, ptr %8, align 4, !tbaa !9
  br label %54, !llvm.loop !17

81:                                               ; preds = %63
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %82

82:                                               ; preds = %81, %77
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %83 = load i32, ptr %4, align 4
  ret i32 %83
}

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

declare i32 @ft_print_out(ptr 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 1044}
!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 1048}
!14 = !{!12, !10, i64 1052}
!15 = !{!12, !10, i64 1036}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @output_of_initial_spaces(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 1044
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, %1
  %.phi.trans.insert.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 1048
  %.pre.pre = load i32, ptr %.phi.trans.insert.phi.trans.insert, align 8, !tbaa !11
  %7 = icmp slt i32 %.pre.pre, %1
  %or.cond34 = or i1 %6, %7
  %8 = add i32 %2, %1
  %9 = sub i32 %5, %8
  %.0 = select i1 %or.cond34, i32 %9, i32 0
  %10 = icmp sgt i32 %5, %.pre.pre
  %11 = icmp sgt i32 %.pre.pre, %1
  %or.cond = and i1 %10, %11
  %12 = add i32 %.pre.pre, %2
  %13 = sub i32 %5, %12
  %.1 = select i1 %or.cond, i32 %13, i32 %.0
  %14 = getelementptr inbounds i8, ptr %0, i64 1052
  %15 = getelementptr inbounds i8, ptr %0, i64 12
  %16 = getelementptr inbounds i8, ptr %0, i64 1036
  %17 = icmp sgt i32 %.1, 0
  br i1 %17, label %.lr.ph, label %.critedge

18:                                               ; preds = %22
  %19 = add nsw i32 %.228, -1
  %20 = icmp sgt i32 %.228, 1
  br i1 %20, label %.lr.ph, label %.critedge, !llvm.loop !12

.lr.ph:                                           ; preds = %3, %18
  %.228 = phi i32 [ %19, %18 ], [ %.1, %3 ]
  %21 = load i32, ptr %14, align 4, !tbaa !14
  %.not = icmp eq i32 %21, 0
  br i1 %.not, label %22, label %.critedge

22:                                               ; preds = %.lr.ph
  %23 = load i32, ptr %16, align 4, !tbaa !15
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %16, align 4, !tbaa !15
  %25 = sext i32 %23 to i64
  %26 = getelementptr inbounds [1024 x i8], ptr %15, i64 0, i64 %25
  store i8 32, ptr %26, align 1, !tbaa !16
  %27 = tail call i32 @ft_print_out(ptr noundef nonnull %0) #2
  %28 = icmp eq i32 %27, -1
  br i1 %28, label %.critedge, label %18

.critedge:                                        ; preds = %22, %18, %.lr.ph, %3
  %.020 = phi i32 [ 0, %3 ], [ 0, %.lr.ph ], [ 0, %18 ], [ -1, %22 ]
  ret i32 %.020
}

declare i32 @ft_print_out(ptr 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 1044}
!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 1048}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!6, !10, i64 1052}
!15 = !{!6, !10, i64 1036}
!16 = !{!8, !8, i64 0}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass