; LLVM IR from Mohamed-Ouarar/C_piscine :: C00/ex06 - ft_print_comb2 (ft_print_comb2)

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

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

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

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

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

3:                                                ; preds = %21, %0
  %4 = load i8, ptr %1, align 1, !tbaa !5
  %5 = sext i8 %4 to i32
  %6 = icmp sle i32 %5, 98
  br i1 %6, label %7, label %24

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

12:                                               ; preds = %16, %7
  %13 = load i8, ptr %2, align 1, !tbaa !5
  %14 = sext i8 %13 to i32
  %15 = icmp sle i32 %14, 99
  br i1 %15, label %16, label %21

16:                                               ; preds = %12
  %17 = load i8, ptr %1, align 1, !tbaa !5
  %18 = load i8, ptr %2, align 1, !tbaa !5
  call void @print(i8 noundef signext %17, i8 noundef signext %18)
  %19 = load i8, ptr %2, align 1, !tbaa !5
  %20 = add i8 %19, 1
  store i8 %20, ptr %2, align 1, !tbaa !5
  br label %12, !llvm.loop !8

21:                                               ; preds = %12
  %22 = load i8, ptr %1, align 1, !tbaa !5
  %23 = add i8 %22, 1
  store i8 %23, ptr %1, align 1, !tbaa !5
  br label %3, !llvm.loop !10

24:                                               ; preds = %3
  call void @llvm.lifetime.end.p0(i64 1, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %1) #2
  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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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}


; 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
declare dso_local void @print(i8 noundef signext, i8 noundef signext) local_unnamed_addr #0

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

.lr.ph.preheader:                                 ; preds = %._crit_edge, %0
  %.0711 = phi i8 [ 0, %0 ], [ %.09, %._crit_edge ]
  %.09 = add nuw nsw i8 %.0711, 1
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.010 = phi i8 [ %.0, %.lr.ph ], [ %.09, %.lr.ph.preheader ]
  tail call void @print(i8 noundef signext %.0711, i8 noundef signext %.010)
  %.0 = add nuw nsw i8 %.010, 1
  %1 = icmp ult i8 %.010, 99
  br i1 %1, label %.lr.ph, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph
  %exitcond.not = icmp eq i8 %.09, 99
  br i1 %exitcond.not, label %2, label %.lr.ph.preheader, !llvm.loop !7

2:                                                ; 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" }

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


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