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

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

; 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
define dso_local zeroext i8 @IsHotPlugDevice(ptr noundef %0) #1 {
  %2 = alloca i8, align 1
  %3 = alloca ptr, align 8
  %4 = alloca ptr, 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
  store ptr %6, ptr %4, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %44, %1
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = call zeroext i8 @IsDevicePathEnd(ptr noundef %8)
  %10 = icmp ne i8 %9, 0
  %11 = xor i1 %10, true
  br i1 %11, label %12, label %47

12:                                               ; preds = %7
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = call zeroext i8 @DevicePathType(ptr noundef %13)
  %15 = zext i8 %14 to i32
  %16 = icmp eq i32 %15, 3
  br i1 %16, label %17, label %33

17:                                               ; preds = %12
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call zeroext i8 @DevicePathSubType(ptr noundef %18)
  %20 = zext i8 %19 to i32
  %21 = icmp eq i32 %20, 5
  br i1 %21, label %32, label %22

22:                                               ; preds = %17
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = call zeroext i8 @DevicePathSubType(ptr noundef %23)
  %25 = zext i8 %24 to i32
  %26 = icmp eq i32 %25, 15
  br i1 %26, label %32, label %27

27:                                               ; preds = %22
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = call zeroext i8 @DevicePathSubType(ptr noundef %28)
  %30 = zext i8 %29 to i32
  %31 = icmp eq i32 %30, 16
  br i1 %31, label %32, label %33

32:                                               ; preds = %27, %22, %17
  store i8 1, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %48

33:                                               ; preds = %27, %12
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = call zeroext i8 @DevicePathType(ptr noundef %34)
  %36 = zext i8 %35 to i32
  %37 = icmp eq i32 %36, 1
  br i1 %37, label %38, label %44

38:                                               ; preds = %33
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = call zeroext i8 @DevicePathSubType(ptr noundef %39)
  %41 = zext i8 %40 to i32
  %42 = icmp eq i32 %41, 2
  br i1 %42, label %43, label %44

43:                                               ; preds = %38
  store i8 1, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %48

44:                                               ; preds = %38, %33
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = call ptr @NextDevicePathNode(ptr noundef %45)
  store ptr %46, ptr %4, align 8, !tbaa !5
  br label %7, !llvm.loop !9

47:                                               ; preds = %7
  store i8 0, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %48

48:                                               ; preds = %47, %43, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %49 = load i8, ptr %2, align 1
  ret i8 %49
}

declare zeroext i8 @DevicePathType(ptr noundef) #2

declare zeroext i8 @DevicePathSubType(ptr noundef) #2

declare ptr @NextDevicePathNode(ptr noundef) #2

declare zeroext i8 @IsDevicePathEnd(ptr noundef) #2

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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @IsHotPlugDevice(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call zeroext i8 @IsDevicePathEnd(ptr noundef %0) #2
  %.not10 = icmp eq i8 %2, 0
  br i1 %.not10, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1, %20
  %.011 = phi ptr [ %21, %20 ], [ %0, %1 ]
  %3 = tail call zeroext i8 @DevicePathType(ptr noundef %.011) #2
  %4 = icmp eq i8 %3, 3
  br i1 %4, label %5, label %14

5:                                                ; preds = %.lr.ph
  %6 = tail call zeroext i8 @DevicePathSubType(ptr noundef %.011) #2
  %7 = icmp eq i8 %6, 5
  br i1 %7, label %._crit_edge, label %8

8:                                                ; preds = %5
  %9 = tail call zeroext i8 @DevicePathSubType(ptr noundef %.011) #2
  %10 = icmp eq i8 %9, 15
  br i1 %10, label %._crit_edge, label %11

11:                                               ; preds = %8
  %12 = tail call zeroext i8 @DevicePathSubType(ptr noundef %.011) #2
  %13 = icmp eq i8 %12, 16
  br i1 %13, label %._crit_edge, label %14

14:                                               ; preds = %11, %.lr.ph
  %15 = tail call zeroext i8 @DevicePathType(ptr noundef %.011) #2
  %16 = icmp eq i8 %15, 1
  br i1 %16, label %17, label %20

17:                                               ; preds = %14
  %18 = tail call zeroext i8 @DevicePathSubType(ptr noundef %.011) #2
  %19 = icmp eq i8 %18, 2
  br i1 %19, label %._crit_edge, label %20

20:                                               ; preds = %17, %14
  %21 = tail call ptr @NextDevicePathNode(ptr noundef %.011) #2
  %22 = tail call zeroext i8 @IsDevicePathEnd(ptr noundef %21) #2
  %.not = icmp eq i8 %22, 0
  br i1 %.not, label %.lr.ph, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %11, %8, %5, %17, %20, %1
  %.09 = phi i8 [ 0, %1 ], [ 0, %20 ], [ 1, %17 ], [ 1, %5 ], [ 1, %8 ], [ 1, %11 ]
  ret i8 %.09
}

declare zeroext i8 @DevicePathType(ptr noundef) local_unnamed_addr #1

declare zeroext i8 @DevicePathSubType(ptr noundef) local_unnamed_addr #1

declare ptr @NextDevicePathNode(ptr noundef) local_unnamed_addr #1

declare zeroext i8 @IsDevicePathEnd(ptr noundef) 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass