; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal (EfiIp4ConfigStop)

; 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._IP4_CONFIG_INSTANCE = type { i32, ptr, ptr, ptr, %struct._EFI_IP4_CONFIG_PROTOCOL, %struct._EFI_HII_CONFIG_ACCESS_PROTOCOL, ptr, ptr, ptr, %struct._IP4CONFIG_CALLBACK_INFO, i64, ptr, ptr, ptr, ptr, i64, %struct.NIC_ADDR, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8 }
%struct._EFI_IP4_CONFIG_PROTOCOL = type { ptr, ptr, ptr }
%struct._EFI_HII_CONFIG_ACCESS_PROTOCOL = type { ptr, ptr, ptr }
%struct._IP4CONFIG_CALLBACK_INFO = type { i8, i8, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS }
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }
%struct.NIC_ADDR = type { i16, i8, %struct.EFI_MAC_ADDRESS }
%struct.EFI_MAC_ADDRESS = type { [32 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 }

@gBS = external global ptr, align 8
@.str = external hidden unnamed_addr constant [157 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @EfiIp4ConfigStop(ptr noundef %0) #0 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  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
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  store i64 -9223372036854775806, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %49

11:                                               ; preds = %1
  %12 = call zeroext i8 @DebugAssertEnabled()
  %13 = zext i8 %12 to i32
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %25

15:                                               ; preds = %11
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = ptrtoint ptr %16 to i64
  %18 = sub i64 %17, ptrtoint (ptr getelementptr inbounds (%struct._IP4_CONFIG_INSTANCE, ptr null, i32 0, i32 4) to i64)
  %19 = inttoptr i64 %18 to ptr
  %20 = getelementptr inbounds %struct._IP4_CONFIG_INSTANCE, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %20, align 8, !tbaa !9
  %22 = icmp ne i32 %21, 1127501897
  br i1 %22, label %23, label %25

23:                                               ; preds = %15
  call void @DebugAssert(ptr noundef @.str, i64 noundef 512, ptr noundef @.str.3)
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  br label %30

25:                                               ; preds = %15, %11
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = ptrtoint ptr %26 to i64
  %28 = sub i64 %27, ptrtoint (ptr getelementptr inbounds (%struct._IP4_CONFIG_INSTANCE, ptr null, i32 0, i32 4) to i64)
  %29 = inttoptr i64 %28 to ptr
  br label %30

30:                                               ; preds = %25, %23
  %31 = phi ptr [ %24, %23 ], [ %29, %25 ]
  store ptr %31, ptr %4, align 8, !tbaa !5
  store i64 0, ptr %5, align 8, !tbaa !19
  %32 = load ptr, ptr @gBS, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %32, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !20
  %35 = call i64 %34(i64 noundef 8)
  store i64 %35, ptr %6, align 8, !tbaa !19
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._IP4_CONFIG_INSTANCE, ptr %36, i32 0, i32 10
  %38 = load i64, ptr %37, align 8, !tbaa !23
  %39 = icmp eq i64 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %30
  store i64 -9223372036854775789, ptr %5, align 8, !tbaa !19
  br label %43

41:                                               ; preds = %30
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  call void @Ip4ConfigCleanConfig(ptr noundef %42)
  br label %43

43:                                               ; preds = %41, %40
  %44 = load ptr, ptr @gBS, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !24
  %47 = load i64, ptr %6, align 8, !tbaa !19
  call void %46(i64 noundef %47)
  %48 = load i64, ptr %5, align 8, !tbaa !19
  store i64 %48, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %49

49:                                               ; preds = %43, %10
  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
  %50 = load i64, ptr %2, align 8
  ret i64 %50
}

; 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

declare zeroext i8 @DebugAssertEnabled() #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @Ip4ConfigCleanConfig(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 = !{!10, !11, i64 0}
!10 = !{!"_IP4_CONFIG_INSTANCE", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !13, i64 56, !6, i64 80, !6, i64 88, !6, i64 96, !14, i64 104, !16, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !16, i64 160, !17, i64 168, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !7, i64 256, !7, i64 257}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_EFI_IP4_CONFIG_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!"_EFI_HII_CONFIG_ACCESS_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16}
!14 = !{!"_IP4CONFIG_CALLBACK_INFO", !7, i64 0, !7, i64 1, !15, i64 2, !15, i64 6, !15, i64 10}
!15 = !{!"", !7, i64 0}
!16 = !{!"long long", !7, i64 0}
!17 = !{!"", !18, i64 0, !7, i64 2, !15, i64 3}
!18 = !{!"short", !7, i64 0}
!19 = !{!16, !16, i64 0}
!20 = !{!21, !6, i64 24}
!21 = !{!"", !22, 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}
!22 = !{!"", !16, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!23 = !{!10, !16, i64 120}
!24 = !{!21, !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 = external hidden unnamed_addr constant [157 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775806, 1) i64 @EfiIp4ConfigStop(ptr noundef %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %21, label %3

3:                                                ; preds = %1
  %4 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %4, 0
  %.pre = ptrtoint ptr %0 to i64
  %.pre11 = add i64 %.pre, -32
  %.pre13 = inttoptr i64 %.pre11 to ptr
  br i1 %.not, label %._crit_edge, label %5

5:                                                ; preds = %3
  %6 = load i32, ptr %.pre13, align 8, !tbaa !5
  %.not10 = icmp eq i32 %6, 1127501897
  br i1 %.not10, label %._crit_edge, label %7

7:                                                ; preds = %5
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 512, ptr noundef nonnull @.str.3) #2
  br label %._crit_edge

._crit_edge:                                      ; preds = %3, %5, %7
  %8 = phi ptr [ %0, %7 ], [ %.pre13, %5 ], [ %.pre13, %3 ]
  %9 = load ptr, ptr @gBS, align 8, !tbaa !18
  %10 = getelementptr inbounds i8, ptr %9, i64 24
  %11 = load ptr, ptr %10, align 8, !tbaa !19
  %12 = tail call i64 %11(i64 noundef 8) #2
  %13 = getelementptr inbounds i8, ptr %8, i64 120
  %14 = load i64, ptr %13, align 8, !tbaa !22
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %17, label %16

16:                                               ; preds = %._crit_edge
  tail call void @Ip4ConfigCleanConfig(ptr noundef nonnull %8)
  br label %17

17:                                               ; preds = %._crit_edge, %16
  %.08 = phi i64 [ 0, %16 ], [ -9223372036854775789, %._crit_edge ]
  %18 = load ptr, ptr @gBS, align 8, !tbaa !18
  %19 = getelementptr inbounds i8, ptr %18, i64 32
  %20 = load ptr, ptr %19, align 8, !tbaa !23
  tail call void %20(i64 noundef %12) #2
  br label %21

21:                                               ; preds = %1, %17
  %.0 = phi i64 [ %.08, %17 ], [ -9223372036854775806, %1 ]
  ret i64 %.0
}

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @Ip4ConfigCleanConfig(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 = { "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, !7, i64 0}
!6 = !{!"_IP4_CONFIG_INSTANCE", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !11, i64 32, !12, i64 56, !10, i64 80, !10, i64 88, !10, i64 96, !13, i64 104, !15, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !15, i64 160, !16, i64 168, !10, i64 208, !10, i64 216, !10, i64 224, !10, i64 232, !10, i64 240, !10, i64 248, !8, i64 256, !8, i64 257}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_EFI_IP4_CONFIG_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16}
!12 = !{!"_EFI_HII_CONFIG_ACCESS_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16}
!13 = !{!"_IP4CONFIG_CALLBACK_INFO", !8, i64 0, !8, i64 1, !14, i64 2, !14, i64 6, !14, i64 10}
!14 = !{!"", !8, i64 0}
!15 = !{!"long long", !8, i64 0}
!16 = !{!"", !17, i64 0, !8, i64 2, !14, i64 3}
!17 = !{!"short", !8, i64 0}
!18 = !{!10, !10, i64 0}
!19 = !{!20, !10, i64 24}
!20 = !{!"", !21, 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}
!21 = !{!"", !15, i64 0, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!22 = !{!6, !15, i64 120}
!23 = !{!20, !10, i64 32}


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