; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe (IScsiSupported)

; 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.GUID = type { i32, i16, i16, [8 x i8] }
%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 }
%struct._EFI_DRIVER_BINDING_PROTOCOL = type { ptr, ptr, ptr, i32, ptr, ptr }

@gIScsiV4PrivateGuid = external dso_local global %struct.GUID, align 4
@gIScsiV6PrivateGuid = external dso_local global %struct.GUID, align 4
@gEfiTcp4ServiceBindingProtocolGuid = external global %struct.GUID, align 4
@gEfiDhcp4ServiceBindingProtocolGuid = external global %struct.GUID, align 4
@gEfiTcp6ServiceBindingProtocolGuid = external global %struct.GUID, align 4
@gEfiDhcp6ServiceBindingProtocolGuid = external global %struct.GUID, align 4
@gBS = external global ptr, align 8

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

; 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
define dso_local i64 @IScsiSupported(ptr noundef %0, ptr noundef %1, ptr noundef %2, i8 noundef zeroext %3) #0 {
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i8 %3, ptr %9, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %15 = load i8, ptr %9, align 1, !tbaa !9
  %16 = zext i8 %15 to i32
  %17 = icmp eq i32 %16, 4
  br i1 %17, label %18, label %19

18:                                               ; preds = %4
  store ptr @gIScsiV4PrivateGuid, ptr %11, align 8, !tbaa !5
  store ptr @gEfiTcp4ServiceBindingProtocolGuid, ptr %12, align 8, !tbaa !5
  store ptr @gEfiDhcp4ServiceBindingProtocolGuid, ptr %13, align 8, !tbaa !5
  br label %20

19:                                               ; preds = %4
  store ptr @gIScsiV6PrivateGuid, ptr %11, align 8, !tbaa !5
  store ptr @gEfiTcp6ServiceBindingProtocolGuid, ptr %12, align 8, !tbaa !5
  store ptr @gEfiDhcp6ServiceBindingProtocolGuid, ptr %13, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %19, %18
  %21 = load ptr, ptr @gBS, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %21, i32 0, i32 33
  %23 = load ptr, ptr %22, align 8, !tbaa !10
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %26, i32 0, i32 5
  %28 = load ptr, ptr %27, align 8, !tbaa !15
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = call i64 %23(ptr noundef %24, ptr noundef %25, ptr noundef null, ptr noundef %28, ptr noundef %29, i32 noundef 4)
  store i64 %30, ptr %10, align 8, !tbaa !17
  %31 = load i64, ptr %10, align 8, !tbaa !17
  %32 = icmp slt i64 %31, 0
  br i1 %32, label %34, label %33

33:                                               ; preds = %20
  store i64 -9223372036854775788, ptr %5, align 8
  store i32 1, ptr %14, align 4
  br label %75

34:                                               ; preds = %20
  %35 = load ptr, ptr @gBS, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %35, i32 0, i32 33
  %37 = load ptr, ptr %36, align 8, !tbaa !10
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load ptr, ptr %12, align 8, !tbaa !5
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %40, i32 0, i32 5
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = call i64 %37(ptr noundef %38, ptr noundef %39, ptr noundef null, ptr noundef %42, ptr noundef %43, i32 noundef 4)
  store i64 %44, ptr %10, align 8, !tbaa !17
  %45 = load i64, ptr %10, align 8, !tbaa !17
  %46 = icmp slt i64 %45, 0
  br i1 %46, label %47, label %48

47:                                               ; preds = %34
  store i64 -9223372036854775805, ptr %5, align 8
  store i32 1, ptr %14, align 4
  br label %75

48:                                               ; preds = %34
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = call i64 @IScsiIsDevicePathSupported(ptr noundef %49)
  store i64 %50, ptr %10, align 8, !tbaa !17
  %51 = load i64, ptr %10, align 8, !tbaa !17
  %52 = icmp slt i64 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %48
  store i64 -9223372036854775805, ptr %5, align 8
  store i32 1, ptr %14, align 4
  br label %75

54:                                               ; preds = %48
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = load i8, ptr %9, align 1, !tbaa !9
  %57 = call zeroext i8 @IScsiDhcpIsConfigured(ptr noundef %55, i8 noundef zeroext %56)
  %58 = icmp ne i8 %57, 0
  br i1 %58, label %59, label %74

59:                                               ; preds = %54
  %60 = load ptr, ptr @gBS, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %60, i32 0, i32 33
  %62 = load ptr, ptr %61, align 8, !tbaa !10
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %65, i32 0, i32 5
  %67 = load ptr, ptr %66, align 8, !tbaa !15
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = call i64 %62(ptr noundef %63, ptr noundef %64, ptr noundef null, ptr noundef %67, ptr noundef %68, i32 noundef 4)
  store i64 %69, ptr %10, align 8, !tbaa !17
  %70 = load i64, ptr %10, align 8, !tbaa !17
  %71 = icmp slt i64 %70, 0
  br i1 %71, label %72, label %73

72:                                               ; preds = %59
  store i64 -9223372036854775805, ptr %5, align 8
  store i32 1, ptr %14, align 4
  br label %75

