; LLVM IR from yettabaa/FdF :: libft_fdf (ft_split)

; 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
define dso_local ptr @ft_split(ptr noundef %0, i8 noundef signext %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %12, label %11

11:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %106

12:                                               ; preds = %2
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = load i8, ptr %5, align 1, !tbaa !9
  %15 = call i32 @nb_w(ptr noundef %13, i8 noundef signext %14)
  %16 = add nsw i32 %15, 1
  %17 = sext i32 %16 to i64
  %18 = mul i64 8, %17
  %19 = call noalias ptr @malloc(i64 noundef %18) #5
  store ptr %19, ptr %7, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %23, label %22

22:                                               ; preds = %12
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %106

23:                                               ; preds = %12
  store i32 0, ptr %6, align 4, !tbaa !10
  br label %24

24:                                               ; preds = %99, %23
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i8, ptr %25, align 1, !tbaa !9
  %27 = icmp ne i8 %26, 0
  br i1 %27, label %28, label %100

28:                                               ; preds = %24
  br label %29

29:                                               ; preds = %43, %28
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load i8, ptr %30, align 1, !tbaa !9
  %32 = sext i8 %31 to i32
  %33 = load i8, ptr %5, align 1, !tbaa !9
  %34 = sext i8 %33 to i32
  %35 = icmp eq i32 %32, %34
  br i1 %35, label %36, label %41

36:                                               ; preds = %29
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load i8, ptr %37, align 1, !tbaa !9
  %39 = sext i8 %38 to i32
  %40 = icmp ne i32 %39, 0
  br label %41

41:                                               ; preds = %36, %29
  %42 = phi i1 [ false, %29 ], [ %40, %36 ]
  br i1 %42, label %43, label %46

43:                                               ; preds = %41
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i32 1
  store ptr %45, ptr %4, align 8, !tbaa !5
  br label %29, !llvm.loop !12

46:                                               ; preds = %41
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = load i8, ptr %47, align 1, !tbaa !9
  %49 = sext i8 %48 to i32
  %50 = load i8, ptr %5, align 1, !tbaa !9
  %51 = sext i8 %50 to i32
  %52 = icmp ne i32 %49, %51
  br i1 %52, label %53, label %99

53:                                               ; preds = %46
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = load i8, ptr %54, align 1, !tbaa !9
  %56 = sext i8 %55 to i32
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %99

58:                                               ; preds = %53
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = load i8, ptr %5, align 1, !tbaa !9
  %62 = call i32 @len_split(ptr noundef %60, i8 noundef signext %61)
  %63 = sext i32 %62 to i64
  %64 = call ptr @ft_substr(ptr noundef %59, i32 noundef 0, i64 noundef %63)
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = load i32, ptr %6, align 4, !tbaa !10
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds ptr, ptr %65, i64 %67
  store ptr %64, ptr %68, align 8, !tbaa !5
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = load i32, ptr %6, align 4, !tbaa !10
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds ptr, ptr %69, i64 %71
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = icmp ne ptr %73, null
  br i1 %74, label %78, label %75

75:                                               ; preds = %58
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = load i32, ptr %6, align 4, !tbaa !10
  call void @free_s(ptr noundef %76, i32 noundef %77)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %106

78:                                               ; preds = %58
  %79 = load i32, ptr %6, align 4, !tbaa !10
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %6, align 4, !tbaa !10
  br label %81

81:                                               ; preds = %95, %78
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = load i8, ptr %82, align 1, !tbaa !9
  %84 = sext i8 %83 to i32
  %85 = load i8, ptr %5, align 1, !tbaa !9
  %86 = sext i8 %85 to i32
  %87 = icmp ne i32 %84, %86
  br i1 %87, label %88, label %93

88:                                               ; preds = %81
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = load i8, ptr %89, align 1, !tbaa !9
  %91 = sext i8 %90 to i32
  %92 = icmp ne i32 %91, 0
  br label %93

93:                                               ; preds = %88, %81
  %94 = phi i1 [ false, %81 ], [ %92, %88 ]
  br i1 %94, label %95, label %98

95:                                               ; preds = %93
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds i8, ptr %96, i32 1
  store ptr %97, ptr %4, align 8, !tbaa !5
  br label %81, !llvm.loop !14

98:                                               ; preds = %93
  br label %99

99:                                               ; preds = %98, %53, %46
  br label %24, !llvm.loop !15

100:                                              ; preds = %24
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = load i32, ptr %6, align 4, !tbaa !10
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds ptr, ptr %101, i64 %103
  store ptr null, ptr %104, align 8, !tbaa !5
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %105, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %106

106:                                              ; preds = %100, %75, %22, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %107 = load ptr, ptr %3, align 8
  ret ptr %107
}

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @nb_w(ptr noundef, i8 noundef signext) #0

declare ptr @ft_substr(ptr noundef, i32 noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @len_split(ptr noundef, i8 noundef signext) #0

; Function Attrs: nounwind uwtable
declare hidden void @free_s(ptr noundef, i32 noundef) #0

; 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 = { nounwind allocsize(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 #3 = { "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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(0) }

!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, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}


; 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 noundef ptr @ft_split(ptr noundef %0, i8 noundef signext %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %27, label %3

3:                                                ; preds = %2
  %4 = tail call i32 @nb_w(ptr noundef nonnull %0, i8 noundef signext %1)
  %5 = add nsw i32 %4, 1
  %6 = sext i32 %5 to i64
  %7 = shl nsw i64 %6, 3
  %8 = tail call noalias ptr @malloc(i64 noundef %7) #3
  %.not40 = icmp eq ptr %8, null
  br i1 %.not40, label %27, label %.preheader50

.preheader50:                                     ; preds = %3
  %9 = load i8, ptr %0, align 1, !tbaa !5
  %.not4152 = icmp eq i8 %9, 0
  br i1 %.not4152, label %._crit_edge, label %.preheader

.preheader:                                       ; preds = %.preheader50, %.critedge2
  %.03154 = phi i32 [ %.1, %.critedge2 ], [ 0, %.preheader50 ]
  %.03253 = phi ptr [ %.3, %.critedge2 ], [ %0, %.preheader50 ]
  br label %10

10:                                               ; preds = %10, %.preheader
  %.133 = phi ptr [ %13, %10 ], [ %.03253, %.preheader ]
  %11 = load i8, ptr %.133, align 1, !tbaa !5
  %12 = icmp ne i8 %11, %1
  %.not42 = icmp eq i8 %11, 0
  %or.cond = or i1 %12, %.not42
  %13 = getelementptr inbounds i8, ptr %.133, i64 1
  br i1 %or.cond, label %.critedge, label %10, !llvm.loop !8

.critedge:                                        ; preds = %10
  %.not43 = icmp eq i8 %11, %1
  %or.cond48 = or i1 %.not43, %.not42
  br i1 %or.cond48, label %.critedge2, label %14

14:                                               ; preds = %.critedge
  %15 = tail call i32 @len_split(ptr noundef nonnull %.133, i8 noundef signext %1)
  %16 = sext i32 %15 to i64
  %17 = tail call ptr @ft_substr(ptr noundef nonnull %.133, i32 noundef 0, i64 noundef %16) #4
  %18 = sext i32 %.03154 to i64
  %19 = getelementptr inbounds ptr, ptr %8, i64 %18
  store ptr %17, ptr %19, align 8, !tbaa !10
  %.not45 = icmp eq ptr %17, null
  br i1 %.not45, label %20, label %.preheader58

20:                                               ; preds = %14
  tail call void @free_s(ptr noundef nonnull %8, i32 noundef %.03154)
  br label %27

.preheader58:                                     ; preds = %14, %.preheader58
  %.2 = phi ptr [ %22, %.preheader58 ], [ %.133, %14 ]
  %21 = load i8, ptr %.2, align 1, !tbaa !5
  %.not46 = icmp eq i8 %21, %1
  %.not47 = icmp eq i8 %21, 0
  %or.cond49 = or i1 %.not46, %.not47
  %22 = getelementptr inbounds i8, ptr %.2, i64 1
  br i1 %or.cond49, label %.critedge2.loopexit, label %.preheader58, !llvm.loop !12

.critedge2.loopexit:                              ; preds = %.preheader58
  %23 = add nsw i32 %.03154, 1
  br label %.critedge2

.critedge2:                                       ; preds = %.critedge2.loopexit, %.critedge
  %24 = phi i8 [ %11, %.critedge ], [ %21, %.critedge2.loopexit ]
  %.3 = phi ptr [ %.133, %.critedge ], [ %.2, %.critedge2.loopexit ]
  %.1 = phi i32 [ %.03154, %.critedge ], [ %23, %.critedge2.loopexit ]
  %.not41 = icmp eq i8 %24, 0
  br i1 %.not41, label %._crit_edge.loopexit, label %.preheader, !llvm.loop !13

._crit_edge.loopexit:                             ; preds = %.critedge2
  %25 = sext i32 %.1 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader50
  %.031.lcssa = phi i64 [ 0, %.preheader50 ], [ %25, %._crit_edge.loopexit ]
  %26 = getelementptr inbounds ptr, ptr %8, i64 %.031.lcssa
  store ptr null, ptr %26, align 8, !tbaa !10
  br label %27

27:                                               ; preds = %3, %2, %._crit_edge, %20
  %.0 = phi ptr [ null, %20 ], [ %8, %._crit_edge ], [ null, %2 ], [ null, %3 ]
  ret ptr %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @nb_w(ptr noundef, i8 noundef signext) local_unnamed_addr #0

declare ptr @ft_substr(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @len_split(ptr noundef, i8 noundef signext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @free_s(ptr noundef, i32 noundef) local_unnamed_addr #0

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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { "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 allocsize(0) }
attributes #4 = { 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 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = distinct !{!12, !9}
!13 = distinct !{!13, !9}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass