; 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 void @reset_insignificant_values(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.s_pf, ptr %5, i32 0, i32 11
  %7 = load i32, ptr %6, align 4, !tbaa !11
  %8 = icmp ne i32 %7, 0
  br i1 %8, label %9, label %31

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

14:                                               ; preds = %9
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.s_pf, ptr %15, i32 0, i32 6
  %17 = load i32, ptr %16, align 8, !tbaa !14
  %18 = icmp sle i32 %17, 0
  br i1 %18, label %19, label %31

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

31:                                               ; preds = %19, %14, %9, %2
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.s_pf, ptr %32, i32 0, i32 5
  %34 = load i32, ptr %33, align 4, !tbaa !13
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.s_pf, ptr %35, i32 0, i32 6
  %37 = load i32, ptr %36, align 8, !tbaa !14
  %38 = icmp sle i32 %34, %37
  br i1 %38, label %39, label %42

39:                                               ; preds = %31
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.s_pf, ptr %40, i32 0, i32 5
  store i32 0, ptr %41, align 4, !tbaa !13
  br label %42

42:                                               ; preds = %39, %31
  ret void
}

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

!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 1068}
!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 1044}
!14 = !{!12, !10, i64 1048}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @reset_insignificant_values(ptr nocapture noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 1068
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %.not = icmp ne i32 %4, 0
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 1044
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !11
  %5 = icmp sgt i32 %.pre, 0
  %or.cond = select i1 %.not, i1 %5, i1 false
  br i1 %or.cond, label %6, label %._crit_edge

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 1048
  %8 = load i32, ptr %7, align 8, !tbaa !12
  %9 = icmp slt i32 %8, 1
  br i1 %9, label %10, label %._crit_edge

10:                                               ; preds = %6
  store i32 0, ptr %3, align 4, !tbaa !5
  %11 = sub nsw i32 %.pre, %1
  store i32 %11, ptr %7, align 8, !tbaa !12
  store i32 0, ptr %.phi.trans.insert, align 4, !tbaa !11
  br label %._crit_edge

._crit_edge:                                      ; preds = %2, %10, %6
  %12 = phi i32 [ 0, %10 ], [ %.pre, %6 ], [ %.pre, %2 ]
  %13 = getelementptr inbounds i8, ptr %0, i64 1048
  %14 = load i32, ptr %13, align 8, !tbaa !12
  %.not10 = icmp sgt i32 %12, %14
  br i1 %.not10, label %17, label %15

15:                                               ; preds = %._crit_edge
  %16 = getelementptr inbounds i8, ptr %0, i64 1044
  store i32 0, ptr %16, align 4, !tbaa !11
  br label %17

17:                                               ; preds = %15, %._crit_edge
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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" }

!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 1068}
!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 1048}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass