; LLVM IR from 48d31kh413k/1337-push_swap-42 :: libft (get_next_line_utils)

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

12:                                               ; preds = %2
  %13 = call noalias ptr @malloc(i64 noundef 1) #5
  store ptr %13, ptr %4, align 8, !tbaa !5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 0
  store i8 0, ptr %15, align 1, !tbaa !9
  br label %16

16:                                               ; preds = %12, %2
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %22

19:                                               ; preds = %16
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %23, label %22

22:                                               ; preds = %19, %16
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %84

23:                                               ; preds = %19
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = call i64 @ft_strlen1(ptr noundef %24)
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call i64 @ft_strlen1(ptr noundef %26)
  %28 = add i64 %25, %27
  %29 = add i64 %28, 1
  %30 = mul i64 1, %29
  %31 = call noalias ptr @malloc(i64 noundef %30) #5
  store ptr %31, ptr %8, align 8, !tbaa !5
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %23
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %84

35:                                               ; preds = %23
  store i64 -1, ptr %6, align 8, !tbaa !10
  store i64 0, ptr %7, align 8, !tbaa !10
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %56

38:                                               ; preds = %35
  br label %39

39:                                               ; preds = %47, %38
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load i64, ptr %6, align 8, !tbaa !10
  %42 = add i64 %41, 1
  store i64 %42, ptr %6, align 8, !tbaa !10
  %43 = getelementptr inbounds i8, ptr %40, i64 %42
  %44 = load i8, ptr %43, align 1, !tbaa !9
  %45 = sext i8 %44 to i32
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %55

47:                                               ; preds = %39
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = load i64, ptr %6, align 8, !tbaa !10
  %50 = getelementptr inbounds i8, ptr %48, i64 %49
  %51 = load i8, ptr %50, align 1, !tbaa !9
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = load i64, ptr %6, align 8, !tbaa !10
  %54 = getelementptr inbounds i8, ptr %52, i64 %53
  store i8 %51, ptr %54, align 1, !tbaa !9
  br label %39, !llvm.loop !12

55:                                               ; preds = %39
  br label %56

56:                                               ; preds = %55, %35
  br label %57

57:                                               ; preds = %64, %56
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = load i64, ptr %7, align 8, !tbaa !10
  %60 = getelementptr inbounds i8, ptr %58, i64 %59
  %61 = load i8, ptr %60, align 1, !tbaa !9
  %62 = sext i8 %61 to i32
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %74

64:                                               ; preds = %57
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = load i64, ptr %7, align 8, !tbaa !10
  %67 = add i64 %66, 1
  store i64 %67, ptr %7, align 8, !tbaa !10
  %68 = getelementptr inbounds i8, ptr %65, i64 %66
  %69 = load i8, ptr %68, align 1, !tbaa !9
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = load i64, ptr %6, align 8, !tbaa !10
  %72 = add i64 %71, 1
  store i64 %72, ptr %6, align 8, !tbaa !10
  %73 = getelementptr inbounds i8, ptr %70, i64 %71
  store i8 %69, ptr %73, align 1, !tbaa !9
  br label %57, !llvm.loop !14

74:                                               ; preds = %57
  %75 = load ptr, ptr %8, align 8, !tbaa !5
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = call i64 @ft_strlen1(ptr noundef %76)
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = call i64 @ft_strlen1(ptr noundef %78)
  %80 = add i64 %77, %79
  %81 = getelementptr inbounds i8, ptr %75, i64 %80
  store i8 0, ptr %81, align 1, !tbaa !9
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %82) #4
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %83, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %84

84:                                               ; preds = %74, %34, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %85 = load ptr, ptr %3, align 8
  ret ptr %85
}

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

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 = { nounwind "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 = !{!"long", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !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
declare dso_local i64 @ft_strlen1(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @ft_strjoin1(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %5

3:                                                ; preds = %2
  %4 = tail call noalias dereferenceable_or_null(1) ptr @malloc(i64 noundef 1) #3
  store i8 0, ptr %4, align 1, !tbaa !5
  br label %5

5:                                                ; preds = %3, %2
  %.028 = phi ptr [ %0, %2 ], [ %4, %3 ]
  %.not32 = icmp eq ptr %1, null
  br i1 %.not32, label %31, label %6

6:                                                ; preds = %5
  %7 = tail call i64 @ft_strlen1(ptr noundef nonnull %.028)
  %8 = tail call i64 @ft_strlen1(ptr noundef nonnull %1)
  %9 = add i64 %7, 1
  %10 = add i64 %9, %8
  %11 = tail call noalias ptr @malloc(i64 noundef %10) #3
  %12 = icmp eq ptr %11, null
  br i1 %12, label %31, label %.preheader35

.preheader35:                                     ; preds = %6
  %13 = load i8, ptr %.028, align 1, !tbaa !5
  %.not3336 = icmp eq i8 %13, 0
  br i1 %.not3336, label %.preheader, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph, %.preheader35
  %.lcssa = phi i64 [ 0, %.preheader35 ], [ %18, %.lr.ph ]
  %14 = load i8, ptr %1, align 1, !tbaa !5
  %.not3437 = icmp eq i8 %14, 0
  br i1 %.not3437, label %._crit_edge, label %.lr.ph40

.lr.ph:                                           ; preds = %.preheader35, %.lr.ph
  %15 = phi i8 [ %20, %.lr.ph ], [ %13, %.preheader35 ]
  %16 = phi i64 [ %18, %.lr.ph ], [ 0, %.preheader35 ]
  %17 = getelementptr inbounds i8, ptr %11, i64 %16
  store i8 %15, ptr %17, align 1, !tbaa !5
  %18 = add i64 %16, 1
  %19 = getelementptr inbounds i8, ptr %.028, i64 %18
  %20 = load i8, ptr %19, align 1, !tbaa !5
  %.not33 = icmp eq i8 %20, 0
  br i1 %.not33, label %.preheader, label %.lr.ph, !llvm.loop !8

.lr.ph40:                                         ; preds = %.preheader, %.lr.ph40
  %21 = phi i8 [ %26, %.lr.ph40 ], [ %14, %.preheader ]
  %.02639 = phi i64 [ %22, %.lr.ph40 ], [ 0, %.preheader ]
  %.238 = phi i64 [ %23, %.lr.ph40 ], [ %.lcssa, %.preheader ]
  %22 = add i64 %.02639, 1
  %23 = add i64 %.238, 1
  %24 = getelementptr inbounds i8, ptr %11, i64 %.238
  store i8 %21, ptr %24, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %1, i64 %22
  %26 = load i8, ptr %25, align 1, !tbaa !5
  %.not34 = icmp eq i8 %26, 0
  br i1 %.not34, label %._crit_edge, label %.lr.ph40, !llvm.loop !10

._crit_edge:                                      ; preds = %.lr.ph40, %.preheader
  %27 = tail call i64 @ft_strlen1(ptr noundef nonnull %.028)
  %28 = tail call i64 @ft_strlen1(ptr noundef nonnull %1)
  %29 = getelementptr i8, ptr %11, i64 %27
  %30 = getelementptr i8, ptr %29, i64 %28
  store i8 0, ptr %30, align 1, !tbaa !5
  tail call void @free(ptr noundef %.028) #4
  br label %31

31:                                               ; preds = %6, %5, %._crit_edge
  %.0 = phi ptr [ %11, %._crit_edge ], [ null, %5 ], [ null, %6 ]
  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: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #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 = { 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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #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 = distinct !{!10, !9}


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