; LLVM IR from tevador/RandomX :: src/jit_compiler_x86.ll (ZN7randomx14JitCompilerX869h_CBRANCHERNS_11InstructionEi)

; 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.randomx::Instruction" = type { i8, i8, i8, i8, i32 }
%"class.randomx::JitCompilerX86" = type <{ %"class.std::vector", [8 x i32], ptr, i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZN7randomxL9REX_ADD_IE = external hidden constant [2 x i8], align 1
@_ZN7randomxL8REX_TESTE = external hidden constant [2 x i8], align 1
@_ZN7randomxL2JZE = external hidden constant [2 x i8], align 1

; 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 nounwind uwtable
declare dso_local void @_ZN7randomx14JitCompilerX864emitILm2EEEvRAT__Kh(ptr noundef nonnull align 8 dereferenceable(68), ptr noundef nonnull align 1 dereferenceable(2)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7randomx14JitCompilerX868emitByteEh(ptr noundef nonnull align 8 dereferenceable(68), i8 noundef zeroext) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7randomx14JitCompilerX866emit32Ej(ptr noundef nonnull align 8 dereferenceable(68), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK7randomx11Instruction8getImm32Ev(ptr noundef nonnull align 4 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7randomx11Instruction10getModCondEv(ptr noundef nonnull align 4 dereferenceable(8)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7randomx14JitCompilerX869h_CBRANCHERNS_11InstructionEi(ptr noundef nonnull align 8 dereferenceable(68) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, i32 noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %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 i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %12 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %"class.randomx::Instruction", ptr %13, i32 0, i32 1
  %15 = load i8, ptr %14, align 1, !tbaa !11
  %16 = zext i8 %15 to i32
  store i32 %16, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %17 = getelementptr inbounds %"class.randomx::JitCompilerX86", ptr %12, i32 0, i32 1
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [8 x i32], ptr %17, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %8, align 4, !tbaa !9
  call void @_ZN7randomx14JitCompilerX864emitILm2EEEvRAT__Kh(ptr noundef nonnull align 8 dereferenceable(68) %12, ptr noundef nonnull align 1 dereferenceable(2) @_ZN7randomxL9REX_ADD_IE)
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = add nsw i32 192, %23
  %25 = trunc i32 %24 to i8
  call void @_ZN7randomx14JitCompilerX868emitByteEh(ptr noundef nonnull align 8 dereferenceable(68) %12, i8 noundef zeroext %25)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call noundef i32 @_ZNK7randomx11Instruction10getModCondEv(ptr noundef nonnull align 4 dereferenceable(8) %26)
  %28 = add nsw i32 %27, 8
  store i32 %28, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = call noundef i32 @_ZNK7randomx11Instruction8getImm32Ev(ptr noundef nonnull align 4 dereferenceable(8) %29)
  %31 = zext i32 %30 to i64
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = zext i32 %32 to i64
  %34 = shl i64 1, %33
  %35 = or i64 %31, %34
  %36 = trunc i64 %35 to i32
  store i32 %36, ptr %10, align 4, !tbaa !9
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = sub nsw i32 %37, 1
  %39 = zext i32 %38 to i64
  %40 = shl i64 1, %39
  %41 = xor i64 %40, -1
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = zext i32 %42 to i64
  %44 = and i64 %43, %41
  %45 = trunc i64 %44 to i32
  store i32 %45, ptr %10, align 4, !tbaa !9
  %46 = load i32, ptr %10, align 4, !tbaa !9
  call void @_ZN7randomx14JitCompilerX866emit32Ej(ptr noundef nonnull align 8 dereferenceable(68) %12, i32 noundef %46)
  call void @_ZN7randomx14JitCompilerX864emitILm2EEEvRAT__Kh(ptr noundef nonnull align 8 dereferenceable(68) %12, ptr noundef nonnull align 1 dereferenceable(2) @_ZN7randomxL8REX_TESTE)
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = add nsw i32 192, %47
  %49 = trunc i32 %48 to i8
  call void @_ZN7randomx14JitCompilerX868emitByteEh(ptr noundef nonnull align 8 dereferenceable(68) %12, i8 noundef zeroext %49)
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = shl i32 255, %50
  call void @_ZN7randomx14JitCompilerX866emit32Ej(ptr noundef nonnull align 8 dereferenceable(68) %12, i32 noundef %51)
  call void @_ZN7randomx14JitCompilerX864emitILm2EEEvRAT__Kh(ptr noundef nonnull align 8 dereferenceable(68) %12, ptr noundef nonnull align 1 dereferenceable(2) @_ZN7randomxL2JZE)
  %52 = getelementptr inbounds %"class.randomx::JitCompilerX86", ptr %12, i32 0, i32 0
  %53 = load i32, ptr %8, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %52, i64 noundef %54) #3
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = getelementptr inbounds %"class.randomx::JitCompilerX86", ptr %12, i32 0, i32 3
  %58 = load i32, ptr %57, align 8, !tbaa !13
  %59 = add nsw i32 %58, 4
  %60 = sub nsw i32 %56, %59
  call void @_ZN7randomx14JitCompilerX866emit32Ej(ptr noundef nonnull align 8 dereferenceable(68) %12, i32 noundef %60)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %71, %3
  %62 = load i32, ptr %11, align 4, !tbaa !9
  %63 = icmp ult i32 %62, 8
  br i1 %63, label %65, label %64

64:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %74

65:                                               ; preds = %61
  %66 = load i32, ptr %6, align 4, !tbaa !9
  %67 = getelementptr inbounds %"class.randomx::JitCompilerX86", ptr %12, i32 0, i32 1
  %68 = load i32, ptr %11, align 4, !tbaa !9
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds [8 x i32], ptr %67, i64 0, i64 %69
  store i32 %66, ptr %70, align 4, !tbaa !9
  br label %71

71:                                               ; preds = %65
  %72 = load i32, ptr %11, align 4, !tbaa !9
  %73 = add i32 %72, 1
  store i32 %73, ptr %11, align 4, !tbaa !9
  br label %61, !llvm.loop !19

74:                                               ; preds = %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 #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, !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, !7, i64 1}
!12 = !{!"_ZTSN7randomx11InstructionE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !10, i64 4}
!13 = !{!14, !10, i64 64}
!14 = !{!"_ZTSN7randomx14JitCompilerX86E", !15, i64 0, !7, i64 24, !6, i64 56, !10, i64 64}
!15 = !{!"_ZTSSt6vectorIiSaIiEE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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

@_ZN7randomxL9REX_ADD_IE = external hidden constant [2 x i8], align 1
@_ZN7randomxL8REX_TESTE = external hidden constant [2 x i8], align 1
@_ZN7randomxL2JZE = external hidden constant [2 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7randomx14JitCompilerX864emitILm2EEEvRAT__Kh(ptr noundef nonnull align 8 dereferenceable(68), ptr noundef nonnull align 1 dereferenceable(2)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7randomx14JitCompilerX868emitByteEh(ptr noundef nonnull align 8 dereferenceable(68), i8 noundef zeroext) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7randomx14JitCompilerX866emit32Ej(ptr noundef nonnull align 8 dereferenceable(68), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK7randomx11Instruction8getImm32Ev(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7randomx11Instruction10getModCondEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7randomx14JitCompilerX869h_CBRANCHERNS_11InstructionEi(ptr noundef nonnull align 8 dereferenceable(68) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, i32 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = getelementptr inbounds i8, ptr %1, i64 1
  %5 = load i8, ptr %4, align 1, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = zext i8 %5 to i64
  %8 = getelementptr inbounds [8 x i32], ptr %6, i64 0, i64 %7
  %9 = load i32, ptr %8, align 4, !tbaa !10
  %10 = add nsw i32 %9, 1
  tail call void @_ZN7randomx14JitCompilerX864emitILm2EEEvRAT__Kh(ptr noundef nonnull align 8 dereferenceable(68) %0, ptr noundef nonnull align 1 dereferenceable(2) @_ZN7randomxL9REX_ADD_IE)
  %11 = add i8 %5, -64
  tail call void @_ZN7randomx14JitCompilerX868emitByteEh(ptr noundef nonnull align 8 dereferenceable(68) %0, i8 noundef zeroext %11)
  %12 = tail call noundef i32 @_ZNK7randomx11Instruction10getModCondEv(ptr noundef nonnull align 4 dereferenceable(8) %1)
  %13 = add nsw i32 %12, 8
  %14 = tail call noundef i32 @_ZNK7randomx11Instruction8getImm32Ev(ptr noundef nonnull align 4 dereferenceable(8) %1)
  %15 = zext nneg i32 %13 to i64
  %16 = shl nuw i64 1, %15
  %17 = trunc i64 %16 to i32
  %18 = or i32 %14, %17
  %19 = add nsw i32 %12, 7
  %20 = zext nneg i32 %19 to i64
  %21 = shl nuw i64 1, %20
  %22 = trunc i64 %21 to i32
  %23 = xor i32 %22, -1
  %24 = and i32 %18, %23
  tail call void @_ZN7randomx14JitCompilerX866emit32Ej(ptr noundef nonnull align 8 dereferenceable(68) %0, i32 noundef %24)
  tail call void @_ZN7randomx14JitCompilerX864emitILm2EEEvRAT__Kh(ptr noundef nonnull align 8 dereferenceable(68) %0, ptr noundef nonnull align 1 dereferenceable(2) @_ZN7randomxL8REX_TESTE)
  tail call void @_ZN7randomx14JitCompilerX868emitByteEh(ptr noundef nonnull align 8 dereferenceable(68) %0, i8 noundef zeroext %11)
  %25 = shl i32 255, %13
  tail call void @_ZN7randomx14JitCompilerX866emit32Ej(ptr noundef nonnull align 8 dereferenceable(68) %0, i32 noundef %25)
  tail call void @_ZN7randomx14JitCompilerX864emitILm2EEEvRAT__Kh(ptr noundef nonnull align 8 dereferenceable(68) %0, ptr noundef nonnull align 1 dereferenceable(2) @_ZN7randomxL2JZE)
  %26 = sext i32 %10 to i64
  %27 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %26) #2
  %28 = load i32, ptr %27, align 4, !tbaa !10
  %29 = getelementptr inbounds i8, ptr %0, i64 64
  %30 = load i32, ptr %29, align 8, !tbaa !11
  %.neg16 = add i32 %28, -4
  %31 = sub i32 %.neg16, %30
  tail call void @_ZN7randomx14JitCompilerX866emit32Ej(ptr noundef nonnull align 8 dereferenceable(68) %0, i32 noundef %31)
  %32 = insertelement <4 x i32> poison, i32 %2, i64 0
  %33 = shufflevector <4 x i32> %32, <4 x i32> poison, <4 x i32> zeroinitializer
  store <4 x i32> %33, ptr %6, align 8, !tbaa !10
  %34 = getelementptr inbounds i8, ptr %0, i64 40
  store <4 x i32> %33, ptr %34, align 8, !tbaa !10
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #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 = { 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 = { 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 1}
!6 = !{!"_ZTSN7randomx11InstructionE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !9, i64 4}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!9, !9, i64 0}
!11 = !{!12, !9, i64 64}
!12 = !{!"_ZTSN7randomx14JitCompilerX86E", !13, i64 0, !7, i64 24, !17, i64 56, !9, i64 64}
!13 = !{!"_ZTSSt6vectorIiSaIiEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!17 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass