; LLVM IR from pmwkaa/monotone :: monotone/engine/engine (op)

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
define dso_local void @engine_drop(ptr noundef %0, i64 noundef %1, i1 noundef zeroext %2, i32 noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  %11 = zext i1 %2 to i8
  store i8 %11, ptr %7, align 1, !tbaa !11
  store i32 %3, ptr %8, align 4, !tbaa !13
  %12 = load i32, ptr %8, align 4, !tbaa !13
  %13 = icmp eq i32 %12, 9
  br i1 %13, label %14, label %36

14:                                               ; preds = %4
  br label %15

15:                                               ; preds = %34, %14
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #2
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load i64, ptr %6, align 8, !tbaa !9
  %18 = load i8, ptr %7, align 1, !tbaa !11, !range !15, !noundef !16
  %19 = trunc i8 %18 to i1
  %20 = load i32, ptr %8, align 4, !tbaa !13
  %21 = call zeroext i1 @engine_drop_file(ptr noundef %16, i64 noundef %17, i1 noundef zeroext %19, i1 noundef zeroext false, i32 noundef %20)
  %22 = zext i1 %21 to i8
  store i8 %22, ptr %9, align 1, !tbaa !11
  %23 = load i8, ptr %9, align 1, !tbaa !11, !range !15, !noundef !16
  %24 = trunc i8 %23 to i1
  br i1 %24, label %26, label %25

25:                                               ; preds = %15
  store i32 2, ptr %10, align 4
  br label %32

26:                                               ; preds = %15
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load i64, ptr %6, align 8, !tbaa !9
  %29 = call zeroext i1 @engine_drop_reference(ptr noundef %27, i64 noundef %28)
  br i1 %29, label %30, label %31

30:                                               ; preds = %26
  store i32 2, ptr %10, align 4
  br label %32

31:                                               ; preds = %26
  store i32 0, ptr %10, align 4
  br label %32

32:                                               ; preds = %31, %30, %25
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #2
  %33 = load i32, ptr %10, align 4
  switch i32 %33, label %44 [
    i32 0, label %34
    i32 2, label %35
  ]

34:                                               ; preds = %32
  br label %15

35:                                               ; preds = %32
  br label %43

36:                                               ; preds = %4
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load i64, ptr %6, align 8, !tbaa !9
  %39 = load i8, ptr %7, align 1, !tbaa !11, !range !15, !noundef !16
  %40 = trunc i8 %39 to i1
  %41 = load i32, ptr %8, align 4, !tbaa !13
  %42 = call zeroext i1 @engine_drop_file(ptr noundef %37, i64 noundef %38, i1 noundef zeroext %40, i1 noundef zeroext false, i32 noundef %41)
  br label %43

43:                                               ; preds = %36, %35
  ret void

44:                                               ; preds = %32
  unreachable
}

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @engine_drop_file(ptr noundef, i64 noundef, i1 noundef zeroext, i1 noundef zeroext, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @engine_drop_reference(ptr noundef, i64 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{i8 0, i8 2}
!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: nounwind uwtable
define dso_local void @engine_drop(ptr noundef %0, i64 noundef %1, i1 noundef zeroext %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp eq i32 %3, 9
  br i1 %5, label %.preheader, label %9

.preheader:                                       ; preds = %4, %7
  %6 = tail call zeroext i1 @engine_drop_file(ptr noundef %0, i64 noundef %1, i1 noundef zeroext %2, i1 noundef zeroext false, i32 noundef 9)
  br i1 %6, label %7, label %.thread

7:                                                ; preds = %.preheader
  %8 = tail call zeroext i1 @engine_drop_reference(ptr noundef %0, i64 noundef %1)
  br i1 %8, label %.thread, label %.preheader

9:                                                ; preds = %4
  %10 = tail call zeroext i1 @engine_drop_file(ptr noundef %0, i64 noundef %1, i1 noundef zeroext %2, i1 noundef zeroext false, i32 noundef %3)
  br label %.thread

.thread:                                          ; preds = %7, %.preheader, %9
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @engine_drop_file(ptr noundef, i64 noundef, i1 noundef zeroext, i1 noundef zeroext, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @engine_drop_reference(ptr noundef, i64 noundef) local_unnamed_addr #0

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" }

!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)"}


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