; LLVM IR from facebook/redex :: libredex/IRInstruction.ll (ZNK13IRInstruction4sizeEv)

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

%class.IRInstruction = type { i16, i16, i32, %union.anon.0, %union.anon.1 }
%union.anon.0 = type { i64 }
%union.anon.1 = type { ptr, [8 x i8] }

@_ZZNK13IRInstruction4sizeEvE4args = external hidden global [43 x i32], align 16

; 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: mustprogress uwtable
define dso_local noundef zeroext i16 @_ZNK13IRInstruction4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #1 align 2 {
  %2 = alloca i16, align 2
  %3 = alloca ptr, align 8
  %4 = alloca i16, align 2
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 2, ptr %4) #4
  %7 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 0
  %8 = load i16, ptr %7, align 8, !tbaa !9
  store i16 %8, ptr %4, align 2, !tbaa !14
  %9 = load i16, ptr %4, align 2, !tbaa !14
  %10 = call noundef zeroext i1 @_ZN6opcode16is_write_barrierE8IROpcode(i16 noundef zeroext %9)
  br i1 %10, label %11, label %12

11:                                               ; preds = %1
  store i16 90, ptr %4, align 2, !tbaa !14
  br label %12

12:                                               ; preds = %11, %1
  %13 = load i16, ptr %4, align 2, !tbaa !14
  %14 = call noundef zeroext i1 @_ZN6opcode14is_an_internalE8IROpcode(i16 noundef zeroext %13)
  br i1 %14, label %15, label %27

15:                                               ; preds = %12
  %16 = load i16, ptr %4, align 2, !tbaa !14
  %17 = call noundef zeroext i1 @_ZN6opcode15is_injection_idE8IROpcode(i16 noundef zeroext %16)
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  br label %24

19:                                               ; preds = %15
  %20 = load i16, ptr %4, align 2, !tbaa !14
  %21 = call noundef zeroext i1 @_ZN6opcode14is_unreachableE8IROpcode(i16 noundef zeroext %20)
  %22 = zext i1 %21 to i64
  %23 = select i1 %21, i32 1, i32 0
  br label %24

24:                                               ; preds = %19, %18
  %25 = phi i32 [ 2, %18 ], [ %23, %19 ]
  %26 = trunc i32 %25 to i16
  store i16 %26, ptr %2, align 2
  store i32 1, ptr %5, align 4
  br label %35

27:                                               ; preds = %12
  %28 = load i16, ptr %4, align 2, !tbaa !14
  %29 = call noundef zeroext i16 @_ZN6opcode13to_dex_opcodeE8IROpcode(i16 noundef zeroext %28)
  %30 = call noundef zeroext i8 @_ZN10dex_opcode6formatE9DexOpcode(i16 noundef zeroext %29)
  %31 = zext i8 %30 to i64
  %32 = getelementptr inbounds [43 x i32], ptr @_ZZNK13IRInstruction4sizeEvE4args, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !15
  %34 = trunc i32 %33 to i16
  store i16 %34, ptr %2, align 2
  store i32 1, ptr %5, align 4
  br label %35

35:                                               ; preds = %27, %24
  call void @llvm.lifetime.end.p0(i64 2, ptr %4) #4
  %36 = load i16, ptr %2, align 2
  ret i16 %36
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode16is_write_barrierE8IROpcode(i16 noundef zeroext) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode14is_an_internalE8IROpcode(i16 noundef zeroext) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode15is_injection_idE8IROpcode(i16 noundef zeroext) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode14is_unreachableE8IROpcode(i16 noundef zeroext) #2

declare noundef zeroext i8 @_ZN10dex_opcode6formatE9DexOpcode(i16 noundef zeroext) #3

declare noundef zeroext i16 @_ZN6opcode13to_dex_opcodeE8IROpcode(i16 noundef zeroext) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 #3 = { "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, !11, i64 0}
!10 = !{!"_ZTS13IRInstruction", !11, i64 0, !12, i64 2, !13, i64 4, !7, i64 8, !7, i64 16}
!11 = !{!"_ZTS8IROpcode", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!13, !13, 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"

@_ZZNK13IRInstruction4sizeEvE4args = external hidden local_unnamed_addr global [43 x i32], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i16 @_ZNK13IRInstruction4sizeEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(32) %0) local_unnamed_addr #0 align 2 {
  %2 = load i16, ptr %0, align 8, !tbaa !5
  %3 = tail call noundef zeroext i1 @_ZN6opcode16is_write_barrierE8IROpcode(i16 noundef zeroext %2)
  %spec.select = select i1 %3, i16 90, i16 %2
  %4 = tail call noundef zeroext i1 @_ZN6opcode14is_an_internalE8IROpcode(i16 noundef zeroext %spec.select)
  br i1 %4, label %5, label %10

5:                                                ; preds = %1
  %6 = tail call noundef zeroext i1 @_ZN6opcode15is_injection_idE8IROpcode(i16 noundef zeroext %spec.select)
  br i1 %6, label %17, label %7

7:                                                ; preds = %5
  %8 = tail call noundef zeroext i1 @_ZN6opcode14is_unreachableE8IROpcode(i16 noundef zeroext %spec.select)
  %9 = zext i1 %8 to i16
  br label %17

10:                                               ; preds = %1
  %11 = tail call noundef zeroext i16 @_ZN6opcode13to_dex_opcodeE8IROpcode(i16 noundef zeroext %spec.select)
  %12 = tail call noundef zeroext i8 @_ZN10dex_opcode6formatE9DexOpcode(i16 noundef zeroext %11)
  %13 = zext i8 %12 to i64
  %14 = getelementptr inbounds [43 x i32], ptr @_ZZNK13IRInstruction4sizeEvE4args, i64 0, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !12
  %16 = trunc i32 %15 to i16
  br label %17

17:                                               ; preds = %7, %5, %10
  %.06 = phi i16 [ %16, %10 ], [ %9, %7 ], [ 2, %5 ]
  ret i16 %.06
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode16is_write_barrierE8IROpcode(i16 noundef zeroext) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode14is_an_internalE8IROpcode(i16 noundef zeroext) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode15is_injection_idE8IROpcode(i16 noundef zeroext) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6opcode14is_unreachableE8IROpcode(i16 noundef zeroext) local_unnamed_addr #1

declare noundef zeroext i8 @_ZN10dex_opcode6formatE9DexOpcode(i16 noundef zeroext) local_unnamed_addr #2

declare noundef zeroext i16 @_ZN6opcode13to_dex_opcodeE8IROpcode(i16 noundef zeroext) local_unnamed_addr #2

attributes #0 = { 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 #1 = { inlinehint 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 #2 = { "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, !7, i64 0}
!6 = !{!"_ZTS13IRInstruction", !7, i64 0, !10, i64 2, !11, i64 4, !8, i64 8, !8, i64 16}
!7 = !{!"_ZTS8IROpcode", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!11, !11, i64 0}


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