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

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

%struct.I2C_HOST_CONTEXT = type { i64, i64, ptr, ptr, i64, i8, %struct._LIST_ENTRY, %struct._EFI_I2C_HOST_PROTOCOL, ptr, ptr }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct._EFI_I2C_HOST_PROTOCOL = type { ptr, ptr }
%struct.I2C_REQUEST = type { i32, %struct._LIST_ENTRY, i64, i64, ptr, ptr, ptr }
%struct._EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL = type { ptr }
%struct.EFI_BOOT_SERVICES = type { %struct.EFI_TABLE_HEADER, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_TABLE_HEADER = type { i64, i32, i32, i32, i32 }

@gBS = external global ptr, align 8
@.str.12 = external hidden unnamed_addr constant [139 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [21 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

; Function Attrs: nounwind uwtable
declare dso_local void @I2cHostI2cBusConfigurationAvailable(ptr noundef, ptr noundef) #1

declare zeroext i8 @DebugAssertEnabled() #2

declare void @DebugAssert(ptr noundef, i64 noundef, ptr noundef) #2

declare ptr @GetFirstNode(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @I2cHostRequestEnable(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  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 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 -9223372036854775802, ptr %6, align 8, !tbaa !9
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.I2C_HOST_CONTEXT, ptr %10, i32 0, i32 8
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  store ptr %12, ptr %4, align 8, !tbaa !5
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.I2C_HOST_CONTEXT, ptr %13, i32 0, i32 6
  store ptr %14, ptr %8, align 8, !tbaa !5
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = call ptr @GetFirstNode(ptr noundef %15)
  store ptr %16, ptr %9, align 8, !tbaa !5
  %17 = call zeroext i8 @DebugAssertEnabled()
  %18 = zext i8 %17 to i32
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %30

20:                                               ; preds = %1
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = ptrtoint ptr %21 to i64
  %23 = sub i64 %22, ptrtoint (ptr getelementptr inbounds (%struct.I2C_REQUEST, ptr null, i32 0, i32 1) to i64)
  %24 = inttoptr i64 %23 to ptr
  %25 = getelementptr inbounds %struct.I2C_REQUEST, ptr %24, i32 0, i32 0
  %26 = load i32, ptr %25, align 8, !tbaa !15
  %27 = icmp ne i32 %26, 1380135497
  br i1 %27, label %28, label %30

28:                                               ; preds = %20
  call void @DebugAssert(ptr noundef @.str.12, i64 noundef 811, ptr noundef @.str.13)
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  br label %35

30:                                               ; preds = %20, %1
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = ptrtoint ptr %31 to i64
  %33 = sub i64 %32, ptrtoint (ptr getelementptr inbounds (%struct.I2C_REQUEST, ptr null, i32 0, i32 1) to i64)
  %34 = inttoptr i64 %33 to ptr
  br label %35

35:                                               ; preds = %30, %28
  %36 = phi ptr [ %29, %28 ], [ %34, %30 ]
  store ptr %36, ptr %5, align 8, !tbaa !5
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.I2C_REQUEST, ptr %37, i32 0, i32 2
  %39 = load i64, ptr %38, align 8, !tbaa !18
  store i64 %39, ptr %3, align 8, !tbaa !9
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.I2C_HOST_CONTEXT, ptr %40, i32 0, i32 1
  %42 = load i64, ptr %41, align 8, !tbaa !19
  %43 = load i64, ptr %3, align 8, !tbaa !9
  %44 = icmp ne i64 %42, %43
  br i1 %44, label %45, label %59

45:                                               ; preds = %35
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.I2C_HOST_CONTEXT, ptr %46, i32 0, i32 5
  store i8 1, ptr %47, align 8, !tbaa !20
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !21
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load i64, ptr %3, align 8, !tbaa !9
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.I2C_HOST_CONTEXT, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !23
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.I2C_HOST_CONTEXT, ptr %56, i32 0, i32 4
  %58 = call i64 %50(ptr noundef %51, i64 noundef %52, ptr noundef %55, ptr noundef %57)
  store i64 %58, ptr %6, align 8, !tbaa !9
  br label %74

59:                                               ; preds = %35
  %60 = load ptr, ptr @gBS, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %60, i32 0, i32 1
  %62 = load ptr, ptr %61, align 8, !tbaa !24
  %63 = call i64 %62(i64 noundef 16)
  store i64 %63, ptr %7, align 8, !tbaa !9
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.I2C_HOST_CONTEXT, ptr %64, i32 0, i32 4
  store i64 0, ptr %65, align 8, !tbaa !27
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.I2C_HOST_CONTEXT, ptr %66, i32 0, i32 2
  %68 = load ptr, ptr %67, align 8, !tbaa !23
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  call void @I2cHostI2cBusConfigurationAvailable(ptr noundef %68, ptr noundef %69)
  %70 = load ptr, ptr @gBS, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %70, i32 0, i32 2
  %72 = load ptr, ptr %71, align 8, !tbaa !28
  %73 = load i64, ptr %7, align 8, !tbaa !9
  call void %72(i64 noundef %73)
  br label %74

74:                                               ; preds = %59, %45
  %75 = load i64, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret i64 %75
}

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 = { "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}
!11 = !{!12, !6, i64 80}
!12 = !{!"", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !7, i64 40, !13, i64 48, !14, i64 64, !6, i64 80, !6, i64 88}
!13 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!14 = !{!"_EFI_I2C_HOST_PROTOCOL", !6, i64 0, !6, i64 8}
!15 = !{!16, !17, i64 0}
!16 = !{!"", !17, i64 0, !13, i64 8, !10, i64 24, !10, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!17 = !{!"int", !7, i64 0}
!18 = !{!16, !10, i64 24}
!19 = !{!12, !10, i64 8}
!20 = !{!12, !7, i64 40}
!21 = !{!22, !6, i64 0}
!22 = !{!"_EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL", !6, i64 0}
!23 = !{!12, !6, i64 16}
!24 = !{!25, !6, i64 24}
!25 = !{!"", !26, i64 0, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368}
!26 = !{!"", !10, i64 0, !17, i64 8, !17, i64 12, !17, i64 16, !17, i64 20}
!27 = !{!12, !10, i64 32}
!28 = !{!25, !6, i64 32}


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

@gBS = external local_unnamed_addr global ptr, align 8
@.str.12 = external hidden unnamed_addr constant [139 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [21 x i8], align 1

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

declare void @DebugAssert(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

declare ptr @GetFirstNode(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i64 @I2cHostRequestEnable(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 80
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 48
  %5 = tail call ptr @GetFirstNode(ptr noundef nonnull %4) #2
  %6 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %6, 0
  %.pre = ptrtoint ptr %5 to i64
  %.pre22 = add i64 %.pre, -8
  %.pre24 = inttoptr i64 %.pre22 to ptr
  br i1 %.not, label %._crit_edge, label %7

7:                                                ; preds = %1
  %8 = load i32, ptr %.pre24, align 8, !tbaa !13
  %.not20 = icmp eq i32 %8, 1380135497
  br i1 %.not20, label %._crit_edge, label %9

9:                                                ; preds = %7
  tail call void @DebugAssert(ptr noundef nonnull @.str.12, i64 noundef 811, ptr noundef nonnull @.str.13) #2
  br label %._crit_edge

._crit_edge:                                      ; preds = %1, %7, %9
  %10 = phi ptr [ %5, %9 ], [ %.pre24, %7 ], [ %.pre24, %1 ]
  %11 = getelementptr inbounds i8, ptr %10, i64 24
  %12 = load i64, ptr %11, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load i64, ptr %13, align 8, !tbaa !17
  %.not21 = icmp eq i64 %14, %12
  br i1 %.not21, label %22, label %15

15:                                               ; preds = %._crit_edge
  %16 = getelementptr inbounds i8, ptr %0, i64 40
  store i8 1, ptr %16, align 8, !tbaa !18
  %17 = load ptr, ptr %3, align 8, !tbaa !19
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !21
  %20 = getelementptr inbounds i8, ptr %0, i64 32
  %21 = tail call i64 %17(ptr noundef nonnull %3, i64 noundef %12, ptr noundef %19, ptr noundef nonnull %20) #2
  br label %33

22:                                               ; preds = %._crit_edge
  %23 = load ptr, ptr @gBS, align 8, !tbaa !22
  %24 = getelementptr inbounds i8, ptr %23, i64 24
  %25 = load ptr, ptr %24, align 8, !tbaa !23
  %26 = tail call i64 %25(i64 noundef 16) #2
  %27 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 0, ptr %27, align 8, !tbaa !26
  %28 = getelementptr inbounds i8, ptr %0, i64 16
  %29 = load ptr, ptr %28, align 8, !tbaa !21
  tail call void @I2cHostI2cBusConfigurationAvailable(ptr noundef %29, ptr noundef nonnull %0)
  %30 = load ptr, ptr @gBS, align 8, !tbaa !22
  %31 = getelementptr inbounds i8, ptr %30, i64 32
  %32 = load ptr, ptr %31, align 8, !tbaa !27
  tail call void %32(i64 noundef %26) #2
  br label %33

33:                                               ; preds = %22, %15
  %.0 = phi i64 [ %21, %15 ], [ -9223372036854775802, %22 ]
  ret i64 %.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 = { "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, !10, i64 80}
!6 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !7, i64 32, !8, i64 40, !11, i64 48, !12, i64 64, !10, i64 80, !10, i64 88}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_LIST_ENTRY", !10, i64 0, !10, i64 8}
!12 = !{!"_EFI_I2C_HOST_PROTOCOL", !10, i64 0, !10, i64 8}
!13 = !{!14, !15, i64 0}
!14 = !{!"", !15, i64 0, !11, i64 8, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!15 = !{!"int", !8, i64 0}
!16 = !{!14, !7, i64 24}
!17 = !{!6, !7, i64 8}
!18 = !{!6, !8, i64 40}
!19 = !{!20, !10, i64 0}
!20 = !{!"_EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL", !10, i64 0}
!21 = !{!6, !10, i64 16}
!22 = !{!10, !10, i64 0}
!23 = !{!24, !10, i64 24}
!24 = !{!"", !25, i64 0, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !10, i64 168, !10, i64 176, !10, i64 184, !10, i64 192, !10, i64 200, !10, i64 208, !10, i64 216, !10, i64 224, !10, i64 232, !10, i64 240, !10, i64 248, !10, i64 256, !10, i64 264, !10, i64 272, !10, i64 280, !10, i64 288, !10, i64 296, !10, i64 304, !10, i64 312, !10, i64 320, !10, i64 328, !10, i64 336, !10, i64 344, !10, i64 352, !10, i64 360, !10, i64 368}
!25 = !{!"", !7, i64 0, !15, i64 8, !15, i64 12, !15, i64 16, !15, i64 20}
!26 = !{!6, !7, i64 32}
!27 = !{!24, !10, i64 32}


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