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

; 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 @ft_c(ptr noundef %0, i8 noundef signext %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !9
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.s_pf, ptr %6, i32 0, i32 7
  %8 = load i32, ptr %7, align 4, !tbaa !10
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %37

10:                                               ; preds = %2
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.s_pf, ptr %11, i32 0, i32 5
  %13 = load i32, ptr %12, align 4, !tbaa !13
  %14 = icmp sgt i32 %13, 1
  br i1 %14, label %15, label %37

15:                                               ; preds = %10
  br label %16

16:                                               ; preds = %35, %15
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.s_pf, ptr %17, i32 0, i32 5
  %19 = load i32, ptr %18, align 4, !tbaa !13
  %20 = add nsw i32 %19, -1
  store i32 %20, ptr %18, align 4, !tbaa !13
  %21 = icmp sgt i32 %19, 1
  br i1 %21, label %22, label %36

22:                                               ; preds = %16
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.s_pf, ptr %23, i32 0, i32 2
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.s_pf, ptr %25, i32 0, i32 3
  %27 = load i32, ptr %26, align 4, !tbaa !14
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %26, align 4, !tbaa !14
  %29 = sext i32 %27 to i64
  %30 = getelementptr inbounds [1024 x i8], ptr %24, i64 0, i64 %29
  store i8 32, ptr %30, align 1, !tbaa !9
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = call i32 @ft_print_out(ptr noundef %31)
  %33 = icmp eq i32 %32, -1
  br i1 %33, label %34, label %35

34:                                               ; preds = %22
  store i32 -1, ptr %3, align 4
  br label %84

35:                                               ; preds = %22
  br label %16, !llvm.loop !15

36:                                               ; preds = %16
  br label %37

37:                                               ; preds = %36, %10, %2
  %38 = load i8, ptr %5, align 1, !tbaa !9
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.s_pf, ptr %39, i32 0, i32 2
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.s_pf, ptr %41, i32 0, i32 3
  %43 = load i32, ptr %42, align 4, !tbaa !14
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %42, align 4, !tbaa !14
  %45 = sext i32 %43 to i64
  %46 = getelementptr inbounds [1024 x i8], ptr %40, i64 0, i64 %45
  store i8 %38, ptr %46, align 1, !tbaa !9
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = call i32 @ft_print_out(ptr noundef %47)
  %49 = icmp eq i32 %48, -1
  br i1 %49, label %50, label %51

50:                                               ; preds = %37
  store i32 -1, ptr %3, align 4
  br label %84

51:                                               ; preds = %37
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.s_pf, ptr %52, i32 0, i32 7
  %54 = load i32, ptr %53, align 4, !tbaa !10
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %83

56:                                               ; preds = %51
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.s_pf, ptr %57, i32 0, i32 5
  %59 = load i32, ptr %58, align 4, !tbaa !13
  %60 = icmp sgt i32 %59, 1
  br i1 %60, label %61, label %83

61:                                               ; preds = %56
  br label %62

62:                                               ; preds = %81, %61
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.s_pf, ptr %63, i32 0, i32 5
  %65 = load i32, ptr %64, align 4, !tbaa !13
  %66 = add nsw i32 %65, -1
  store i32 %66, ptr %64, align 4, !tbaa !13
  %67 = icmp sgt i32 %65, 1
  br i1 %67, label %68, label %82

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

80:                                               ; preds = %68
  store i32 -1, ptr %3, align 4
  br label %84

81:                                               ; preds = %68
  br label %62, !llvm.loop !17

82:                                               ; preds = %62
  br label %83

83:                                               ; preds = %82, %56, %51
  store i32 0, ptr %3, align 4
  br label %84

84:                                               ; preds = %83, %80, %50, %34
  %85 = load i32, ptr %3, align 4
  ret i32 %85
}

declare i32 @ft_print_out(ptr 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 1052}
!11 = !{!"s_pf", !6, i64 0, !12, i64 8, !7, i64 12, !12, i64 1036, !12, i64 1040, !12, i64 1044, !12, i64 1048, !12, i64 1052, !12, i64 1056, !12, i64 1060, !12, i64 1064, !12, i64 1068, !12, i64 1072}
!12 = !{!"int", !7, i64 0}
!13 = !{!11, !12, i64 1044}
!14 = !{!11, !12, i64 1036}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 @ft_c(ptr noundef %0, i8 noundef signext %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 1052
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %6, label %.loopexit19

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 1044
  %8 = load i32, ptr %7, align 4, !tbaa !11
  %9 = icmp sgt i32 %8, 1
  br i1 %9, label %.preheader18, label %.loopexit19

.preheader18:                                     ; preds = %6
  %10 = add nsw i32 %8, -1
  store i32 %10, ptr %7, align 4, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %0, i64 12
  %12 = getelementptr inbounds i8, ptr %0, i64 1036
  br label %15

thread-pre-split:                                 ; preds = %15
  %.pr = load i32, ptr %7, align 4, !tbaa !11
  %13 = add nsw i32 %.pr, -1
  store i32 %13, ptr %7, align 4, !tbaa !11
  %14 = icmp sgt i32 %.pr, 1
  br i1 %14, label %15, label %.loopexit19

15:                                               ; preds = %.preheader18, %thread-pre-split
  %16 = load i32, ptr %12, align 4, !tbaa !12
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %12, align 4, !tbaa !12
  %18 = sext i32 %16 to i64
  %19 = getelementptr inbounds [1024 x i8], ptr %11, i64 0, i64 %18
  store i8 32, ptr %19, align 1, !tbaa !13
  %20 = tail call i32 @ft_print_out(ptr noundef nonnull %0) #2
  %21 = icmp eq i32 %20, -1
  br i1 %21, label %.loopexit, label %thread-pre-split, !llvm.loop !14

.loopexit19:                                      ; preds = %thread-pre-split, %6, %2
  %22 = getelementptr inbounds i8, ptr %0, i64 12
  %23 = getelementptr inbounds i8, ptr %0, i64 1036
  %24 = load i32, ptr %23, align 4, !tbaa !12
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %23, align 4, !tbaa !12
  %26 = sext i32 %24 to i64
  %27 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 %26
  store i8 %1, ptr %27, align 1, !tbaa !13
  %28 = tail call i32 @ft_print_out(ptr noundef nonnull %0) #2
  %29 = icmp eq i32 %28, -1
  br i1 %29, label %.loopexit, label %30

30:                                               ; preds = %.loopexit19
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %.not = icmp eq i32 %31, 0
  br i1 %.not, label %.loopexit, label %32

32:                                               ; preds = %30
  %33 = getelementptr inbounds i8, ptr %0, i64 1044
  %34 = load i32, ptr %33, align 4, !tbaa !11
  %35 = icmp sgt i32 %34, 1
  br i1 %35, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %32
  %36 = add nsw i32 %34, -1
  store i32 %36, ptr %33, align 4, !tbaa !11
  br label %39

thread-pre-split16:                               ; preds = %39
  %.pr17 = load i32, ptr %33, align 4, !tbaa !11
  %37 = add nsw i32 %.pr17, -1
  store i32 %37, ptr %33, align 4, !tbaa !11
  %38 = icmp sgt i32 %.pr17, 1
  br i1 %38, label %39, label %.loopexit

39:                                               ; preds = %.preheader, %thread-pre-split16
  %40 = load i32, ptr %23, align 4, !tbaa !12
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %23, align 4, !tbaa !12
  %42 = sext i32 %40 to i64
  %43 = getelementptr inbounds [1024 x i8], ptr %22, i64 0, i64 %42
  store i8 32, ptr %43, align 1, !tbaa !13
  %44 = tail call i32 @ft_print_out(ptr noundef nonnull %0) #2
  %45 = icmp eq i32 %44, -1
  br i1 %45, label %.loopexit, label %thread-pre-split16, !llvm.loop !16

.loopexit:                                        ; preds = %15, %thread-pre-split16, %39, %30, %32, %.loopexit19
  %.0 = phi i32 [ -1, %.loopexit19 ], [ 0, %32 ], [ 0, %30 ], [ 0, %thread-pre-split16 ], [ -1, %39 ], [ -1, %15 ]
  ret i32 %.0
}

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass