; LLVM IR from intel/cryptography-primitives :: sources/ippcp/crypto_mb/src/common (cpu_features)

; 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.anon = type { ptr, i32 }
%struct.algo_width_map = type { i32, i32 }

@__const.mbx_get_algo_info.map_tbl = external hidden unnamed_addr constant [2 x %struct.anon], 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: nounwind uwtable
declare dso_local i32 @internal_is_k1_applicable(i64 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @internal_is_l9_applicable(i64 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @_mbx_own_get_index() #1

; Function Attrs: nounwind uwtable
define dso_local i64 @mbx_get_algo_info(i32 noundef %0) #1 {
  %2 = alloca i64, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca [2 x %struct.anon], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %13 = call i32 @internal_is_k1_applicable(i64 noundef 0)
  store i32 %13, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %14 = call i32 @internal_is_l9_applicable(i64 noundef 0)
  store i32 %14, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %6) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %6, ptr align 16 @__const.mbx_get_algo_info.map_tbl, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = icmp eq i32 0, %15
  br i1 %16, label %17, label %23

17:                                               ; preds = %1
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = icmp eq i32 0, %18
  br i1 %19, label %20, label %23

20:                                               ; preds = %17
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  store i64 %22, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %75

23:                                               ; preds = %17, %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %24 = call ptr @_mbx_own_get_index()
  %25 = load i32, ptr %24, align 4, !tbaa !5
  store i32 %25, ptr %9, align 4, !tbaa !5
  %26 = load i32, ptr %9, align 4, !tbaa !5
  %27 = icmp slt i32 %26, 0
  br i1 %27, label %31, label %28

28:                                               ; preds = %23
  %29 = load i32, ptr %9, align 4, !tbaa !5
  %30 = icmp sge i32 %29, 2
  br i1 %30, label %31, label %34

31:                                               ; preds = %28, %23
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  store i64 %33, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %74

34:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %35 = load i32, ptr %9, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [2 x %struct.anon], ptr %6, i64 0, i64 %36
  %38 = getelementptr inbounds %struct.anon, ptr %37, i32 0, i32 1
  %39 = load i32, ptr %38, align 8, !tbaa !9
  store i32 %39, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %40 = load i32, ptr %9, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [2 x %struct.anon], ptr %6, i64 0, i64 %41
  %43 = getelementptr inbounds %struct.anon, ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 16, !tbaa !12
  store ptr %44, ptr %11, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %67, %34
  %46 = load i32, ptr %12, align 4, !tbaa !5
  %47 = load i32, ptr %10, align 4, !tbaa !5
  %48 = icmp ult i32 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  store i32 2, ptr %8, align 4
  br label %70

50:                                               ; preds = %45
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = load ptr, ptr %11, align 8, !tbaa !13
  %53 = load i32, ptr %12, align 4, !tbaa !5
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds %struct.algo_width_map, ptr %52, i64 %54
  %56 = getelementptr inbounds %struct.algo_width_map, ptr %55, i32 0, i32 0
  %57 = load i32, ptr %56, align 4, !tbaa !14
  %58 = icmp ne i32 %51, %57
  br i1 %58, label %59, label %60

59:                                               ; preds = %50
  br label %67

60:                                               ; preds = %50
  %61 = load ptr, ptr %11, align 8, !tbaa !13
  %62 = load i32, ptr %12, align 4, !tbaa !5
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds %struct.algo_width_map, ptr %61, i64 %63
  %65 = getelementptr inbounds %struct.algo_width_map, ptr %64, i32 0, i32 1
  %66 = load i32, ptr %65, align 4, !tbaa !16
  store i32 %66, ptr %7, align 4, !tbaa !5
  store i32 2, ptr %8, align 4
  br label %70

67:                                               ; preds = %59
  %68 = load i32, ptr %12, align 4, !tbaa !5
  %69 = add i32 %68, 1
  store i32 %69, ptr %12, align 4, !tbaa !5
  br label %45, !llvm.loop !17

70:                                               ; preds = %60, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  store i64 %73, ptr %2, align 8
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %74

74:                                               ; preds = %71, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %75

75:                                               ; preds = %74, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %76 = load i64, ptr %2, align 8
  ret i64 %76
}

; 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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"", !11, i64 0, !6, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"", !6, i64 0, !6, i64 4}
!16 = !{!15, !6, i64 4}
!17 = distinct !{!17, !18}
!18 = !{!"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"

%struct.anon = type { ptr, i32 }
%struct.algo_width_map = type { i32, i32 }

@__const.mbx_get_algo_info.map_tbl = external hidden unnamed_addr constant [2 x %struct.anon], align 16

; Function Attrs: nounwind uwtable
declare dso_local i32 @internal_is_k1_applicable(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @internal_is_l9_applicable(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @_mbx_own_get_index() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i64 -2147483648, 2147483648) i64 @mbx_get_algo_info(i32 noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @internal_is_k1_applicable(i64 noundef 0)
  %3 = tail call i32 @internal_is_l9_applicable(i64 noundef 0)
  %4 = icmp eq i32 %2, 0
  %5 = icmp eq i32 %3, 0
  %or.cond = select i1 %4, i1 %5, i1 false
  br i1 %or.cond, label %.loopexit, label %6

6:                                                ; preds = %1
  %7 = tail call ptr @_mbx_own_get_index()
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %or.cond3 = icmp ugt i32 %8, 1
  br i1 %or.cond3, label %.loopexit, label %9

9:                                                ; preds = %6
  %10 = zext nneg i32 %8 to i64
  %11 = getelementptr inbounds [2 x %struct.anon], ptr @__const.mbx_get_algo_info.map_tbl, i64 0, i64 %10
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  %13 = load i32, ptr %12, align 8, !tbaa !9
  %14 = load ptr, ptr %11, align 16, !tbaa !12
  %.not25 = icmp eq i32 %13, 0
  br i1 %.not25, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %9
  %wide.trip.count = zext i32 %13 to i64
  br label %.lr.ph

15:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !13

.lr.ph:                                           ; preds = %.lr.ph.preheader, %15
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %15 ]
  %16 = getelementptr inbounds %struct.algo_width_map, ptr %14, i64 %indvars.iv
  %17 = load i32, ptr %16, align 4, !tbaa !15
  %.not = icmp eq i32 %17, %0
  br i1 %.not, label %18, label %15

18:                                               ; preds = %.lr.ph
  %19 = getelementptr inbounds %struct.algo_width_map, ptr %14, i64 %indvars.iv, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !17
  %21 = sext i32 %20 to i64
  br label %.loopexit

.loopexit:                                        ; preds = %15, %9, %6, %18, %1
  %.1 = phi i64 [ 0, %1 ], [ 0, %6 ], [ %21, %18 ], [ 0, %9 ], [ 0, %15 ]
  ret i64 %.1
}

attributes #0 = { 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" }

!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/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"", !11, i64 0, !6, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !6, i64 0}
!16 = !{!"", !6, i64 0, !6, i64 4}
!17 = !{!16, !6, i64 4}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass