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

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

@_ZN4INTR9intrnamesE = external dso_local constant [21 x ptr], align 16
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_ZN4INTR13get_intr_nameEh(ptr noundef nonnull align 1 dereferenceable(1) %0, i8 noundef zeroext %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !9
  %6 = load ptr, ptr %4, align 8
  %7 = load i8, ptr %5, align 1, !tbaa !9
  %8 = zext i8 %7 to i64
  %9 = icmp ult i64 %8, 21
  br i1 %9, label %10, label %15

10:                                               ; preds = %2
  %11 = load i8, ptr %5, align 1, !tbaa !9
  %12 = zext i8 %11 to i64
  %13 = getelementptr inbounds [21 x ptr], ptr @_ZN4INTR9intrnamesE, i64 0, i64 %12
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %14, ptr %3, align 8
  br label %16

15:                                               ; preds = %2
  store ptr @.str.2, ptr %3, align 8
  br label %16

16:                                               ; preds = %15, %10
  %17 = load ptr, ptr %3, align 8
  ret ptr %17
}

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

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

@_ZN4INTR9intrnamesE = external dso_local local_unnamed_addr constant [21 x ptr], align 16
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef ptr @_ZN4INTR13get_intr_nameEh(ptr nocapture noundef nonnull readnone align 1 dereferenceable(1) %0, i8 noundef zeroext %1) local_unnamed_addr #0 align 2 {
  %3 = icmp ult i8 %1, 21
  br i1 %3, label %4, label %8

4:                                                ; preds = %2
  %5 = zext nneg i8 %1 to i64
  %6 = getelementptr inbounds [21 x ptr], ptr @_ZN4INTR9intrnamesE, i64 0, i64 %5
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %2, %4
  %.0 = phi ptr [ %7, %4 ], [ @.str.2, %2 ]
  ret ptr %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass