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

; 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.INTR::idt_entry32_t" = type { i64 }

@_ZN4INTR11idt_entry32E = external dso_local global [256 x %"struct.INTR::idt_entry32_t"], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4INTR7set_idtEhjthhh(ptr noundef nonnull align 1 dereferenceable(1) %0, i8 noundef zeroext %1, i32 noundef %2, i16 noundef zeroext %3, i8 noundef zeroext %4, i8 noundef zeroext %5, i8 noundef zeroext %6) #0 align 2 {
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  %11 = alloca i16, align 2
  %12 = alloca i8, align 1
  %13 = alloca i8, align 1
  %14 = alloca i8, align 1
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i8 %1, ptr %9, align 1, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !10
  store i16 %3, ptr %11, align 2, !tbaa !12
  store i8 %4, ptr %12, align 1, !tbaa !9
  store i8 %5, ptr %13, align 1, !tbaa !9
  store i8 %6, ptr %14, align 1, !tbaa !9
  %15 = load ptr, ptr %8, align 8
  %16 = load i32, ptr %10, align 4, !tbaa !10
  %17 = and i32 %16, 65535
  %18 = zext i32 %17 to i64
  %19 = load i8, ptr %9, align 1, !tbaa !9
  %20 = zext i8 %19 to i64
  %21 = getelementptr inbounds [256 x %"struct.INTR::idt_entry32_t"], ptr @_ZN4INTR11idt_entry32E, i64 0, i64 %20
  %22 = load i64, ptr %21, align 8
  %23 = and i64 %18, 65535
  %24 = and i64 %22, -65536
  %25 = or i64 %24, %23
  store i64 %25, ptr %21, align 8
  %26 = load i16, ptr %11, align 2, !tbaa !12
  %27 = zext i16 %26 to i64
  %28 = load i8, ptr %9, align 1, !tbaa !9
  %29 = zext i8 %28 to i64
  %30 = getelementptr inbounds [256 x %"struct.INTR::idt_entry32_t"], ptr @_ZN4INTR11idt_entry32E, i64 0, i64 %29
  %31 = load i64, ptr %30, align 8
  %32 = and i64 %27, 65535
  %33 = shl i64 %32, 16
  %34 = and i64 %31, -4294901761
  %35 = or i64 %34, %33
  store i64 %35, ptr %30, align 8
  %36 = load i8, ptr %9, align 1, !tbaa !9
  %37 = zext i8 %36 to i64
  %38 = getelementptr inbounds [256 x %"struct.INTR::idt_entry32_t"], ptr @_ZN4INTR11idt_entry32E, i64 0, i64 %37
  %39 = load i64, ptr %38, align 8
  %40 = and i64 %39, -64424509441
  %41 = or i64 %40, 0
  store i64 %41, ptr %38, align 8
  %42 = load i8, ptr %9, align 1, !tbaa !9
  %43 = zext i8 %42 to i64
  %44 = getelementptr inbounds [256 x %"struct.INTR::idt_entry32_t"], ptr @_ZN4INTR11idt_entry32E, i64 0, i64 %43
  %45 = load i64, ptr %44, align 8
  %46 = and i64 %45, -1030792151041
  %47 = or i64 %46, 0
  store i64 %47, ptr %44, align 8
  %48 = load i8, ptr %12, align 1, !tbaa !9
  %49 = zext i8 %48 to i64
  %50 = load i8, ptr %9, align 1, !tbaa !9
  %51 = zext i8 %50 to i64
  %52 = getelementptr inbounds [256 x %"struct.INTR::idt_entry32_t"], ptr @_ZN4INTR11idt_entry32E, i64 0, i64 %51
  %53 = load i64, ptr %52, align 8
  %54 = and i64 %49, 31
  %55 = shl i64 %54, 40
  %56 = and i64 %53, -34084860461057
  %57 = or i64 %56, %55
  store i64 %57, ptr %52, align 8
  %58 = load i8, ptr %13, align 1, !tbaa !9
  %59 = zext i8 %58 to i64
  %60 = load i8, ptr %9, align 1, !tbaa !9
  %61 = zext i8 %60 to i64
  %62 = getelementptr inbounds [256 x %"struct.INTR::idt_entry32_t"], ptr @_ZN4INTR11idt_entry32E, i64 0, i64 %61
  %63 = load i64, ptr %62, align 8
  %64 = and i64 %59, 3
  %65 = shl i64 %64, 45
  %66 = and i64 %63, -105553116266497
  %67 = or i64 %66, %65
  store i64 %67, ptr %62, align 8
  %68 = load i8, ptr %14, align 1, !tbaa !9
  %69 = zext i8 %68 to i64
  %70 = load i8, ptr %9, align 1, !tbaa !9
  %71 = zext i8 %70 to i64
  %72 = getelementptr inbounds [256 x %"struct.INTR::idt_entry32_t"], ptr @_ZN4INTR11idt_entry32E, i64 0, i64 %71
  %73 = load i64, ptr %72, align 8
  %74 = and i64 %69, 1
  %75 = shl i64 %74, 47
  %76 = and i64 %73, -140737488355329
  %77 = or i64 %76, %75
  store i64 %77, ptr %72, align 8
  %78 = load i32, ptr %10, align 4, !tbaa !10
  %79 = lshr i32 %78, 16
  %80 = and i32 %79, 65535
  %81 = zext i32 %80 to i64
  %82 = load i8, ptr %9, align 1, !tbaa !9
  %83 = zext i8 %82 to i64
  %84 = getelementptr inbounds [256 x %"struct.INTR::idt_entry32_t"], ptr @_ZN4INTR11idt_entry32E, i64 0, i64 %83
  %85 = load i64, ptr %84, align 8
  %86 = and i64 %81, 65535
  %87 = shl i64 %86, 48
  %88 = and i64 %85, 281474976710655
  %89 = or i64 %88, %87
  store i64 %89, ptr %84, align 8
  ret void
}

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}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !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"

%"struct.INTR::idt_entry32_t" = type { i64 }

@_ZN4INTR11idt_entry32E = external dso_local local_unnamed_addr global [256 x %"struct.INTR::idt_entry32_t"], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @_ZN4INTR7set_idtEhjthhh(ptr nocapture noundef nonnull readnone align 1 dereferenceable(1) %0, i8 noundef zeroext %1, i32 noundef %2, i16 noundef zeroext %3, i8 noundef zeroext %4, i8 noundef zeroext %5, i8 noundef zeroext %6) local_unnamed_addr #0 align 2 {
  %8 = zext i8 %1 to i64
  %9 = getelementptr inbounds [256 x %"struct.INTR::idt_entry32_t"], ptr @_ZN4INTR11idt_entry32E, i64 0, i64 %8
  %10 = zext i16 %3 to i64
  %11 = shl nuw nsw i64 %10, 16
  %12 = and i32 %2, 65535
  %.masked = zext nneg i32 %12 to i64
  %13 = or disjoint i64 %11, %.masked
  %14 = and i8 %4, 31
  %15 = zext nneg i8 %14 to i64
  %16 = shl nuw nsw i64 %15, 40
  %17 = or disjoint i64 %13, %16
  %18 = and i8 %5, 3
  %19 = zext nneg i8 %18 to i64
  %20 = shl nuw nsw i64 %19, 45
  %21 = or disjoint i64 %17, %20
  %22 = zext i8 %6 to i64
  %23 = shl nuw nsw i64 %22, 47
  %24 = lshr i32 %2, 16
  %25 = zext nneg i32 %24 to i64
  %26 = shl nuw i64 %25, 48
  %.masked14 = and i64 %23, 140737488355328
  %27 = or disjoint i64 %21, %.masked14
  %28 = or disjoint i64 %27, %26
  store i64 %28, ptr %9, align 8
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none, inaccessiblemem: 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)"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass