; LLVM IR from Mohamed-Ouarar/C_piscine :: C00/ex05 - ft_print_comb (ft_print_comb)

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @print(i8 noundef signext, i8 noundef signext, i8 noundef signext) #0

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @ft_print_comb() #0 {
  %1 = alloca i8, align 1
  %2 = alloca i8, align 1
  %3 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #3
  store i8 48, ptr %1, align 1, !tbaa !5
  br label %4

4:                                                ; preds = %49, %0
  %5 = load i8, ptr %1, align 1, !tbaa !5
  %6 = sext i8 %5 to i32
  %7 = icmp sle i32 %6, 55
  br i1 %7, label %8, label %52

8:                                                ; preds = %4
  %9 = load i8, ptr %1, align 1, !tbaa !5
  %10 = sext i8 %9 to i32
  %11 = add nsw i32 %10, 1
  %12 = trunc i32 %11 to i8
  store i8 %12, ptr %2, align 1, !tbaa !5
  br label %13

13:                                               ; preds = %46, %8
  %14 = load i8, ptr %2, align 1, !tbaa !5
  %15 = sext i8 %14 to i32
  %16 = icmp sle i32 %15, 56
  br i1 %16, label %17, label %49

17:                                               ; preds = %13
  %18 = load i8, ptr %2, align 1, !tbaa !5
  %19 = sext i8 %18 to i32
  %20 = add nsw i32 %19, 1
  %21 = trunc i32 %20 to i8
  store i8 %21, ptr %3, align 1, !tbaa !5
  br label %22

22:                                               ; preds = %43, %17
  %23 = load i8, ptr %3, align 1, !tbaa !5
  %24 = sext i8 %23 to i32
  %25 = icmp sle i32 %24, 57
  br i1 %25, label %26, label %46

26:                                               ; preds = %22
  %27 = load i8, ptr %1, align 1, !tbaa !5
  %28 = load i8, ptr %2, align 1, !tbaa !5
  %29 = load i8, ptr %3, align 1, !tbaa !5
  call void @print(i8 noundef signext %27, i8 noundef signext %28, i8 noundef signext %29)
  %30 = load i8, ptr %1, align 1, !tbaa !5
  %31 = sext i8 %30 to i32
  %32 = icmp eq i32 %31, 55
  br i1 %32, label %33, label %41

33:                                               ; preds = %26
  %34 = load i8, ptr %2, align 1, !tbaa !5
  %35 = sext i8 %34 to i32
  %36 = icmp eq i32 %35, 56
  br i1 %36, label %37, label %41

37:                                               ; preds = %33
  %38 = load i8, ptr %3, align 1, !tbaa !5
  %39 = sext i8 %38 to i32
  %40 = icmp eq i32 %39, 57
  br i1 %40, label %43, label %41

41:                                               ; preds = %37, %33, %26
  %42 = call i64 @write(i32 noundef 1, ptr noundef @.str, i64 noundef 2)
  br label %43

43:                                               ; preds = %41, %37
  %44 = load i8, ptr %3, align 1, !tbaa !5
  %45 = add i8 %44, 1
  store i8 %45, ptr %3, align 1, !tbaa !5
  br label %22, !llvm.loop !8

46:                                               ; preds = %22
  %47 = load i8, ptr %2, align 1, !tbaa !5
  %48 = add i8 %47, 1
  store i8 %48, ptr %2, align 1, !tbaa !5
  br label %13, !llvm.loop !10

49:                                               ; preds = %13
  %50 = load i8, ptr %1, align 1, !tbaa !5
  %51 = add i8 %50, 1
  store i8 %51, ptr %1, align 1, !tbaa !5
  br label %4, !llvm.loop !11

52:                                               ; preds = %4
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %1) #3
  ret void
}

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}
!11 = distinct !{!11, !9}


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

; Function Attrs: nounwind uwtable
declare dso_local void @print(i8 noundef signext, i8 noundef signext, i8 noundef signext) local_unnamed_addr #0

; Function Attrs: nofree
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @ft_print_comb() local_unnamed_addr #0 {
  br label %.lr.ph29

.lr.ph29:                                         ; preds = %._crit_edge, %0
  %.02030 = phi i8 [ 48, %0 ], [ %.01925, %._crit_edge ]
  %.01925 = add nuw nsw i8 %.02030, 1
  %1 = icmp eq i8 %.02030, 55
  br label %3

.loopexit:                                        ; preds = %.lr.ph.split.us, %.lr.ph.split, %.lr.ph.split.preheader, %3
  %.019 = add nuw nsw i8 %.01927, 1
  %2 = icmp ult i8 %.01927, 56
  br i1 %2, label %3, label %._crit_edge, !llvm.loop !5

3:                                                ; preds = %.lr.ph29, %.loopexit
  %.01927 = phi i8 [ %.01925, %.lr.ph29 ], [ %.019, %.loopexit ]
  %.019.in26 = phi i8 [ %.02030, %.lr.ph29 ], [ %.01927, %.loopexit ]
  %4 = icmp ult i8 %.019.in26, 56
  br i1 %4, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %3
  %5 = add nuw nsw i8 %.019.in26, 2
  %6 = icmp eq i8 %.01927, 56
  %or.cond = and i1 %1, %6
  %or.cond.fr = freeze i1 %or.cond
  br i1 %or.cond.fr, label %.lr.ph.split.preheader, label %.lr.ph.split.us

.lr.ph.split.preheader:                           ; preds = %.lr.ph
  tail call void @print(i8 noundef signext %.02030, i8 noundef signext %.01927, i8 noundef signext %5)
  %7 = icmp eq i8 %5, 57
  br i1 %7, label %.loopexit, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph.split.us
  %.024.us = phi i8 [ %9, %.lr.ph.split.us ], [ %5, %.lr.ph ]
  tail call void @print(i8 noundef signext %.02030, i8 noundef signext %.01927, i8 noundef signext %.024.us)
  %8 = tail call i64 @write(i32 noundef 1, ptr noundef nonnull @.str, i64 noundef 2) #2
  %9 = add nuw nsw i8 %.024.us, 1
  %10 = icmp ult i8 %.024.us, 57
  br i1 %10, label %.lr.ph.split.us, label %.loopexit, !llvm.loop !7

.lr.ph.split:                                     ; preds = %.lr.ph.split.preheader, %.lr.ph.split
  %.02434 = phi i8 [ %12, %.lr.ph.split ], [ %5, %.lr.ph.split.preheader ]
  %11 = tail call i64 @write(i32 noundef 1, ptr noundef nonnull @.str, i64 noundef 2) #2
  %12 = add nuw nsw i8 %.02434, 1
  tail call void @print(i8 noundef signext %.02030, i8 noundef signext %.01927, i8 noundef signext %12)
  %13 = icmp eq i8 %12, 57
  br i1 %13, label %.loopexit, label %.lr.ph.split, !llvm.loop !7

._crit_edge:                                      ; preds = %.loopexit
  %exitcond.not = icmp eq i8 %.01925, 56
  br i1 %exitcond.not, label %14, label %.lr.ph29, !llvm.loop !8

14:                                               ; preds = %._crit_edge
  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" }
attributes #1 = { nofree "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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = distinct !{!8, !6}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass