; LLVM IR from intel/qpl :: tools/utils/generators/configurators (common_methods)

; 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.qpl::test::random" = type { %"class.qpl::test::random_base" }
%"class.qpl::test::random_base" = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, double, double, double, double }

@__const._ZN12gz_generator13CommonMethods10code2MatchEjj.extraBitCountTable = external hidden unnamed_addr constant [29 x i32], align 16
@__const._ZN12gz_generator13CommonMethods10code2MatchEjj.distanceTable = external hidden unnamed_addr constant [29 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
declare dso_local void @_ZN3qpl4test6randomC2Eddj(ptr noundef nonnull align 8 dereferenceable(72), double noundef, double noundef, i32 noundef) unnamed_addr #1 align 2

declare noundef i32 @_ZN3qpl4test11random_basecvjEv(ptr noundef nonnull align 8 dereferenceable(72)) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN12gz_generator13CommonMethods10code2MatchEjj(i32 noundef %0, i32 noundef %1) #1 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca [29 x i32], align 16
  %9 = alloca [29 x i32], align 16
  %10 = alloca %"class.qpl::test::random", align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 116, ptr %8) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %8, ptr align 16 @__const._ZN12gz_generator13CommonMethods10code2MatchEjj.extraBitCountTable, i64 116, i1 false)
  call void @llvm.lifetime.start.p0(i64 116, ptr %9) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %9, ptr align 16 @__const._ZN12gz_generator13CommonMethods10code2MatchEjj.distanceTable, i64 116, i1 false)
  call void @llvm.lifetime.start.p0(i64 72, ptr %10) #4
  %11 = load i32, ptr %4, align 4, !tbaa !5
  call void @_ZN3qpl4test6randomC2Eddj(ptr noundef nonnull align 8 dereferenceable(72) %10, double noundef 0.000000e+00, double noundef 0.000000e+00, i32 noundef %11)
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = sub i32 %12, 257
  store i32 %13, ptr %3, align 4, !tbaa !5
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = zext i32 %14 to i64
  %16 = getelementptr inbounds [29 x i32], ptr %8, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  store i32 %17, ptr %6, align 4, !tbaa !5
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds [29 x i32], ptr %9, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  store i32 %21, ptr %5, align 4, !tbaa !5
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = shl i32 1, %22
  %24 = uitofp i32 %23 to double
  call void @_ZN3qpl4test6random9set_rangeEdd(ptr noundef nonnull align 8 dereferenceable(72) %10, double noundef 0.000000e+00, double noundef %24)
  %25 = call noundef i32 @_ZN3qpl4test11random_basecvjEv(ptr noundef nonnull align 8 dereferenceable(72) %10)
  store i32 %25, ptr %7, align 4, !tbaa !5
  %26 = load i32, ptr %7, align 4, !tbaa !5
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = add i32 %27, %26
  store i32 %28, ptr %5, align 4, !tbaa !5
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = icmp eq i32 %29, 258
  br i1 %30, label %31, label %35

31:                                               ; preds = %2
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = icmp ne i32 %32, 28
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  br label %37

35:                                               ; preds = %31, %2
  %36 = load i32, ptr %5, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %35, %34
  %38 = phi i32 [ 257, %34 ], [ %36, %35 ]
  store i32 %38, ptr %5, align 4, !tbaa !5
  %39 = load i32, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 72, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 116, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 116, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret i32 %39
}

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

declare void @_ZN3qpl4test6random9set_rangeEdd(ptr noundef nonnull align 8 dereferenceable(72), double noundef, double noundef) #2

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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

%"class.qpl::test::random" = type { %"class.qpl::test::random_base" }
%"class.qpl::test::random_base" = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, double, double, double, double }

@__const._ZN12gz_generator13CommonMethods10code2MatchEjj.extraBitCountTable = external hidden unnamed_addr constant [29 x i32], align 16
@__const._ZN12gz_generator13CommonMethods10code2MatchEjj.distanceTable = external hidden unnamed_addr constant [29 x i32], align 16

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3qpl4test6randomC2Eddj(ptr noundef nonnull align 8 dereferenceable(72), double noundef, double noundef, i32 noundef) unnamed_addr #1 align 2

declare noundef i32 @_ZN3qpl4test11random_basecvjEv(ptr noundef nonnull align 8 dereferenceable(72)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN12gz_generator13CommonMethods10code2MatchEjj(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = alloca %"class.qpl::test::random", align 8
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %3) #3
  call void @_ZN3qpl4test6randomC2Eddj(ptr noundef nonnull align 8 dereferenceable(72) %3, double noundef 0.000000e+00, double noundef 0.000000e+00, i32 noundef %1)
  %4 = add i32 %0, -257
  %5 = zext i32 %4 to i64
  %6 = getelementptr inbounds [29 x i32], ptr @__const._ZN12gz_generator13CommonMethods10code2MatchEjj.extraBitCountTable, i64 0, i64 %5
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = getelementptr inbounds [29 x i32], ptr @__const._ZN12gz_generator13CommonMethods10code2MatchEjj.distanceTable, i64 0, i64 %5
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = shl nuw i32 1, %7
  %11 = uitofp i32 %10 to double
  call void @_ZN3qpl4test6random9set_rangeEdd(ptr noundef nonnull align 8 dereferenceable(72) %3, double noundef 0.000000e+00, double noundef %11)
  %12 = call noundef i32 @_ZN3qpl4test11random_basecvjEv(ptr noundef nonnull align 8 dereferenceable(72) %3)
  %13 = add i32 %12, %9
  %14 = icmp eq i32 %13, 258
  %15 = icmp ne i32 %4, 28
  %or.cond = and i1 %15, %14
  %16 = select i1 %or.cond, i32 257, i32 %13
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %3) #3
  ret i32 %16
}

declare void @_ZN3qpl4test6random9set_rangeEdd(ptr noundef nonnull align 8 dereferenceable(72), double noundef, double noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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