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

; 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.40 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [28 x i8], align 1

; 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

declare zeroext i8 @DebugPrintEnabled() #1

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @UfsEnableHostController(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @UfsDeviceDetection(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @UfsInitTaskManagementRequestList(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @UfsInitTransferRequestList(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @UfsControllerInit(ptr noundef %0) #2 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = call i64 @UfsEnableHostController(ptr noundef %6)
  store i64 %7, ptr %4, align 8, !tbaa !9
  %8 = load i64, ptr %4, align 8, !tbaa !9
  %9 = icmp slt i64 %8, 0
  br i1 %9, label %10, label %27

10:                                               ; preds = %1
  br label %11

11:                                               ; preds = %10
  %12 = call zeroext i8 @DebugPrintEnabled()
  %13 = icmp ne i8 %12, 0
  br i1 %13, label %14, label %23

14:                                               ; preds = %11
  br label %15

15:                                               ; preds = %14
  %16 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %17 = icmp ne i8 %16, 0
  br i1 %17, label %18, label %20

18:                                               ; preds = %15
  %19 = load i64, ptr %4, align 8, !tbaa !9
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str.40, i64 noundef %19)
  br label %20

20:                                               ; preds = %18, %15
  br label %21

21:                                               ; preds = %20
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22, %11
  br label %24

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %24
  %26 = load i64, ptr %4, align 8, !tbaa !9
  store i64 %26, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %108

27:                                               ; preds = %1
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = call i64 @UfsDeviceDetection(ptr noundef %28)
  store i64 %29, ptr %4, align 8, !tbaa !9
  %30 = load i64, ptr %4, align 8, !tbaa !9
  %31 = icmp slt i64 %30, 0
  br i1 %31, label %32, label %49

32:                                               ; preds = %27
  br label %33

33:                                               ; preds = %32
  %34 = call zeroext i8 @DebugPrintEnabled()
  %35 = icmp ne i8 %34, 0
  br i1 %35, label %36, label %45

36:                                               ; preds = %33
  br label %37

37:                                               ; preds = %36
  %38 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %39 = icmp ne i8 %38, 0
  br i1 %39, label %40, label %42

40:                                               ; preds = %37
  %41 = load i64, ptr %4, align 8, !tbaa !9
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str.41, i64 noundef %41)
  br label %42

42:                                               ; preds = %40, %37
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44, %33
  br label %46

46:                                               ; preds = %45
  br label %47

47:                                               ; preds = %46
  %48 = load i64, ptr %4, align 8, !tbaa !9
  store i64 %48, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %108

49:                                               ; preds = %27
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = call i64 @UfsInitTaskManagementRequestList(ptr noundef %50)
  store i64 %51, ptr %4, align 8, !tbaa !9
  %52 = load i64, ptr %4, align 8, !tbaa !9
  %53 = icmp slt i64 %52, 0
  br i1 %53, label %54, label %71

54:                                               ; preds = %49
  br label %55

55:                                               ; preds = %54
  %56 = call zeroext i8 @DebugPrintEnabled()
  %57 = icmp ne i8 %56, 0
  br i1 %57, label %58, label %67

58:                                               ; preds = %55
  br label %59

59:                                               ; preds = %58
  %60 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %61 = icmp ne i8 %60, 0
  br i1 %61, label %62, label %64

62:                                               ; preds = %59
  %63 = load i64, ptr %4, align 8, !tbaa !9
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str.42, i64 noundef %63)
  br label %64

64:                                               ; preds = %62, %59
  br label %65

65:                                               ; preds = %64
  br label %66

66:                                               ; preds = %65
  br label %67

67:                                               ; preds = %66, %55
  br label %68

68:                                               ; preds = %67
  br label %69

69:                                               ; preds = %68
  %70 = load i64, ptr %4, align 8, !tbaa !9
  store i64 %70, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %108

71:                                               ; preds = %49
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = call i64 @UfsInitTransferRequestList(ptr noundef %72)
  store i64 %73, ptr %4, align 8, !tbaa !9
  %74 = load i64, ptr %4, align 8, !tbaa !9
  %75 = icmp slt i64 %74, 0
  br i1 %75, label %76, label %93

76:                                               ; preds = %71
  br label %77

77:                                               ; preds = %76
  %78 = call zeroext i8 @DebugPrintEnabled()
  %79 = icmp ne i8 %78, 0
  br i1 %79, label %80, label %89

80:                                               ; preds = %77
  br label %81

81:                                               ; preds = %80
  %82 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %83 = icmp ne i8 %82, 0
  br i1 %83, label %84, label %86

84:                                               ; preds = %81
  %85 = load i64, ptr %4, align 8, !tbaa !9
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str.43, i64 noundef %85)
  br label %86

86:                                               ; preds = %84, %81
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87
  br label %89

89:                                               ; preds = %88, %77
  br label %90

90:                                               ; preds = %89
  br label %91

91:                                               ; preds = %90
  %92 = load i64, ptr %4, align 8, !tbaa !9
  store i64 %92, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %108

93:                                               ; preds = %71
  br label %94

94:                                               ; preds = %93
  %95 = call zeroext i8 @DebugPrintEnabled()
  %96 = icmp ne i8 %95, 0
  br i1 %96, label %97, label %105

97:                                               ; preds = %94
  br label %98

98:                                               ; preds = %97
  %99 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 64)
  %100 = icmp ne i8 %99, 0
  br i1 %100, label %101, label %102

101:                                              ; preds = %98
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 64, ptr noundef @.str.44)
  br label %102

102:                                              ; preds = %101, %98
  br label %103

103:                                              ; preds = %102
  br label %104

104:                                              ; preds = %103
  br label %105

105:                                              ; preds = %104, %94
  br label %106

106:                                              ; preds = %105
  br label %107

107:                                              ; preds = %106
  store i64 0, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %108

108:                                              ; preds = %107, %91, %69, %47, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %109 = load i64, ptr %2, align 8
  ret i64 %109
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"any pointer", !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}


; 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.40 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [28 x i8], align 1

declare zeroext i8 @DebugPrintEnabled() local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @UfsEnableHostController(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @UfsDeviceDetection(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @UfsInitTaskManagementRequestList(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @UfsInitTransferRequestList(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775808, 1) i64 @UfsControllerInit(ptr noundef %0) local_unnamed_addr #1 {
  %2 = tail call i64 @UfsEnableHostController(ptr noundef %0)
  %3 = icmp slt i64 %2, 0
  br i1 %3, label %4, label %9

4:                                                ; preds = %1
  %5 = tail call zeroext i8 @DebugPrintEnabled() #2
  %.not27 = icmp eq i8 %5, 0
  br i1 %.not27, label %37, label %6

6:                                                ; preds = %4
  %7 = tail call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #2
  %.not28 = icmp eq i8 %7, 0
  br i1 %.not28, label %37, label %8

8:                                                ; preds = %6
  tail call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str.40, i64 noundef %2) #2
  br label %37

9:                                                ; preds = %1
  %10 = tail call i64 @UfsDeviceDetection(ptr noundef %0)
  %11 = icmp slt i64 %10, 0
  br i1 %11, label %12, label %17

12:                                               ; preds = %9
  %13 = tail call zeroext i8 @DebugPrintEnabled() #2
  %.not25 = icmp eq i8 %13, 0
  br i1 %.not25, label %37, label %14

14:                                               ; preds = %12
  %15 = tail call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #2
  %.not26 = icmp eq i8 %15, 0
  br i1 %.not26, label %37, label %16

16:                                               ; preds = %14
  tail call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str.41, i64 noundef %10) #2
  br label %37

17:                                               ; preds = %9
  %18 = tail call i64 @UfsInitTaskManagementRequestList(ptr noundef %0)
  %19 = icmp slt i64 %18, 0
  br i1 %19, label %20, label %25

20:                                               ; preds = %17
  %21 = tail call zeroext i8 @DebugPrintEnabled() #2
  %.not23 = icmp eq i8 %21, 0
  br i1 %.not23, label %37, label %22

22:                                               ; preds = %20
  %23 = tail call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #2
  %.not24 = icmp eq i8 %23, 0
  br i1 %.not24, label %37, label %24

24:                                               ; preds = %22
  tail call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str.42, i64 noundef %18) #2
  br label %37

25:                                               ; preds = %17
  %26 = tail call i64 @UfsInitTransferRequestList(ptr noundef %0)
  %27 = icmp slt i64 %26, 0
  %28 = tail call zeroext i8 @DebugPrintEnabled() #2
  %.not21 = icmp eq i8 %28, 0
  br i1 %27, label %29, label %33

29:                                               ; preds = %25
  br i1 %.not21, label %37, label %30

30:                                               ; preds = %29
  %31 = tail call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #2
  %.not22 = icmp eq i8 %31, 0
  br i1 %.not22, label %37, label %32

32:                                               ; preds = %30
  tail call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str.43, i64 noundef %26) #2
  br label %37

33:                                               ; preds = %25
  br i1 %.not21, label %37, label %34

34:                                               ; preds = %33
  %35 = tail call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 64) #2
  %.not20 = icmp eq i8 %35, 0
  br i1 %.not20, label %37, label %36

36:                                               ; preds = %34
  tail call void (i64, ptr, ...) @DebugPrint(i64 noundef 64, ptr noundef nonnull @.str.44) #2
  br label %37

37:                                               ; preds = %33, %36, %34, %29, %32, %30, %20, %24, %22, %12, %16, %14, %4, %8, %6
  %.0 = phi i64 [ %2, %6 ], [ %2, %8 ], [ %2, %4 ], [ %10, %14 ], [ %10, %16 ], [ %10, %12 ], [ %18, %22 ], [ %18, %24 ], [ %18, %20 ], [ %26, %30 ], [ %26, %32 ], [ %26, %29 ], [ 0, %34 ], [ 0, %36 ], [ 0, %33 ]
  ret i64 %.0
}

attributes #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 = { 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)"}


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