; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/OptionRomPkg (PxeStructInit)

; 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.s_pxe_sw_undi = type { i32, i8, i8, i8, i8, i8, i8, i8, i8, i32, i64, [3 x i8], i8, [1 x i32] }

; Function Attrs: nounwind uwtable
declare dso_local void @UNDI_APIEntry_new(i64 noundef) #0

declare zeroext i8 @CalculateSum8(ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @PxeStructInit(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %3, i32 0, i32 0
  store i32 1163415585, ptr %4, align 1, !tbaa !9
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %5, i32 0, i32 1
  store i8 32, ptr %6, align 1, !tbaa !13
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %7, i32 0, i32 2
  store i8 0, ptr %8, align 1, !tbaa !14
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %9, i32 0, i32 4
  store i8 0, ptr %10, align 1, !tbaa !15
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %11, i32 0, i32 7
  store i8 0, ptr %12, align 1, !tbaa !16
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %13, i32 0, i32 3
  store i8 2, ptr %14, align 1, !tbaa !17
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %15, i32 0, i32 5
  store i8 3, ptr %16, align 1, !tbaa !18
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %17, i32 0, i32 6
  store i8 1, ptr %18, align 1, !tbaa !19
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %19, i32 0, i32 8
  store i8 0, ptr %20, align 1, !tbaa !20
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %21, i32 0, i32 9
  store i32 1073792506, ptr %22, align 1, !tbaa !21
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %23, i32 0, i32 10
  store i64 ptrtoint (ptr @UNDI_APIEntry_new to i64), ptr %24, align 1, !tbaa !22
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %25, i32 0, i32 6
  store i8 16, ptr %26, align 1, !tbaa !19
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %27, i32 0, i32 11
  %29 = getelementptr inbounds [3 x i8], ptr %28, i64 0, i64 0
  store i8 0, ptr %29, align 1, !tbaa !23
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %30, i32 0, i32 11
  %32 = getelementptr inbounds [3 x i8], ptr %31, i64 0, i64 1
  store i8 0, ptr %32, align 1, !tbaa !23
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %33, i32 0, i32 11
  %35 = getelementptr inbounds [3 x i8], ptr %34, i64 0, i64 2
  store i8 0, ptr %35, align 1, !tbaa !23
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %36, i32 0, i32 12
  store i8 1, ptr %37, align 1, !tbaa !24
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %38, i32 0, i32 13
  %40 = getelementptr inbounds [1 x i32], ptr %39, i64 0, i64 0
  store i32 1380533072, ptr %40, align 1, !tbaa !25
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %41, i32 0, i32 2
  %43 = load i8, ptr %42, align 1, !tbaa !14
  %44 = zext i8 %43 to i32
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %46, i32 0, i32 1
  %48 = load i8, ptr %47, align 1, !tbaa !13
  %49 = zext i8 %48 to i64
  %50 = call zeroext i8 @CalculateSum8(ptr noundef %45, i64 noundef %49)
  %51 = zext i8 %50 to i32
  %52 = sub nsw i32 %44, %51
  %53 = trunc i32 %52 to i8
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.s_pxe_sw_undi, ptr %54, i32 0, i32 2
  store i8 %53, ptr %55, align 1, !tbaa !14
  ret void
}

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

!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 = !{!10, !11, i64 0}
!10 = !{!"s_pxe_sw_undi", !11, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !11, i64 12, !12, i64 16, !7, i64 24, !7, i64 27, !7, i64 28}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!10, !7, i64 4}
!14 = !{!10, !7, i64 5}
!15 = !{!10, !7, i64 7}
!16 = !{!10, !7, i64 10}
!17 = !{!10, !7, i64 6}
!18 = !{!10, !7, i64 8}
!19 = !{!10, !7, i64 9}
!20 = !{!10, !7, i64 11}
!21 = !{!10, !11, i64 12}
!22 = !{!10, !12, i64 16}
!23 = !{!7, !7, i64 0}
!24 = !{!10, !7, i64 27}
!25 = !{!11, !11, 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"

; Function Attrs: nounwind uwtable
declare dso_local void @UNDI_APIEntry_new(i64 noundef) #0

declare zeroext i8 @CalculateSum8(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @PxeStructInit(ptr noundef %0) local_unnamed_addr #0 {
  store i32 1163415585, ptr %0, align 1, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 4
  %3 = getelementptr inbounds i8, ptr %0, i64 5
  %4 = getelementptr inbounds i8, ptr %0, i64 10
  store i8 0, ptr %4, align 1, !tbaa !11
  store <4 x i8> <i8 32, i8 0, i8 2, i8 0>, ptr %2, align 1, !tbaa !12
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  store i8 3, ptr %5, align 1, !tbaa !13
  %6 = getelementptr inbounds i8, ptr %0, i64 9
  %7 = getelementptr inbounds i8, ptr %0, i64 11
  store i8 0, ptr %7, align 1, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 1073792506, ptr %8, align 1, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 ptrtoint (ptr @UNDI_APIEntry_new to i64), ptr %9, align 1, !tbaa !16
  store i8 16, ptr %6, align 1, !tbaa !17
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  store <4 x i8> <i8 0, i8 0, i8 0, i8 1>, ptr %10, align 1, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 1380533072, ptr %11, align 1, !tbaa !18
  %12 = tail call zeroext i8 @CalculateSum8(ptr noundef nonnull %0, i64 noundef 32) #2
  %13 = sub i8 0, %12
  store i8 %13, ptr %3, align 1, !tbaa !19
  ret void
}

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 = !{!6, !7, i64 0}
!6 = !{!"s_pxe_sw_undi", !7, i64 0, !8, i64 4, !8, i64 5, !8, i64 6, !8, i64 7, !8, i64 8, !8, i64 9, !8, i64 10, !8, i64 11, !7, i64 12, !10, i64 16, !8, i64 24, !8, i64 27, !8, i64 28}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long long", !8, i64 0}
!11 = !{!6, !8, i64 10}
!12 = !{!8, !8, i64 0}
!13 = !{!6, !8, i64 8}
!14 = !{!6, !8, i64 11}
!15 = !{!6, !7, i64 12}
!16 = !{!6, !10, i64 16}
!17 = !{!6, !8, i64 9}
!18 = !{!7, !7, i64 0}
!19 = !{!6, !8, i64 5}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass