; LLVM IR from simon-zerisenay/42_Push_Swap :: bonus (validate_args_bonus)

; 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 i32 @have_duplicates(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  store i32 0, ptr %5, align 4, !tbaa !9
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = call ptr @ft_split(ptr noundef %8, i8 noundef signext 32)
  store ptr %9, ptr %3, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %76, %1
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds ptr, ptr %11, i64 %13
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %79

17:                                               ; preds = %10
  %18 = load i32, ptr %4, align 4, !tbaa !9
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %5, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %73, %17
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds ptr, ptr %21, i64 %23
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %76

27:                                               ; preds = %20
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds ptr, ptr %28, i64 %30
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = call i64 @ft_strlen(ptr noundef %32)
  %34 = trunc i64 %33 to i32
  store i32 %34, ptr %6, align 4, !tbaa !9
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds ptr, ptr %35, i64 %37
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = call i64 @ft_strlen(ptr noundef %39)
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = load i32, ptr %4, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds ptr, ptr %41, i64 %43
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = call i64 @ft_strlen(ptr noundef %45)
  %47 = icmp ugt i64 %40, %46
  br i1 %47, label %48, label %56

48:                                               ; preds = %27
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = load i32, ptr %5, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds ptr, ptr %49, i64 %51
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  %54 = call i64 @ft_strlen(ptr noundef %53)
  %55 = trunc i64 %54 to i32
  store i32 %55, ptr %6, align 4, !tbaa !9
  br label %56

56:                                               ; preds = %48, %27
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = load i32, ptr %4, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds ptr, ptr %57, i64 %59
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = load i32, ptr %5, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds ptr, ptr %62, i64 %64
  %66 = load ptr, ptr %65, align 8, !tbaa !5
  %67 = load i32, ptr %6, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = call i32 @ft_strncmp(ptr noundef %61, ptr noundef %66, i64 noundef %68)
  %70 = icmp eq i32 %69, 0
  br i1 %70, label %71, label %73

71:                                               ; preds = %56
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free_storage(ptr noundef %3, ptr noundef %72)
  br label %73

73:                                               ; preds = %71, %56
  %74 = load i32, ptr %5, align 4, !tbaa !9
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %5, align 4, !tbaa !9
  br label %20, !llvm.loop !11

76:                                               ; preds = %20
  %77 = load i32, ptr %4, align 4, !tbaa !9
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %4, align 4, !tbaa !9
  br label %10, !llvm.loop !13

79:                                               ; preds = %10
  call void @free_array(ptr noundef %3)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret i32 1
}

; 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

declare i64 @ft_strlen(ptr noundef) #2

declare i32 @ft_strncmp(ptr noundef, ptr noundef, i64 noundef) #2

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

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 }

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


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

.loopexit:                                        ; preds = %37
  %.phi.trans.insert = getelementptr inbounds ptr, ptr %38, i64 %indvars.iv.next25
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !5
  %.not = icmp eq ptr %.pre, null
  %indvars.iv.next = add nuw i64 %indvars.iv, 1
  br i1 %.not, label %._crit_edge, label %.lr.ph20, !llvm.loop !9

.lr.ph20:                                         ; preds = %1, %.loopexit
  %6 = phi ptr [ %38, %.loopexit ], [ %4, %1 ]
  %indvars.iv24 = phi i64 [ %indvars.iv.next25, %.loopexit ], [ 0, %1 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %.loopexit ], [ 1, %1 ]
  %indvars.iv.next25 = add nuw nsw i64 %indvars.iv24, 1
  %7 = getelementptr inbounds ptr, ptr %6, i64 %indvars.iv.next25
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %.not1516 = icmp eq ptr %8, null
  br i1 %.not1516, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph20, %37
  %indvars.iv21 = phi i64 [ %indvars.iv.next22, %37 ], [ %indvars.iv, %.lr.ph20 ]
  %9 = phi ptr [ %38, %37 ], [ %6, %.lr.ph20 ]
  %10 = getelementptr inbounds ptr, ptr %9, i64 %indvars.iv24
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = call i64 @ft_strlen(ptr noundef %11) #3
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds ptr, ptr %13, i64 %indvars.iv21
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = call i64 @ft_strlen(ptr noundef %15) #3
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds ptr, ptr %17, i64 %indvars.iv24
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %20 = call i64 @ft_strlen(ptr noundef %19) #3
  %21 = icmp ugt i64 %16, %20
  br i1 %21, label %22, label %27

22:                                               ; preds = %.lr.ph
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds ptr, ptr %23, i64 %indvars.iv21
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = call i64 @ft_strlen(ptr noundef %25) #3
  br label %27

27:                                               ; preds = %22, %.lr.ph
  %.0.in = phi i64 [ %26, %22 ], [ %12, %.lr.ph ]
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds ptr, ptr %28, i64 %indvars.iv24
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = getelementptr inbounds ptr, ptr %28, i64 %indvars.iv21
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %sext = shl i64 %.0.in, 32
  %33 = ashr exact i64 %sext, 32
  %34 = call i32 @ft_strncmp(ptr noundef %30, ptr noundef %32, i64 noundef %33) #3
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %27
  call void @free_storage(ptr noundef nonnull %2, ptr noundef nonnull %0)
  br label %37

37:                                               ; preds = %36, %27
  %indvars.iv.next22 = add nuw nsw i64 %indvars.iv21, 1
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds ptr, ptr %38, i64 %indvars.iv.next22
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  %.not15 = icmp eq ptr %40, null
  br i1 %.not15, label %.loopexit, label %.lr.ph, !llvm.loop !11

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

; 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

declare i64 @ft_strlen(ptr noundef) local_unnamed_addr #2

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

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

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 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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