73:                                               ; preds = %59
  br label %74

74:                                               ; preds = %73, %54
  store i64 0, ptr %5, align 8
  store i32 1, ptr %14, align 4
  br label %75

75:                                               ; preds = %74, %72, %53, %47, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %76 = load i64, ptr %5, align 8
  ret i64 %76
}

declare zeroext i8 @IScsiDhcpIsConfigured(ptr noundef, i8 noundef zeroext) #2

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, !6, i64 280}
!11 = !{!"", !12, 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}
!12 = !{!"", !13, i64 0, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !6, i64 40}
!16 = !{!"_EFI_DRIVER_BINDING_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !14, i64 24, !6, i64 32, !6, i64 40}
!17 = !{!13, !13, 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"

%struct.GUID = type { i32, i16, i16, [8 x i8] }

@gIScsiV4PrivateGuid = external dso_local global %struct.GUID, align 4
@gIScsiV6PrivateGuid = external dso_local global %struct.GUID, align 4
@gEfiTcp4ServiceBindingProtocolGuid = external global %struct.GUID, align 4
@gEfiDhcp4ServiceBindingProtocolGuid = external global %struct.GUID, align 4
@gEfiTcp6ServiceBindingProtocolGuid = external global %struct.GUID, align 4
@gEfiDhcp6ServiceBindingProtocolGuid = external global %struct.GUID, align 4
@gBS = external local_unnamed_addr global ptr, align 8

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

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775805, 1) i64 @IScsiSupported(ptr nocapture noundef readonly %0, ptr noundef %1, ptr noundef %2, i8 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = icmp eq i8 %3, 4
  %gIScsiV4PrivateGuid.gIScsiV6PrivateGuid = select i1 %5, ptr @gIScsiV4PrivateGuid, ptr @gIScsiV6PrivateGuid
  %gEfiDhcp4ServiceBindingProtocolGuid.gEfiDhcp6ServiceBindingProtocolGuid = select i1 %5, ptr @gEfiDhcp4ServiceBindingProtocolGuid, ptr @gEfiDhcp6ServiceBindingProtocolGuid
  %6 = load ptr, ptr @gBS, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 280
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %11 = tail call i64 %8(ptr noundef %1, ptr noundef nonnull %gIScsiV4PrivateGuid.gIScsiV6PrivateGuid, ptr noundef null, ptr noundef %10, ptr noundef %1, i32 noundef 4) #2
  %12 = icmp slt i64 %11, 0
  br i1 %12, label %13, label %33

13:                                               ; preds = %4
  %gEfiTcp4ServiceBindingProtocolGuid.gEfiTcp6ServiceBindingProtocolGuid = select i1 %5, ptr @gEfiTcp4ServiceBindingProtocolGuid, ptr @gEfiTcp6ServiceBindingProtocolGuid
  %14 = load ptr, ptr @gBS, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 280
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = load ptr, ptr %9, align 8, !tbaa !14
  %18 = tail call i64 %16(ptr noundef %1, ptr noundef nonnull %gEfiTcp4ServiceBindingProtocolGuid.gEfiTcp6ServiceBindingProtocolGuid, ptr noundef null, ptr noundef %17, ptr noundef %1, i32 noundef 4) #2
  %19 = icmp slt i64 %18, 0
  br i1 %19, label %33, label %20

20:                                               ; preds = %13
  %21 = tail call i64 @IScsiIsDevicePathSupported(ptr noundef %2)
  %22 = icmp slt i64 %21, 0
  br i1 %22, label %33, label %23

23:                                               ; preds = %20
  %24 = tail call zeroext i8 @IScsiDhcpIsConfigured(ptr noundef %1, i8 noundef zeroext %3) #2
  %.not = icmp eq i8 %24, 0
  br i1 %.not, label %32, label %25

25:                                               ; preds = %23
  %26 = load ptr, ptr @gBS, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %26, i64 280
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  %29 = load ptr, ptr %9, align 8, !tbaa !14
  %30 = tail call i64 %28(ptr noundef %1, ptr noundef nonnull %gEfiDhcp4ServiceBindingProtocolGuid.gEfiDhcp6ServiceBindingProtocolGuid, ptr noundef null, ptr noundef %29, ptr noundef %1, i32 noundef 4) #2
  %31 = icmp slt i64 %30, 0
  br i1 %31, label %33, label %32

32:                                               ; preds = %25, %23
  br label %33

33:                                               ; preds = %25, %20, %13, %4, %32
  %.022 = phi i64 [ 0, %32 ], [ -9223372036854775788, %4 ], [ -9223372036854775805, %13 ], [ -9223372036854775805, %20 ], [ -9223372036854775805, %25 ]
  ret i64 %.022
}

declare zeroext i8 @IScsiDhcpIsConfigured(ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 280}
!10 = !{!"", !11, 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}
!11 = !{!"", !12, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20}
!12 = !{!"long long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !6, i64 40}
!15 = !{!"_EFI_DRIVER_BINDING_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !6, i64 40}


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