; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Bus/Usb (UsbBotExecCommand)

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

@.str.5 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [41 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @UsbBotExecCommand(ptr noundef %0, ptr noundef %1, i8 noundef zeroext %2, i32 noundef %3, ptr noundef %4, i32 noundef %5, i8 noundef zeroext %6, i32 noundef %7, ptr noundef %8) #0 {
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i8, align 1
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i8, align 1
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca i8, align 1
  %24 = alloca i32, align 4
  store ptr %0, ptr %11, align 8, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !5
  store i8 %2, ptr %13, align 1, !tbaa !9
  store i32 %3, ptr %14, align 4, !tbaa !10
  store ptr %4, ptr %15, align 8, !tbaa !5
  store i32 %5, ptr %16, align 4, !tbaa !10
  store i8 %6, ptr %17, align 1, !tbaa !9
  store i32 %7, ptr %18, align 4, !tbaa !10
  store ptr %8, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %23) #3
  %25 = load ptr, ptr %19, align 8, !tbaa !5
  store i32 1, ptr %25, align 4, !tbaa !10
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %26, ptr %20, align 8, !tbaa !5
  %27 = load ptr, ptr %20, align 8, !tbaa !5
  %28 = load ptr, ptr %12, align 8, !tbaa !5
  %29 = load i8, ptr %13, align 1, !tbaa !9
  %30 = load i32, ptr %14, align 4, !tbaa !10
  %31 = load i32, ptr %16, align 4, !tbaa !10
  %32 = load i8, ptr %17, align 1, !tbaa !9
  %33 = call i64 @UsbBotSendCommand(ptr noundef %27, ptr noundef %28, i8 noundef zeroext %29, i32 noundef %30, i32 noundef %31, i8 noundef zeroext %32)
  store i64 %33, ptr %21, align 8, !tbaa !12
  %34 = load i64, ptr %21, align 8, !tbaa !12
  %35 = icmp slt i64 %34, 0
  br i1 %35, label %36, label %53

36:                                               ; preds = %9
  br label %37

37:                                               ; preds = %36
  %38 = call zeroext i8 @DebugPrintEnabled()
  %39 = icmp ne i8 %38, 0
  br i1 %39, label %40, label %49

40:                                               ; preds = %37
  br label %41

41:                                               ; preds = %40
  %42 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %43 = icmp ne i8 %42, 0
  br i1 %43, label %44, label %46

44:                                               ; preds = %41
  %45 = load i64, ptr %21, align 8, !tbaa !12
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str.5, i64 noundef %45)
  br label %46

46:                                               ; preds = %44, %41
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48, %37
  br label %50

50:                                               ; preds = %49
  br label %51

51:                                               ; preds = %50
  %52 = load i64, ptr %21, align 8, !tbaa !12
  store i64 %52, ptr %10, align 8
  store i32 1, ptr %24, align 4
  br label %90

53:                                               ; preds = %9
  %54 = load i32, ptr %16, align 4, !tbaa !10
  %55 = zext i32 %54 to i64
  store i64 %55, ptr %22, align 8, !tbaa !12
  %56 = load ptr, ptr %20, align 8, !tbaa !5
  %57 = load i32, ptr %14, align 4, !tbaa !10
  %58 = load ptr, ptr %15, align 8, !tbaa !5
  %59 = load i32, ptr %18, align 4, !tbaa !10
  %60 = call i64 @UsbBotDataTransfer(ptr noundef %56, i32 noundef %57, ptr noundef %58, ptr noundef %22, i32 noundef %59)
  %61 = load ptr, ptr %20, align 8, !tbaa !5
  %62 = load i32, ptr %16, align 4, !tbaa !10
  %63 = call i64 @UsbBotGetStatus(ptr noundef %61, i32 noundef %62, ptr noundef %23)
  store i64 %63, ptr %21, align 8, !tbaa !12
  %64 = load i64, ptr %21, align 8, !tbaa !12
  %65 = icmp slt i64 %64, 0
  br i1 %65, label %66, label %83

66:                                               ; preds = %53
  br label %67

67:                                               ; preds = %66
  %68 = call zeroext i8 @DebugPrintEnabled()
  %69 = icmp ne i8 %68, 0
  br i1 %69, label %70, label %79

70:                                               ; preds = %67
  br label %71

71:                                               ; preds = %70
  %72 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %73 = icmp ne i8 %72, 0
  br i1 %73, label %74, label %76

74:                                               ; preds = %71
  %75 = load i64, ptr %21, align 8, !tbaa !12
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str.6, i64 noundef %75)
  br label %76

76:                                               ; preds = %74, %71
  br label %77

77:                                               ; preds = %76
  br label %78

78:                                               ; preds = %77
  br label %79

79:                                               ; preds = %78, %67
  br label %80

80:                                               ; preds = %79
  br label %81

81:                                               ; preds = %80
  %82 = load i64, ptr %21, align 8, !tbaa !12
  store i64 %82, ptr %10, align 8
  store i32 1, ptr %24, align 4
  br label %90

83:                                               ; preds = %53
  %84 = load i8, ptr %23, align 1, !tbaa !9
  %85 = zext i8 %84 to i32
  %86 = icmp eq i32 %85, 0
  br i1 %86, label %87, label %89

87:                                               ; preds = %83
  %88 = load ptr, ptr %19, align 8, !tbaa !5
  store i32 0, ptr %88, align 4, !tbaa !10
  br label %89

89:                                               ; preds = %87, %83
  store i64 0, ptr %10, align 8
  store i32 1, ptr %24, align 4
  br label %90

90:                                               ; preds = %89, %81, %51
  call void @llvm.lifetime.end.p0(i64 1, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  %91 = load i64, ptr %10, align 8
  ret i64 %91
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @UsbBotSendCommand(ptr noundef, ptr noundef, i8 noundef zeroext, i32 noundef, i32 noundef, i8 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @UsbBotDataTransfer(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef) #0

declare zeroext i8 @DebugPrintEnabled() #2

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) #2

declare void @DebugPrint(i64 noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @UsbBotGetStatus(ptr noundef, i32 noundef, ptr noundef) #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" }
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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}


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

@.str.5 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [41 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775808, 1) i64 @UsbBotExecCommand(ptr noundef %0, ptr noundef %1, i8 noundef zeroext %2, i32 noundef %3, ptr noundef %4, i32 noundef %5, i8 noundef zeroext %6, i32 noundef %7, ptr nocapture noundef writeonly %8) local_unnamed_addr #0 {
  %10 = alloca i64, align 8
  %11 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %11) #3
  store i32 1, ptr %8, align 4, !tbaa !5
  %12 = tail call i64 @UsbBotSendCommand(ptr noundef %0, ptr noundef %1, i8 noundef zeroext %2, i32 noundef %3, i32 noundef %5, i8 noundef zeroext %6)
  %13 = icmp slt i64 %12, 0
  br i1 %13, label %14, label %19

14:                                               ; preds = %9
  %15 = tail call zeroext i8 @DebugPrintEnabled() #3
  %.not25 = icmp eq i8 %15, 0
  br i1 %.not25, label %33, label %16

16:                                               ; preds = %14
  %17 = tail call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #3
  %.not26 = icmp eq i8 %17, 0
  br i1 %.not26, label %33, label %18

18:                                               ; preds = %16
  tail call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str.5, i64 noundef %12) #3
  br label %33

19:                                               ; preds = %9
  %20 = zext i32 %5 to i64
  store i64 %20, ptr %10, align 8, !tbaa !9
  %21 = call i64 @UsbBotDataTransfer(ptr noundef %0, i32 noundef %3, ptr noundef %4, ptr noundef nonnull %10, i32 noundef %7)
  %22 = call i64 @UsbBotGetStatus(ptr noundef %0, i32 noundef %5, ptr noundef nonnull %11)
  %23 = icmp slt i64 %22, 0
  br i1 %23, label %24, label %29

24:                                               ; preds = %19
  %25 = call zeroext i8 @DebugPrintEnabled() #3
  %.not = icmp eq i8 %25, 0
  br i1 %.not, label %33, label %26

26:                                               ; preds = %24
  %27 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #3
  %.not24 = icmp eq i8 %27, 0
  br i1 %.not24, label %33, label %28

28:                                               ; preds = %26
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str.6, i64 noundef %22) #3
  br label %33

29:                                               ; preds = %19
  %30 = load i8, ptr %11, align 1, !tbaa !11
  %31 = icmp eq i8 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %29
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %29, %32, %24, %28, %26, %14, %18, %16
  %.0 = phi i64 [ %12, %16 ], [ %12, %18 ], [ %12, %14 ], [ %22, %26 ], [ %22, %28 ], [ %22, %24 ], [ 0, %32 ], [ 0, %29 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #3
  ret i64 %.0
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @UsbBotSendCommand(ptr noundef, ptr noundef, i8 noundef zeroext, i32 noundef, i32 noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @UsbBotDataTransfer(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare zeroext i8 @DebugPrintEnabled() local_unnamed_addr #2

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) local_unnamed_addr #2

declare void @DebugPrint(i64 noundef, ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @UsbBotGetStatus(ptr noundef, i32 noundef, ptr 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" }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!7, !7, i64 0}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass