; LLVM IR from bnidia/push_swap :: main (sort_five)

; 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.s_minmaxmed = type { i32, i32, i32 }
%struct.s_listc = type { i32, i32, i32, i32, i32, ptr, ptr }

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #1

declare i32 @ft_lstc_size(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @sort_five(ptr noundef %0, ptr noundef %1, i64 %2, i32 %3) #3 {
  %5 = alloca %struct.s_minmaxmed, align 4
  %6 = alloca { i64, i32 }, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca { i64, i32 }, align 4
  %10 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 0
  store i64 %2, ptr %10, align 4
  %11 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 1
  store i32 %3, ptr %11, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 %6, i64 12, i1 false)
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %5, i64 12, i1 false)
  %13 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 0
  %14 = load i64, ptr %13, align 4
  %15 = getelementptr inbounds { i64, i32 }, ptr %9, i32 0, i32 1
  %16 = load i32, ptr %15, align 4
  call void @get_index(ptr noundef %12, i64 %14, i32 %16)
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr null, ptr %17, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %38, %35, %4
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = call i32 @ft_lstc_size(ptr noundef %20)
  %22 = icmp ne i32 %21, 3
  br i1 %22, label %23, label %40

23:                                               ; preds = %18
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.s_listc, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 8, !tbaa !9
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %35, label %29

29:                                               ; preds = %23
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.s_listc, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !9
  %34 = icmp eq i32 %33, 5
  br i1 %34, label %35, label %38

35:                                               ; preds = %29, %23
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  call void @pb(ptr noundef %36, ptr noundef %37, i1 noundef zeroext true)
  br label %18, !llvm.loop !12

38:                                               ; preds = %29
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  call void @ra(ptr noundef %39, i1 noundef zeroext true)
  br label %18, !llvm.loop !12

40:                                               ; preds = %18
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  call void @sort_three(ptr noundef %41)
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.s_listc, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %44, align 8, !tbaa !9
  %46 = icmp eq i32 %45, 4
  br i1 %46, label %47, label %49

47:                                               ; preds = %40
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  call void @ra(ptr noundef %48, i1 noundef zeroext true)
  br label %49

49:                                               ; preds = %47, %40
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = load ptr, ptr %50, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.s_listc, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %52, align 8, !tbaa !9
  %54 = icmp eq i32 %53, 3
  br i1 %54, label %55, label %57

55:                                               ; preds = %49
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  call void @rra(ptr noundef %56, i1 noundef zeroext true)
  br label %57

57:                                               ; preds = %55, %49
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  call void @pa(ptr noundef %58, ptr noundef %59, i1 noundef zeroext true)
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.s_listc, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %62, align 8, !tbaa !9
  %64 = icmp eq i32 %63, 5
  br i1 %64, label %65, label %67

65:                                               ; preds = %57
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  call void @ra(ptr noundef %66, i1 noundef zeroext true)
  br label %67

67:                                               ; preds = %65, %57
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  call void @pa(ptr noundef %68, ptr noundef %69, i1 noundef zeroext true)
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = load ptr, ptr %70, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.s_listc, ptr %71, i32 0, i32 0
  %73 = load i32, ptr %72, align 8, !tbaa !9
  %74 = icmp eq i32 %73, 5
  br i1 %74, label %75, label %77

75:                                               ; preds = %67
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  call void @ra(ptr noundef %76, i1 noundef zeroext true)
  br label %77

77:                                               ; preds = %75, %67
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  call void @ft_lstc_clear(ptr noundef %78)
  call void @exit(i32 noundef 0) #4
  unreachable
}

; Function Attrs: nounwind uwtable
declare dso_local void @sort_three(ptr noundef) #3

declare void @ft_lstc_clear(ptr noundef) #2

declare void @ra(ptr noundef, i1 noundef zeroext) #2

declare void @pb(ptr noundef, ptr noundef, i1 noundef zeroext) #2

declare void @get_index(ptr noundef, i64, i32) #2

declare void @rra(ptr noundef, i1 noundef zeroext) #2

declare void @pa(ptr noundef, ptr noundef, i1 noundef zeroext) #2

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #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 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 #4 = { noreturn 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"s_listc", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !6, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #0

