; LLVM IR from VAR-solutions/Algorithms :: Combinatorial Game Theory/Alpha-Beta Pruning/alphabeta.ll (Z7minimaxiibPiii)

; 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: mustprogress uwtable
define dso_local noundef i32 @_Z7minimaxiibPiii(i32 noundef %0, i32 noundef %1, i1 noundef zeroext %2, ptr noundef %3, i32 noundef %4, i32 noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store i32 %0, ptr %8, align 4, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !5
  %21 = zext i1 %2 to i8
  store i8 %21, ptr %10, align 1, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !11
  store i32 %4, ptr %12, align 4, !tbaa !5
  store i32 %5, ptr %13, align 4, !tbaa !5
  %22 = load i32, ptr %8, align 4, !tbaa !5
  %23 = icmp eq i32 %22, 3
  br i1 %23, label %24, label %30

24:                                               ; preds = %6
  %25 = load ptr, ptr %11, align 8, !tbaa !11
  %26 = load i32, ptr %9, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i32, ptr %25, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  store i32 %29, ptr %7, align 4
  br label %101

30:                                               ; preds = %6
  %31 = load i8, ptr %10, align 1, !tbaa !9, !range !13, !noundef !14
  %32 = trunc i8 %31 to i1
  br i1 %32, label %33, label %67

33:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 -1000, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %61, %33
  %35 = load i32, ptr %15, align 4, !tbaa !5
  %36 = icmp slt i32 %35, 2
  br i1 %36, label %38, label %37

37:                                               ; preds = %34
  store i32 2, ptr %16, align 4
  br label %64

38:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %39 = load i32, ptr %8, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  %41 = load i32, ptr %9, align 4, !tbaa !5
  %42 = mul nsw i32 %41, 2
  %43 = load i32, ptr %15, align 4, !tbaa !5
  %44 = add nsw i32 %42, %43
  %45 = load ptr, ptr %11, align 8, !tbaa !11
  %46 = load i32, ptr %12, align 4, !tbaa !5
  %47 = load i32, ptr %13, align 4, !tbaa !5
  %48 = call noundef i32 @_Z7minimaxiibPiii(i32 noundef %40, i32 noundef %44, i1 noundef zeroext false, ptr noundef %45, i32 noundef %46, i32 noundef %47)
  store i32 %48, ptr %17, align 4, !tbaa !5
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %14, ptr noundef nonnull align 4 dereferenceable(4) %17)
  %50 = load i32, ptr %49, align 4, !tbaa !5
  store i32 %50, ptr %14, align 4, !tbaa !5
  %51 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %52 = load i32, ptr %51, align 4, !tbaa !5
  store i32 %52, ptr %12, align 4, !tbaa !5
  %53 = load i32, ptr %13, align 4, !tbaa !5
  %54 = load i32, ptr %12, align 4, !tbaa !5
  %55 = icmp sle i32 %53, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %38
  store i32 2, ptr %16, align 4
  br label %58

57:                                               ; preds = %38
  store i32 0, ptr %16, align 4
  br label %58

58:                                               ; preds = %57, %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  %59 = load i32, ptr %16, align 4
  switch i32 %59, label %64 [
    i32 0, label %60
  ]

60:                                               ; preds = %58
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %15, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %15, align 4, !tbaa !5
  br label %34, !llvm.loop !15

64:                                               ; preds = %58, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %14, align 4, !tbaa !5
  store i32 %66, ptr %7, align 4
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %101

67:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  store i32 1000, ptr %18, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  store i32 0, ptr %19, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %95, %67
  %69 = load i32, ptr %19, align 4, !tbaa !5
  %70 = icmp slt i32 %69, 2
  br i1 %70, label %72, label %71

71:                                               ; preds = %68
  store i32 5, ptr %16, align 4
  br label %98

72:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %73 = load i32, ptr %8, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  %75 = load i32, ptr %9, align 4, !tbaa !5
  %76 = mul nsw i32 %75, 2
  %77 = load i32, ptr %19, align 4, !tbaa !5
  %78 = add nsw i32 %76, %77
  %79 = load ptr, ptr %11, align 8, !tbaa !11
  %80 = load i32, ptr %12, align 4, !tbaa !5
  %81 = load i32, ptr %13, align 4, !tbaa !5
  %82 = call noundef i32 @_Z7minimaxiibPiii(i32 noundef %74, i32 noundef %78, i1 noundef zeroext true, ptr noundef %79, i32 noundef %80, i32 noundef %81)
  store i32 %82, ptr %20, align 4, !tbaa !5
  %83 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %18, ptr noundef nonnull align 4 dereferenceable(4) %20)
  %84 = load i32, ptr %83, align 4, !tbaa !5
  store i32 %84, ptr %18, align 4, !tbaa !5
  %85 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull align 4 dereferenceable(4) %18)
  %86 = load i32, ptr %85, align 4, !tbaa !5
  store i32 %86, ptr %13, align 4, !tbaa !5
  %87 = load i32, ptr %13, align 4, !tbaa !5
  %88 = load i32, ptr %12, align 4, !tbaa !5
  %89 = icmp sle i32 %87, %88
  br i1 %89, label %90, label %91

90:                                               ; preds = %72
  store i32 5, ptr %16, align 4
  br label %92

91:                                               ; preds = %72
  store i32 0, ptr %16, align 4
  br label %92

92:                                               ; preds = %91, %90
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  %93 = load i32, ptr %16, align 4
  switch i32 %93, label %98 [
    i32 0, label %94
  ]

94:                                               ; preds = %92
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %19, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %19, align 4, !tbaa !5
  br label %68, !llvm.loop !17

98:                                               ; preds = %92, %71
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  br label %99

99:                                               ; preds = %98
  %100 = load i32, ptr %18, align 4, !tbaa !5
  store i32 %100, ptr %7, align 4
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  br label %101

101:                                              ; preds = %99, %65, %24
  %102 = load i32, ptr %7, align 4
  ret i32 %102
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z7minimaxiibPiii(i32 noundef %0, i32 noundef %1, i1 noundef zeroext %2, ptr noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 %4, ptr %7, align 4, !tbaa !5
  store i32 %5, ptr %8, align 4, !tbaa !5
  %13 = icmp eq i32 %0, 3
  br i1 %13, label %14, label %18

14:                                               ; preds = %6
  %15 = sext i32 %1 to i64
  %16 = getelementptr inbounds i32, ptr %3, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  br label %49

18:                                               ; preds = %6
  %19 = add nsw i32 %0, 1
  %20 = shl nsw i32 %1, 1
  br i1 %2, label %21, label %35

21:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #3
  store i32 -1000, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #3
  %22 = tail call noundef i32 @_Z7minimaxiibPiii(i32 noundef %19, i32 noundef %20, i1 noundef zeroext false, ptr noundef %3, i32 noundef %4, i32 noundef %5)
  store i32 %22, ptr %10, align 4, !tbaa !5
  %23 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %24 = load i32, ptr %23, align 4, !tbaa !5
  store i32 %24, ptr %9, align 4, !tbaa !5
  %25 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %26 = load i32, ptr %25, align 4, !tbaa !5
  store i32 %26, ptr %7, align 4, !tbaa !5
  %.not23 = icmp slt i32 %26, %5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #3
  br i1 %.not23, label %27, label %33

27:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #3
  %28 = or disjoint i32 %20, 1
  %29 = call noundef i32 @_Z7minimaxiibPiii(i32 noundef %19, i32 noundef %28, i1 noundef zeroext false, ptr noundef %3, i32 noundef %26, i32 noundef %5)
  store i32 %29, ptr %10, align 4, !tbaa !5
  %30 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %31 = load i32, ptr %30, align 4, !tbaa !5
  store i32 %31, ptr %9, align 4, !tbaa !5
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %9)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #3
  br label %33

33:                                               ; preds = %27, %21
  %34 = load i32, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  br label %49

35:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #3
  store i32 1000, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #3
  %36 = tail call noundef i32 @_Z7minimaxiibPiii(i32 noundef %19, i32 noundef %20, i1 noundef zeroext true, ptr noundef %3, i32 noundef %4, i32 noundef %5)
  store i32 %36, ptr %12, align 4, !tbaa !5
  %37 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %38 = load i32, ptr %37, align 4, !tbaa !5
  store i32 %38, ptr %11, align 4, !tbaa !5
  %39 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %40 = load i32, ptr %39, align 4, !tbaa !5
  store i32 %40, ptr %8, align 4, !tbaa !5
  %.not = icmp sgt i32 %40, %4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #3
  br i1 %.not, label %41, label %47

41:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #3
  %42 = or disjoint i32 %20, 1
  %43 = call noundef i32 @_Z7minimaxiibPiii(i32 noundef %19, i32 noundef %42, i1 noundef zeroext true, ptr noundef %3, i32 noundef %4, i32 noundef %40)
  store i32 %43, ptr %12, align 4, !tbaa !5
  %44 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %45 = load i32, ptr %44, align 4, !tbaa !5
  store i32 %45, ptr %11, align 4, !tbaa !5
  %46 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %11)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #3
  br label %47

47:                                               ; preds = %41, %35
  %48 = load i32, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #3
  br label %49

49:                                               ; preds = %47, %33, %14
  %.021 = phi i32 [ %17, %14 ], [ %34, %33 ], [ %48, %47 ]
  ret i32 %.021
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) 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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: ADCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass