; LLVM IR from simon-zerisenay/42_Push_Swap :: src (build_stack)

; 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.t_list = type { i32, i32, i32, i32, i32, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @create_stack(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 ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = call ptr @ft_split(ptr noundef %10, i8 noundef signext 32)
  store ptr %11, ptr %7, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free(ptr noundef %13) #5
  br label %14

14:                                               ; preds = %72, %2
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = load i32, ptr %8, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds ptr, ptr %15, i64 %17
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %75

21:                                               ; preds = %14
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds ptr, ptr %22, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = call i64 @ft_strlen(ptr noundef %26)
  %28 = icmp ugt i64 %27, 11
  br i1 %28, label %29, label %42

29:                                               ; preds = %21
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds ptr, ptr %30, i64 %32
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i64 0
  %36 = load i8, ptr %35, align 1, !tbaa !11
  %37 = sext i8 %36 to i32
  %38 = icmp ne i32 %37, 45
  br i1 %38, label %39, label %42

39:                                               ; preds = %29
  %40 = load i64, ptr %6, align 8, !tbaa !12
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free_stuff(i64 noundef %40, ptr noundef %41, ptr noundef %7)
  br label %42

42:                                               ; preds = %39, %29, %21
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = load i32, ptr %8, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds ptr, ptr %43, i64 %45
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  %48 = call i64 @ft_atoi(ptr noundef %47)
  store i64 %48, ptr %6, align 8, !tbaa !12
  %49 = load i64, ptr %6, align 8, !tbaa !12
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free_stuff(i64 noundef %49, ptr noundef %50, ptr noundef %7)
  %51 = call noalias ptr @malloc(i64 noundef 32) #6
  store ptr %51, ptr %5, align 8, !tbaa !5
  %52 = load i64, ptr %6, align 8, !tbaa !12
  %53 = trunc i64 %52 to i32
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.t_list, ptr %54, i32 0, i32 0
  store i32 %53, ptr %55, align 8, !tbaa !14
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.t_list, ptr %56, i32 0, i32 5
  store ptr null, ptr %57, align 8, !tbaa !16
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.t_list, ptr %58, i32 0, i32 1
  store i32 0, ptr %59, align 4, !tbaa !17
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  %62 = icmp ne ptr %61, null
  br i1 %62, label %66, label %63

63:                                               ; preds = %42
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %64, ptr %65, align 8, !tbaa !5
  br label %72

66:                                               ; preds = %42
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = load ptr, ptr %68, align 8, !tbaa !5
  %70 = call ptr @lstlast(ptr noundef %69)
  %71 = getelementptr inbounds %struct.t_list, ptr %70, i32 0, i32 5
  store ptr %67, ptr %71, align 8, !tbaa !16
  br label %72

72:                                               ; preds = %66, %63
  %73 = load i32, ptr %8, align 4, !tbaa !9
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %8, align 4, !tbaa !9
  br label %14, !llvm.loop !18

75:                                               ; preds = %14
  call void @free_array(ptr noundef %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret void
}

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

declare ptr @ft_split(ptr noundef, i8 noundef signext) #2

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

declare i64 @ft_strlen(ptr noundef) #2

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

declare i64 @ft_atoi(ptr noundef) #2

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

declare ptr @lstlast(ptr noundef) #2

declare void @free_array(ptr noundef) #2

; 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 = { "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 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 #5 = { nounwind }
attributes #6 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"t_list", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24}
!16 = !{!15, !6, i64 24}
!17 = !{!15, !10, i64 4}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; 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 void @create_stack(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = tail call ptr @ft_split(ptr noundef %4, i8 noundef signext 32) #5
  store ptr %5, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  tail call void @free(ptr noundef %6) #5
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %.not24 = icmp eq ptr %7, null
  br i1 %.not24, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %29
  %indvars.iv = phi i64 [ %indvars.iv.next, %29 ], [ 0, %2 ]
  %8 = phi ptr [ %32, %29 ], [ %7, %2 ]
  %.01925 = phi i64 [ %20, %29 ], [ undef, %2 ]
  %9 = call i64 @ft_strlen(ptr noundef nonnull %8) #5
  %10 = icmp ugt i64 %9, 11
  %.pre28 = load ptr, ptr %3, align 8, !tbaa !5
  br i1 %10, label %11, label %16

11:                                               ; preds = %.lr.ph
  %12 = getelementptr inbounds ptr, ptr %.pre28, i64 %indvars.iv
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = load i8, ptr %13, align 1, !tbaa !9
  %.not22 = icmp eq i8 %14, 45
  br i1 %.not22, label %16, label %15

15:                                               ; preds = %11
  call void @free_stuff(i64 noundef %.01925, ptr noundef %1, ptr noundef nonnull %3)
  %.pre = load ptr, ptr %3, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %15, %11, %.lr.ph
  %17 = phi ptr [ %.pre, %15 ], [ %.pre28, %11 ], [ %.pre28, %.lr.ph ]
  %18 = getelementptr inbounds ptr, ptr %17, i64 %indvars.iv
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %20 = call i64 @ft_atoi(ptr noundef %19) #5
  call void @free_stuff(i64 noundef %20, ptr noundef %1, ptr noundef nonnull %3)
  %21 = call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #6
  %22 = trunc i64 %20 to i32
  store i32 %22, ptr %21, align 8, !tbaa !10
  %23 = getelementptr inbounds i8, ptr %21, i64 24
  store ptr null, ptr %23, align 8, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %21, i64 4
  store i32 0, ptr %24, align 4, !tbaa !14
  %25 = load ptr, ptr %1, align 8, !tbaa !5
  %.not23 = icmp eq ptr %25, null
  br i1 %.not23, label %29, label %26

26:                                               ; preds = %16
  %27 = call ptr @lstlast(ptr noundef nonnull %25) #5
  %28 = getelementptr inbounds i8, ptr %27, i64 24
  br label %29

29:                                               ; preds = %16, %26
  %.sink = phi ptr [ %28, %26 ], [ %1, %16 ]
  store ptr %21, ptr %.sink, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds ptr, ptr %30, i64 %indvars.iv.next
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %.not = icmp eq ptr %32, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !15

._crit_edge:                                      ; preds = %29, %2
  call void @free_array(ptr noundef nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  ret void
}

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

declare ptr @ft_split(ptr noundef, i8 noundef signext) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

declare i64 @ft_strlen(ptr noundef) local_unnamed_addr #2

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

declare i64 @ft_atoi(ptr noundef) local_unnamed_addr #2

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

declare ptr @lstlast(ptr noundef) local_unnamed_addr #2

declare void @free_array(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { 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, !12, i64 0}
!11 = !{!"t_list", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !6, i64 24}
!12 = !{!"int", !7, i64 0}
!13 = !{!11, !6, i64 24}
!14 = !{!11, !12, i64 4}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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