declare i32 @ft_lstc_size(ptr noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind uwtable
define dso_local void @sort_five(ptr noundef %0, ptr noundef %1, i64 %2, i32 %3) local_unnamed_addr #2 {
  tail call void @get_index(ptr noundef %0, i64 %2, i32 %3) #4
  store ptr null, ptr %1, align 8, !tbaa !5
  %5 = load ptr, ptr %0, align 8, !tbaa !5
  %6 = tail call i32 @ft_lstc_size(ptr noundef %5) #4
  %.not26 = icmp eq i32 %6, 3
  br i1 %.not26, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4, %.backedge
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = load i32, ptr %7, align 8, !tbaa !9
  switch i32 %8, label %12 [
    i32 1, label %9
    i32 5, label %9
  ]

9:                                                ; preds = %.lr.ph, %.lr.ph
  tail call void @pb(ptr noundef nonnull %0, ptr noundef nonnull %1, i1 noundef zeroext true) #4
  br label %.backedge

.backedge:                                        ; preds = %9, %12
  %10 = load ptr, ptr %0, align 8, !tbaa !5
  %11 = tail call i32 @ft_lstc_size(ptr noundef %10) #4
  %.not = icmp eq i32 %11, 3
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

12:                                               ; preds = %.lr.ph
  tail call void @ra(ptr noundef nonnull %0, i1 noundef zeroext true) #4
  br label %.backedge

._crit_edge:                                      ; preds = %.backedge, %4
  tail call void @sort_three(ptr noundef nonnull %0)
  %13 = load ptr, ptr %0, align 8, !tbaa !5
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = icmp eq i32 %14, 4
  br i1 %15, label %16, label %17

16:                                               ; preds = %._crit_edge
  tail call void @ra(ptr noundef nonnull %0, i1 noundef zeroext true) #4
  %.pre = load ptr, ptr %0, align 8, !tbaa !5
  %.pre27 = load i32, ptr %.pre, align 8, !tbaa !9
  br label %17

17:                                               ; preds = %16, %._crit_edge
  %18 = phi i32 [ %.pre27, %16 ], [ %14, %._crit_edge ]
  %19 = icmp eq i32 %18, 3
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  tail call void @rra(ptr noundef nonnull %0, i1 noundef zeroext true) #4
  br label %21

21:                                               ; preds = %20, %17
  tail call void @pa(ptr noundef nonnull %0, ptr noundef nonnull %1, i1 noundef zeroext true) #4
  %22 = load ptr, ptr %0, align 8, !tbaa !5
  %23 = load i32, ptr %22, align 8, !tbaa !9
  %24 = icmp eq i32 %23, 5
  br i1 %24, label %25, label %26

25:                                               ; preds = %21
  tail call void @ra(ptr noundef nonnull %0, i1 noundef zeroext true) #4
  br label %26

26:                                               ; preds = %25, %21
  tail call void @pa(ptr noundef nonnull %0, ptr noundef nonnull %1, i1 noundef zeroext true) #4
  %27 = load ptr, ptr %0, align 8, !tbaa !5
  %28 = load i32, ptr %27, align 8, !tbaa !9
  %29 = icmp eq i32 %28, 5
  br i1 %29, label %30, label %31

30:                                               ; preds = %26
  tail call void @ra(ptr noundef nonnull %0, i1 noundef zeroext true) #4
  br label %31

31:                                               ; preds = %30, %26
  tail call void @ft_lstc_clear(ptr noundef nonnull %0) #4
  tail call void @exit(i32 noundef 0) #5
  unreachable
}

; Function Attrs: nounwind uwtable
declare dso_local void @sort_three(ptr noundef) local_unnamed_addr #3

declare void @ft_lstc_clear(ptr noundef) local_unnamed_addr #1

declare void @ra(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

declare void @pb(ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

declare void @get_index(ptr noundef, i64, i32) local_unnamed_addr #1

declare void @rra(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

declare void @pa(ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

attributes #0 = { noreturn 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 #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 = { noreturn 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 #3 = { 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 #4 = { nounwind }
attributes #5 = { noreturn 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"s_listc", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !6, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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