; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdePkg/Library (PciCf8Read32)

; 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 = external hidden unnamed_addr constant [142 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [38 x i8], align 1

declare zeroext i8 @DebugAssertEnabled() #0

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare zeroext i8 @SaveAndDisableInterrupts() #0

declare i32 @IoRead32(i64 noundef) #0

declare i32 @IoWrite32(i64 noundef, i32 noundef) #0

declare zeroext i8 @SetInterruptState(i8 noundef zeroext) #0

; 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 i32 @PciCf8Read32(i64 noundef %0) #2 {
  %2 = alloca i64, align 8
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i64 %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  br label %6

6:                                                ; preds = %1
  %7 = call zeroext i8 @DebugAssertEnabled()
  %8 = icmp ne i8 %7, 0
  br i1 %8, label %9, label %15

9:                                                ; preds = %6
  %10 = load i64, ptr %2, align 8, !tbaa !5
  %11 = and i64 %10, -268431613
  %12 = icmp eq i64 %11, 0
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @DebugAssert(ptr noundef @.str, i64 noundef 1114, ptr noundef @.str.3)
  br label %14

14:                                               ; preds = %13, %9
  br label %15

15:                                               ; preds = %14, %6
  br label %16

16:                                               ; preds = %15
  br label %17

17:                                               ; preds = %16
  %18 = call zeroext i8 @SaveAndDisableInterrupts()
  store i8 %18, ptr %3, align 1, !tbaa !9
  %19 = call i32 @IoRead32(i64 noundef 3320)
  store i32 %19, ptr %4, align 4, !tbaa !10
  %20 = load i64, ptr %2, align 8, !tbaa !5
  %21 = lshr i64 %20, 4
  %22 = and i64 %21, 16776960
  %23 = load i64, ptr %2, align 8, !tbaa !5
  %24 = and i64 %23, 252
  %25 = or i64 %22, %24
  %26 = or i64 %25, 2147483648
  %27 = trunc i64 %26 to i32
  %28 = call i32 @IoWrite32(i64 noundef 3320, i32 noundef %27)
  %29 = call i32 @IoRead32(i64 noundef 3324)
  store i32 %29, ptr %5, align 4, !tbaa !10
  %30 = load i32, ptr %4, align 4, !tbaa !10
  %31 = call i32 @IoWrite32(i64 noundef 3320, i32 noundef %30)
  %32 = load i8, ptr %3, align 1, !tbaa !9
  %33 = call zeroext i8 @SetInterruptState(i8 noundef zeroext %32)
  %34 = load i32, ptr %5, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  ret i32 %34
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !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 = external hidden unnamed_addr constant [142 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [38 x i8], align 1

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #0

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

declare zeroext i8 @SaveAndDisableInterrupts() local_unnamed_addr #0

declare i32 @IoRead32(i64 noundef) local_unnamed_addr #0

declare i32 @IoWrite32(i64 noundef, i32 noundef) local_unnamed_addr #0

declare zeroext i8 @SetInterruptState(i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @PciCf8Read32(i64 noundef %0) local_unnamed_addr #1 {
  %2 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %2, 0
  %3 = and i64 %0, -268431613
  %4 = icmp eq i64 %3, 0
  %or.cond = or i1 %4, %.not
  br i1 %or.cond, label %6, label %5

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

6:                                                ; preds = %5, %1
  %7 = tail call zeroext i8 @SaveAndDisableInterrupts() #2
  %8 = tail call i32 @IoRead32(i64 noundef 3320) #2
  %9 = lshr i64 %0, 4
  %10 = and i64 %9, 16776960
  %11 = and i64 %0, 252
  %12 = or disjoint i64 %10, %11
  %13 = trunc nuw nsw i64 %12 to i32
  %14 = or disjoint i32 %13, -2147483648
  %15 = tail call i32 @IoWrite32(i64 noundef 3320, i32 noundef %14) #2
  %16 = tail call i32 @IoRead32(i64 noundef 3324) #2
  %17 = tail call i32 @IoWrite32(i64 noundef 3320, i32 noundef %8) #2
  %18 = tail call zeroext i8 @SetInterruptState(i8 noundef zeroext %7) #2
  ret i32 %16
}

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,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass