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

; 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] }

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13IRInstructionC2ERKS_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) unnamed_addr #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i16, align 2
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  %7 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 0
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %class.IRInstruction, ptr %8, i32 0, i32 0
  %10 = load i16, ptr %9, align 8, !tbaa !9
  store i16 %10, ptr %7, align 8, !tbaa !9
  %11 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 1
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %class.IRInstruction, ptr %12, i32 0, i32 1
  %14 = load i16, ptr %13, align 2, !tbaa !14
  store i16 %14, ptr %11, align 2, !tbaa !14
  %15 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 2
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %class.IRInstruction, ptr %16, i32 0, i32 2
  %18 = load i32, ptr %17, align 4, !tbaa !15
  store i32 %18, ptr %15, align 4, !tbaa !15
  %19 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 3
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %class.IRInstruction, ptr %20, i32 0, i32 3
  %22 = load i64, ptr %21, align 8, !tbaa !16
  store i64 %22, ptr %19, align 8, !tbaa !16
  %23 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 4
  store i32 0, ptr %23, align 4, !tbaa !17
  %24 = getelementptr inbounds i32, ptr %23, i64 1
  %25 = getelementptr inbounds i32, ptr %23, i64 4
  br label %26

26:                                               ; preds = %26, %2
  %27 = phi ptr [ %24, %2 ], [ %28, %26 ]
  store i32 0, ptr %27, align 4, !tbaa !17
  %28 = getelementptr inbounds i32, ptr %27, i64 1
  %29 = icmp eq ptr %28, %25
  br i1 %29, label %30, label %26

30:                                               ; preds = %26
  %31 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 1
  %32 = load i16, ptr %31, align 2, !tbaa !14
  %33 = zext i16 %32 to i32
  %34 = icmp sle i32 %33, 4
  br i1 %34, label %35, label %59

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 2, ptr %5) #5
  store i16 0, ptr %5, align 2, !tbaa !18
  br label %36

36:                                               ; preds = %55, %35
  %37 = load i16, ptr %5, align 2, !tbaa !18
  %38 = zext i16 %37 to i32
  %39 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 1
  %40 = load i16, ptr %39, align 2, !tbaa !14
  %41 = zext i16 %40 to i32
  %42 = icmp slt i32 %38, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 2, ptr %5) #5
  br label %58

44:                                               ; preds = %36
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %class.IRInstruction, ptr %45, i32 0, i32 4
  %47 = load i16, ptr %5, align 2, !tbaa !18
  %48 = zext i16 %47 to i64
  %49 = getelementptr inbounds [4 x i32], ptr %46, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !16
  %51 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 4
  %52 = load i16, ptr %5, align 2, !tbaa !18
  %53 = zext i16 %52 to i64
  %54 = getelementptr inbounds [4 x i32], ptr %51, i64 0, i64 %53
  store i32 %50, ptr %54, align 4, !tbaa !16
  br label %55

55:                                               ; preds = %44
  %56 = load i16, ptr %5, align 2, !tbaa !18
  %57 = add i16 %56, 1
  store i16 %57, ptr %5, align 2, !tbaa !18
  br label %36, !llvm.loop !19

58:                                               ; preds = %43
  br label %78

59:                                               ; preds = %30
  %60 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 1
  %61 = load i16, ptr %60, align 2, !tbaa !14
  %62 = zext i16 %61 to i64
  %63 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %62, i64 4)
  %64 = extractvalue { i64, i1 } %63, 1
  %65 = extractvalue { i64, i1 } %63, 0
  %66 = select i1 %64, i64 -1, i64 %65
  %67 = call noalias noundef nonnull ptr @_Znam(i64 noundef %66) #6
  %68 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 4
  store ptr %67, ptr %68, align 8, !tbaa !16
  %69 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 4
  %70 = load ptr, ptr %69, align 8, !tbaa !16
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %class.IRInstruction, ptr %71, i32 0, i32 4
  %73 = load ptr, ptr %72, align 8, !tbaa !16
  %74 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 1
  %75 = load i16, ptr %74, align 2, !tbaa !14
  %76 = zext i16 %75 to i64
  %77 = mul i64 %76, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %70, ptr align 4 %73, i64 %77, i1 false)
  br label %78

78:                                               ; preds = %59, %58
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = call noundef zeroext i1 @_ZNK13IRInstruction8has_dataEv(ptr noundef nonnull align 8 dereferenceable(32) %79)
  br i1 %80, label %81, label %90

81:                                               ; preds = %78
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %class.IRInstruction, ptr %82, i32 0, i32 3
  %84 = load ptr, ptr %83, align 8, !tbaa !16
  %85 = load ptr, ptr %84, align 8, !tbaa !21
  %86 = getelementptr inbounds ptr, ptr %85, i64 10
  %87 = load ptr, ptr %86, align 8
  %88 = call noundef ptr %87(ptr noundef nonnull align 8 dereferenceable(40) %84)
  %89 = getelementptr inbounds %class.IRInstruction, ptr %6, i32 0, i32 3
  store ptr %88, ptr %89, align 8, !tbaa !16
  br label %90

90:                                               ; preds = %81, %78
  ret void
}

; 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) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK13IRInstruction8has_dataEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nobuiltin allocsize(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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }

!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 = !{!10, !12, i64 2}
!15 = !{!10, !13, i64 4}
!16 = !{!7, !7, i64 0}
!17 = !{!13, !13, i64 0}
!18 = !{!12, !12, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!22, !22, i64 0}
!22 = !{!"vtable pointer", !8, 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13IRInstructionC2ERKS_(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) unnamed_addr #1 align 2 {
  %3 = load <2 x i16>, ptr %1, align 8, !tbaa !5
  store <2 x i16> %3, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !8
  store i32 %6, ptr %4, align 4, !tbaa !8
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load i64, ptr %8, align 8, !tbaa !5
  store i64 %9, ptr %7, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = extractelement <2 x i16> %3, i64 1
  %12 = icmp ult i16 %11, 5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %10, i8 0, i64 16, i1 false)
  br i1 %12, label %.preheader, label %27

.preheader:                                       ; preds = %2
  %.not = icmp eq i16 %11, 0
  br i1 %.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %13 = getelementptr inbounds i8, ptr %1, i64 16
  %14 = load i32, ptr %13, align 8, !tbaa !5
  store i32 %14, ptr %10, align 8, !tbaa !5
  %exitcond.not = icmp eq i16 %11, 1
  br i1 %exitcond.not, label %.loopexit, label %15, !llvm.loop !13

15:                                               ; preds = %.lr.ph
  %16 = getelementptr inbounds i8, ptr %1, i64 20
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 %17, ptr %18, align 4, !tbaa !5
  %exitcond.not.1 = icmp eq i16 %11, 2
  br i1 %exitcond.not.1, label %.loopexit, label %19, !llvm.loop !13

19:                                               ; preds = %15
  %20 = getelementptr inbounds i8, ptr %1, i64 24
  %21 = load i32, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %21, ptr %22, align 8, !tbaa !5
  %exitcond.not.2 = icmp eq i16 %11, 3
  br i1 %exitcond.not.2, label %.loopexit, label %23, !llvm.loop !13

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %1, i64 28
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 %25, ptr %26, align 4, !tbaa !5
  br label %.loopexit

27:                                               ; preds = %2
  %28 = zext i16 %11 to i64
  %29 = shl nuw nsw i64 %28, 2
  %30 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %29) #4
  store ptr %30, ptr %10, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %1, i64 16
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 %30, ptr align 4 %32, i64 %29, i1 false)
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %15, %19, %23, %.preheader, %27
  %33 = tail call noundef zeroext i1 @_ZNK13IRInstruction8has_dataEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  br i1 %33, label %34, label %40

34:                                               ; preds = %.loopexit
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = getelementptr inbounds i8, ptr %36, i64 80
  %38 = load ptr, ptr %37, align 8
  %39 = tail call noundef ptr %38(ptr noundef nonnull align 8 dereferenceable(40) %35)
  store ptr %39, ptr %7, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %34, %.loopexit
  ret void
}

; 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) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK13IRInstruction8has_dataEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { nobuiltin allocsize(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 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { builtin allocsize(0) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !12, i64 4}
!9 = !{!"_ZTS13IRInstruction", !10, i64 0, !11, i64 2, !12, i64 4, !6, i64 8, !6, i64 16}
!10 = !{!"_ZTS8IROpcode", !6, i64 0}
!11 = !{!"short", !6, i64 0}
!12 = !{!"int", !6, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass