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

; 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_data_instance = type { i16, i16, i8, i8, i16, i16, i16, i16, i16, [32 x i8], [32 x i8], [32 x i8], [64 x i32], [128 x i32], i32, i32, i16, i16, i8, i8, i8, i8, i16, i16, i16, i16, i32, i32, i16, i16, [2 x i16], i8, i8, i16, i32, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, i64, i64, i64, [64 x i64], i16, i16, i16, i16, i8, i8, i8, i8, i8, [3 x i8], %struct.mc, i64, ptr, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.mc = type { [3 x i16], i16, [8 x [32 x i8]] }

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

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

; Function Attrs: nounwind uwtable
define dso_local i64 @MapIt(ptr noundef %0, i64 noundef %1, i32 noundef %2, i32 noundef %3, i64 noundef %4) #1 {
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i64 %1, ptr %8, align 8, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !11
  store i32 %3, ptr %10, align 4, !tbaa !11
  store i64 %4, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %14 = load i64, ptr %11, align 8, !tbaa !9
  %15 = inttoptr i64 %14 to ptr
  store ptr %15, ptr %12, align 8, !tbaa !5
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.s_data_instance, ptr %16, i32 0, i32 55
  %18 = load i8, ptr %17, align 4, !tbaa !13
  %19 = zext i8 %18 to i32
  %20 = icmp eq i32 %19, 48
  br i1 %20, label %21, label %44

21:                                               ; preds = %5
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.s_data_instance, ptr %22, i32 0, i32 62
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %31

26:                                               ; preds = %21
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.s_data_instance, ptr %27, i32 0, i32 44
  %29 = load i64, ptr %28, align 8, !tbaa !18
  %30 = load ptr, ptr %12, align 8, !tbaa !5
  store i64 %29, ptr %30, align 8, !tbaa !9
  br label %38

31:                                               ; preds = %21
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.s_data_instance, ptr %32, i32 0, i32 62
  %34 = load ptr, ptr %33, align 8, !tbaa !17
  %35 = load i64, ptr %8, align 8, !tbaa !9
  %36 = load ptr, ptr %12, align 8, !tbaa !5
  %37 = ptrtoint ptr %36 to i64
  call void %34(i64 noundef %35, i64 noundef %37)
  br label %38

38:                                               ; preds = %31, %26
  %39 = load ptr, ptr %12, align 8, !tbaa !5
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = icmp ugt i64 %40, 4294967296
  br i1 %41, label %42, label %43

42:                                               ; preds = %38
  store i64 14, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %70

43:                                               ; preds = %38
  br label %69

44:                                               ; preds = %5
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.s_data_instance, ptr %45, i32 0, i32 69
  %47 = load ptr, ptr %46, align 8, !tbaa !19
  %48 = icmp eq ptr %47, null
  br i1 %48, label %49, label %57

49:                                               ; preds = %44
  %50 = load i64, ptr %8, align 8, !tbaa !9
  %51 = icmp ugt i64 %50, 4294967296
  br i1 %51, label %52, label %53

52:                                               ; preds = %49
  store i64 14, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %70

53:                                               ; preds = %49
  %54 = load i64, ptr %8, align 8, !tbaa !9
  %55 = load ptr, ptr %12, align 8, !tbaa !5
  store i64 %54, ptr %55, align 8, !tbaa !9
  br label %56

56:                                               ; preds = %53
  br label %68

57:                                               ; preds = %44
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.s_data_instance, ptr %58, i32 0, i32 69
  %60 = load ptr, ptr %59, align 8, !tbaa !19
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.s_data_instance, ptr %61, i32 0, i32 58
  %63 = load i64, ptr %62, align 8, !tbaa !20
  %64 = load i64, ptr %8, align 8, !tbaa !9
  %65 = load i32, ptr %9, align 4, !tbaa !11
  %66 = load i32, ptr %10, align 4, !tbaa !11
  %67 = load i64, ptr %11, align 8, !tbaa !9
  call void %60(i64 noundef %63, i64 noundef %64, i32 noundef %65, i32 noundef %66, i64 noundef %67)
  br label %68

68:                                               ; preds = %57, %56
  br label %69

69:                                               ; preds = %68, %43
  store i64 0, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %70

70:                                               ; preds = %69, %52, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  %71 = load i64, ptr %6, align 8
  ret i64 %71
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !7, i64 1540}
!14 = !{!"s_data_instance", !15, i64 0, !15, i64 2, !7, i64 4, !7, i64 5, !15, i64 6, !15, i64 8, !15, i64 10, !15, i64 12, !15, i64 14, !7, i64 16, !7, i64 48, !7, i64 80, !7, i64 112, !7, i64 368, !12, i64 880, !12, i64 884, !15, i64 888, !15, i64 890, !7, i64 892, !7, i64 893, !7, i64 894, !7, i64 895, !15, i64 896, !15, i64 898, !15, i64 900, !15, i64 902, !12, i64 904, !12, i64 908, !15, i64 912, !15, i64 914, !7, i64 916, !7, i64 920, !7, i64 921, !15, i64 922, !12, i64 924, !6, i64 928, !6, i64 936, !6, i64 944, !6, i64 952, !6, i64 960, !6, i64 968, !10, i64 976, !10, i64 984, !10, i64 992, !10, i64 1000, !10, i64 1008, !7, i64 1016, !15, i64 1528, !15, i64 1530, !15, i64 1532, !15, i64 1534, !7, i64 1536, !7, i64 1537, !7, i64 1538, !7, i64 1539, !7, i64 1540, !7, i64 1541, !16, i64 1544, !10, i64 1808, !6, i64 1816, !10, i64 1824, !6, i64 1832, !6, i64 1840, !6, i64 1848, !6, i64 1856, !6, i64 1864, !6, i64 1872, !6, i64 1880, !6, i64 1888, !6, i64 1896, !6, i64 1904, !6, i64 1912}
!15 = !{!"short", !7, i64 0}
!16 = !{!"mc", !7, i64 0, !15, i64 6, !7, i64 8}
!17 = !{!14, !6, i64 1840}
!18 = !{!14, !10, i64 1000}
!19 = !{!14, !6, i64 1896}
!20 = !{!14, !10, i64 1808}


; 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
define dso_local range(i64 0, 15) i64 @MapIt(ptr nocapture noundef readonly %0, i64 noundef %1, i32 noundef %2, i32 noundef %3, i64 noundef %4) local_unnamed_addr #0 {
  %6 = inttoptr i64 %4 to ptr
  %7 = getelementptr inbounds i8, ptr %0, i64 1540
  %8 = load i8, ptr %7, align 4, !tbaa !5
  %9 = icmp eq i8 %8, 48
  br i1 %9, label %10, label %21

10:                                               ; preds = %5
  %11 = getelementptr inbounds i8, ptr %0, i64 1840
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %17

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %0, i64 1000
  %16 = load i64, ptr %15, align 8, !tbaa !15
  store i64 %16, ptr %6, align 8, !tbaa !16
  br label %18

17:                                               ; preds = %10
  tail call void %12(i64 noundef %1, i64 noundef %4) #1
  %.pr = load i64, ptr %6, align 8, !tbaa !16
  br label %18

18:                                               ; preds = %17, %14
  %19 = phi i64 [ %.pr, %17 ], [ %16, %14 ]
  %20 = icmp ugt i64 %19, 4294967296
  br i1 %20, label %32, label %31

21:                                               ; preds = %5
  %22 = getelementptr inbounds i8, ptr %0, i64 1896
  %23 = load ptr, ptr %22, align 8, !tbaa !17
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %28

25:                                               ; preds = %21
  %26 = icmp ugt i64 %1, 4294967296
  br i1 %26, label %32, label %27

27:                                               ; preds = %25
  store i64 %1, ptr %6, align 8, !tbaa !16
  br label %31

28:                                               ; preds = %21
  %29 = getelementptr inbounds i8, ptr %0, i64 1808
  %30 = load i64, ptr %29, align 8, !tbaa !18
  tail call void %23(i64 noundef %30, i64 noundef %1, i32 noundef %2, i32 noundef %3, i64 noundef %4) #1
  br label %31

31:                                               ; preds = %27, %28, %18
  br label %32

32:                                               ; preds = %25, %18, %31
  %.0 = phi i64 [ 0, %31 ], [ 14, %18 ], [ 14, %25 ]
  ret i64 %.0
}

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 = { 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, !8, i64 1540}
!6 = !{!"s_data_instance", !7, i64 0, !7, i64 2, !8, i64 4, !8, i64 5, !7, i64 6, !7, i64 8, !7, i64 10, !7, i64 12, !7, i64 14, !8, i64 16, !8, i64 48, !8, i64 80, !8, i64 112, !8, i64 368, !10, i64 880, !10, i64 884, !7, i64 888, !7, i64 890, !8, i64 892, !8, i64 893, !8, i64 894, !8, i64 895, !7, i64 896, !7, i64 898, !7, i64 900, !7, i64 902, !10, i64 904, !10, i64 908, !7, i64 912, !7, i64 914, !8, i64 916, !8, i64 920, !8, i64 921, !7, i64 922, !10, i64 924, !11, i64 928, !11, i64 936, !11, i64 944, !11, i64 952, !11, i64 960, !11, i64 968, !12, i64 976, !12, i64 984, !12, i64 992, !12, i64 1000, !12, i64 1008, !8, i64 1016, !7, i64 1528, !7, i64 1530, !7, i64 1532, !7, i64 1534, !8, i64 1536, !8, i64 1537, !8, i64 1538, !8, i64 1539, !8, i64 1540, !8, i64 1541, !13, i64 1544, !12, i64 1808, !11, i64 1816, !12, i64 1824, !11, i64 1832, !11, i64 1840, !11, i64 1848, !11, i64 1856, !11, i64 1864, !11, i64 1872, !11, i64 1880, !11, i64 1888, !11, i64 1896, !11, i64 1904, !11, i64 1912}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!"mc", !8, i64 0, !7, i64 6, !8, i64 8}
!14 = !{!6, !11, i64 1840}
!15 = !{!6, !12, i64 1000}
!16 = !{!12, !12, i64 0}
!17 = !{!6, !11, i64 1896}
!18 = !{!6, !12, i64 1808}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass