; LLVM IR from Simple-XX/SimpleKernel :: src/arch/ia32/i386/intr/intr.ll (ZN4INTR10enable_irqEh)

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZN2IO12get_instanceEv() #0

declare void @_ZN2IO4outbEjh(i32 noundef, i8 noundef zeroext) #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: mustprogress uwtable
define dso_local void @_ZN4INTR10enable_irqEh(ptr noundef nonnull align 1 dereferenceable(1) %0, i8 noundef zeroext %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  store i8 0, ptr %5, align 1, !tbaa !9
  %7 = load i8, ptr %4, align 1, !tbaa !9
  %8 = zext i8 %7 to i32
  %9 = icmp uge i32 %8, 40
  br i1 %9, label %10, label %23

10:                                               ; preds = %2
  %11 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN2IO12get_instanceEv()
  %12 = call noundef zeroext i8 @_ZN2IO3inbEj(i32 noundef 161)
  %13 = zext i8 %12 to i32
  %14 = load i8, ptr %4, align 1, !tbaa !9
  %15 = zext i8 %14 to i32
  %16 = srem i32 %15, 8
  %17 = shl i32 1, %16
  %18 = xor i32 %17, -1
  %19 = and i32 %13, %18
  %20 = trunc i32 %19 to i8
  store i8 %20, ptr %5, align 1, !tbaa !9
  %21 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN2IO12get_instanceEv()
  %22 = load i8, ptr %5, align 1, !tbaa !9
  call void @_ZN2IO4outbEjh(i32 noundef 161, i8 noundef zeroext %22)
  br label %36

23:                                               ; preds = %2
  %24 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN2IO12get_instanceEv()
  %25 = call noundef zeroext i8 @_ZN2IO3inbEj(i32 noundef 33)
  %26 = zext i8 %25 to i32
  %27 = load i8, ptr %4, align 1, !tbaa !9
  %28 = zext i8 %27 to i32
  %29 = srem i32 %28, 8
  %30 = shl i32 1, %29
  %31 = xor i32 %30, -1
  %32 = and i32 %26, %31
  %33 = trunc i32 %32 to i8
  store i8 %33, ptr %5, align 1, !tbaa !9
  %34 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN2IO12get_instanceEv()
  %35 = load i8, ptr %5, align 1, !tbaa !9
  call void @_ZN2IO4outbEjh(i32 noundef 33, i8 noundef zeroext %35)
  br label %36

36:                                               ; preds = %23, %10
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  ret void
}

declare noundef zeroext i8 @_ZN2IO3inbEj(i32 noundef) #0

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 = { mustprogress 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !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"

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZN2IO12get_instanceEv() local_unnamed_addr #0

declare void @_ZN2IO4outbEjh(i32 noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4INTR10enable_irqEh(ptr nocapture noundef nonnull readnone align 1 dereferenceable(1) %0, i8 noundef zeroext %1) local_unnamed_addr #1 align 2 {
  %3 = icmp ugt i8 %1, 39
  %4 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN2IO12get_instanceEv()
  %5 = and i8 %1, 7
  %6 = shl nuw i8 1, %5
  %7 = xor i8 %6, -1
  %. = select i1 %3, i32 161, i32 33
  %8 = tail call noundef zeroext i8 @_ZN2IO3inbEj(i32 noundef %.)
  %9 = and i8 %8, %7
  %10 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN2IO12get_instanceEv()
  tail call void @_ZN2IO4outbEjh(i32 noundef %., i8 noundef zeroext %9)
  ret void
}

declare noundef zeroext i8 @_ZN2IO3inbEj(i32 noundef) local_unnamed_addr #0

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 = { mustprogress 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" }

!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: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass