; LLVM IR from Optiroc/SuperFamiconv :: src/Map.ll (ZNK3sfc3Map8entry_atEjj)

; 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.sfc::Mapentry" = type <{ i32, i32, i8, i8, [2 x i8] }>
%"struct.sfc::Map" = type { i32, i32, i32, i32, i32, %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<sfc::Mapentry, std::allocator<sfc::Mapentry>>::_Vector_impl" }
%"struct.std::_Vector_base<sfc::Mapentry, std::allocator<sfc::Mapentry>>::_Vector_impl" = type { %"struct.std::_Vector_base<sfc::Mapentry, std::allocator<sfc::Mapentry>>::_Vector_impl_data" }
%"struct.std::_Vector_base<sfc::Mapentry, std::allocator<sfc::Mapentry>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN3sfc8MapentryESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; 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 nounwind uwtable
declare dso_local void @_ZN3sfc8MapentryC2Ejjbb(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef, i32 noundef, i1 noundef zeroext, i1 noundef zeroext) unnamed_addr #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
define dso_local { i64, i32 } @_ZNK3sfc3Map8entry_atEjj(ptr noundef nonnull align 8 dereferenceable(48) %0, i32 noundef %1, i32 noundef %2) #3 align 2 {
  %4 = alloca %"struct.sfc::Mapentry", align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca { i64, i32 }, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %11 = load ptr, ptr %5, align 8
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = getelementptr inbounds %"struct.sfc::Map", ptr %11, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = icmp ugt i32 %12, %14
  br i1 %15, label %16, label %19

16:                                               ; preds = %3
  %17 = getelementptr inbounds %"struct.sfc::Map", ptr %11, i32 0, i32 1
  %18 = load i32, ptr %17, align 4, !tbaa !11
  store i32 %18, ptr %6, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %16, %3
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = getelementptr inbounds %"struct.sfc::Map", ptr %11, i32 0, i32 2
  %22 = load i32, ptr %21, align 8, !tbaa !18
  %23 = icmp ugt i32 %20, %22
  br i1 %23, label %24, label %27

24:                                               ; preds = %19
  %25 = getelementptr inbounds %"struct.sfc::Map", ptr %11, i32 0, i32 2
  %26 = load i32, ptr %25, align 8, !tbaa !18
  store i32 %26, ptr %7, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %24, %19
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = getelementptr inbounds %"struct.sfc::Map", ptr %11, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !11
  %31 = mul i32 %28, %30
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = add i32 %31, %32
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds %"struct.sfc::Map", ptr %11, i32 0, i32 5
  %36 = call noundef i64 @_ZNKSt6vectorIN3sfc8MapentryESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %35) #4
  %37 = icmp ugt i64 %34, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %27
  call void @_ZN3sfc8MapentryC2Ejjbb(ptr noundef nonnull align 4 dereferenceable(12) %4, i32 noundef 0, i32 noundef 0, i1 noundef zeroext false, i1 noundef zeroext false)
  br label %80

39:                                               ; preds = %27
  %40 = getelementptr inbounds %"struct.sfc::Map", ptr %11, i32 0, i32 5
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = getelementptr inbounds %"struct.sfc::Map", ptr %11, i32 0, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !11
  %44 = mul i32 %41, %43
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = add i32 %44, %45
  %47 = zext i32 %46 to i64
  %48 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN3sfc8MapentryESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %40, i64 noundef %47) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %48, i64 12, i1 false), !tbaa.struct !19
  %49 = getelementptr inbounds %"struct.sfc::Map", ptr %11, i32 0, i32 3
  %50 = load i32, ptr %49, align 4, !tbaa !22
  %51 = icmp eq i32 %50, 8
  br i1 %51, label %52, label %57

52:                                               ; preds = %39
  %53 = getelementptr inbounds %"struct.sfc::Map", ptr %11, i32 0, i32 4
  %54 = load i32, ptr %53, align 8, !tbaa !23
  %55 = icmp eq i32 %54, 8
  br i1 %55, label %56, label %57

56:                                               ; preds = %52
  br label %80

57:                                               ; preds = %52, %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %58 = getelementptr inbounds %"struct.sfc::Mapentry", ptr %4, i32 0, i32 0
  %59 = load i32, ptr %58, align 4, !tbaa !24
  %60 = urem i32 %59, 8
  store i32 %60, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %61 = getelementptr inbounds %"struct.sfc::Mapentry", ptr %4, i32 0, i32 0
  %62 = load i32, ptr %61, align 4, !tbaa !24
  %63 = udiv i32 %62, 8
  store i32 %63, ptr %9, align 4, !tbaa !9
  %64 = load i32, ptr %8, align 4, !tbaa !9
  %65 = getelementptr inbounds %"struct.sfc::Map", ptr %11, i32 0, i32 3
  %66 = load i32, ptr %65, align 4, !tbaa !22
  %67 = icmp eq i32 %66, 8
  %68 = zext i1 %67 to i64
  %69 = select i1 %67, i32 1, i32 2
  %70 = mul i32 %64, %69
  %71 = load i32, ptr %9, align 4, !tbaa !9
  %72 = getelementptr inbounds %"struct.sfc::Map", ptr %11, i32 0, i32 4
  %73 = load i32, ptr %72, align 8, !tbaa !23
  %74 = icmp eq i32 %73, 8
  %75 = zext i1 %74 to i64
  %76 = select i1 %74, i32 16, i32 32
  %77 = mul i32 %71, %76
  %78 = add i32 %70, %77
  %79 = getelementptr inbounds %"struct.sfc::Mapentry", ptr %4, i32 0, i32 0
  store i32 %78, ptr %79, align 4, !tbaa !24
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %80

80:                                               ; preds = %57, %56, %38
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 4 %4, i64 12, i1 false)
  %81 = load { i64, i32 }, ptr %10, align 8
  ret { i64, i32 } %81
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN3sfc8MapentryESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"_ZTSN3sfc3MapE", !13, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !14, i64 24}
!13 = !{!"_ZTSN3sfc4ModeE", !7, i64 0}
!14 = !{!"_ZTSSt6vectorIN3sfc8MapentryESaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIN3sfc8MapentryESaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN3sfc8MapentryESaIS1_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN3sfc8MapentryESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!12, !10, i64 8}
!19 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 1, !20, i64 9, i64 1, !20}
!20 = !{!21, !21, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = !{!12, !10, i64 12}
!23 = !{!12, !10, i64 16}
!24 = !{!25, !10, i64 0}
!25 = !{!"_ZTSN3sfc8MapentryE", !10, i64 0, !10, i64 4, !21, i64 8, !21, i64 9}


; 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.sfc::Mapentry" = type <{ i32, i32, i8, i8, [2 x i8] }>

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN3sfc8MapentryESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3sfc8MapentryC2Ejjbb(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef, i32 noundef, i1 noundef zeroext, i1 noundef zeroext) unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local { i64, i32 } @_ZNK3sfc3Map8entry_atEjj(ptr noundef nonnull align 8 dereferenceable(48) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = alloca %"struct.sfc::Mapentry", align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %spec.select = tail call i32 @llvm.umin.i32(i32 %6, i32 %1)
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load i32, ptr %7, align 8, !tbaa !16
  %.08 = tail call i32 @llvm.umin.i32(i32 %8, i32 %2)
  %9 = mul i32 %.08, %6
  %10 = add i32 %9, %spec.select
  %11 = zext i32 %10 to i64
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = tail call noundef i64 @_ZNKSt6vectorIN3sfc8MapentryESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #3
  %14 = icmp ult i64 %13, %11
  br i1 %14, label %15, label %16

15:                                               ; preds = %3
  call void @_ZN3sfc8MapentryC2Ejjbb(ptr noundef nonnull align 4 dereferenceable(12) %4, i32 noundef 0, i32 noundef 0, i1 noundef zeroext false, i1 noundef zeroext false)
  br label %38

16:                                               ; preds = %3
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = mul i32 %17, %.08
  %19 = add i32 %18, %spec.select
  %20 = zext i32 %19 to i64
  %21 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN3sfc8MapentryESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %20) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(12) %4, ptr noundef nonnull align 4 dereferenceable(12) %21, i64 12, i1 false), !tbaa.struct !17
  %22 = getelementptr inbounds i8, ptr %0, i64 12
  %23 = load i32, ptr %22, align 4, !tbaa !21
  %24 = icmp eq i32 %23, 8
  %25 = getelementptr inbounds i8, ptr %0, i64 16
  %26 = load i32, ptr %25, align 8
  %27 = icmp eq i32 %26, 8
  %or.cond = select i1 %24, i1 %27, i1 false
  br i1 %or.cond, label %38, label %28

28:                                               ; preds = %16
  %29 = load i32, ptr %4, align 8, !tbaa !22
  %30 = and i32 %29, 7
  %31 = lshr i32 %29, 3
  %32 = icmp ne i32 %23, 8
  %33 = zext i1 %32 to i32
  %34 = shl nuw nsw i32 %30, %33
  %35 = select i1 %27, i32 4, i32 5
  %36 = shl i32 %31, %35
  %37 = or disjoint i32 %34, %36
  store i32 %37, ptr %4, align 8, !tbaa !22
  br label %38

38:                                               ; preds = %16, %28, %15
  %.sroa.0.0.copyload = load i64, ptr %4, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  %.sroa.2.0.copyload = load i32, ptr %.sroa.2.0..sroa_idx, align 8
  %.fca.0.insert = insertvalue { i64, i32 } poison, i64 %.sroa.0.0.copyload, 0
  %.fca.1.insert = insertvalue { i64, i32 } %.fca.0.insert, i32 %.sroa.2.0.copyload, 1
  ret { i64, i32 } %.fca.1.insert
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt6vectorIN3sfc8MapentryESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #2

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" }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !10, i64 4}
!6 = !{!"_ZTSN3sfc3MapE", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !11, i64 24}
!7 = !{!"_ZTSN3sfc4ModeE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTSSt6vectorIN3sfc8MapentryESaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIN3sfc8MapentryESaIS1_EE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIN3sfc8MapentryESaIS1_EE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIN3sfc8MapentryESaIS1_EE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!6, !10, i64 8}
!17 = !{i64 0, i64 4, !18, i64 4, i64 4, !18, i64 8, i64 1, !19, i64 9, i64 1, !19}
!18 = !{!10, !10, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"bool", !8, i64 0}
!21 = !{!6, !10, i64 12}
!22 = !{!23, !10, i64 0}
!23 = !{!"_ZTSN3sfc8MapentryE", !10, i64 0, !10, i64 4, !20, i64 8, !20, i64 9}


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