; LLVM IR from intel/cryptography-primitives :: sources/ippcp/gfpec (pcpgfpec_selectp192r1w7)

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

; Function Attrs: nounwind uwtable
define dso_local void @p192r1_select_ap_w7(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %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 i64, align 8
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 64, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %19, %3
  %12 = load i32, ptr %9, align 4, !tbaa !9
  %13 = icmp ult i32 %12, 6
  br i1 %13, label %14, label %22

14:                                               ; preds = %11
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load i32, ptr %9, align 4, !tbaa !9
  %17 = zext i32 %16 to i64
  %18 = getelementptr inbounds i64, ptr %15, i64 %17
  store i64 0, ptr %18, align 8, !tbaa !11
  br label %19

19:                                               ; preds = %14
  %20 = load i32, ptr %9, align 4, !tbaa !9
  %21 = add i32 %20, 1
  store i32 %21, ptr %9, align 4, !tbaa !9
  br label %11, !llvm.loop !13

22:                                               ; preds = %11
  store i32 1, ptr %8, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %55, %22
  %24 = load i32, ptr %8, align 4, !tbaa !9
  %25 = icmp sle i32 %24, 64
  br i1 %25, label %26, label %58

26:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = call i64 @cpIsEqu_ct(i64 noundef %28, i64 noundef %30)
  store i64 %31, ptr %10, align 8, !tbaa !11
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %49, %26
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = icmp ult i32 %33, 6
  br i1 %34, label %35, label %52

35:                                               ; preds = %32
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds i64, ptr %36, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !11
  %41 = load i64, ptr %10, align 8, !tbaa !11
  %42 = and i64 %40, %41
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load i32, ptr %9, align 4, !tbaa !9
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds i64, ptr %43, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !11
  %48 = or i64 %47, %42
  store i64 %48, ptr %46, align 8, !tbaa !11
  br label %49

49:                                               ; preds = %35
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = add i32 %50, 1
  store i32 %51, ptr %9, align 4, !tbaa !9
  br label %32, !llvm.loop !15

52:                                               ; preds = %32
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds i64, ptr %53, i64 6
  store ptr %54, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %55

55:                                               ; preds = %52
  %56 = load i32, ptr %8, align 4, !tbaa !9
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %8, align 4, !tbaa !9
  br label %23, !llvm.loop !16

58:                                               ; preds = %23
  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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @cpIsEqu_ct(i64 noundef, i64 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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: nounwind uwtable
define dso_local void @p192r1_select_ap_w7(ptr nocapture noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #0 {
.preheader:
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %0, i8 0, i64 48, i1 false), !tbaa !5
  %3 = sext i32 %2 to i64
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  br label %9

9:                                                ; preds = %.preheader, %9
  %indvars.iv = phi i64 [ 1, %.preheader ], [ %indvars.iv.next, %9 ]
  %.020 = phi ptr [ %1, %.preheader ], [ %40, %9 ]
  %10 = tail call i64 @cpIsEqu_ct(i64 noundef %indvars.iv, i64 noundef %3)
  %11 = load i64, ptr %.020, align 8, !tbaa !5
  %12 = and i64 %11, %10
  %13 = load i64, ptr %0, align 8, !tbaa !5
  %14 = or i64 %13, %12
  store i64 %14, ptr %0, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %.020, i64 8
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = and i64 %16, %10
  %18 = load i64, ptr %4, align 8, !tbaa !5
  %19 = or i64 %18, %17
  store i64 %19, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %.020, i64 16
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %22 = and i64 %21, %10
  %23 = load i64, ptr %5, align 8, !tbaa !5
  %24 = or i64 %23, %22
  store i64 %24, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %.020, i64 24
  %26 = load i64, ptr %25, align 8, !tbaa !5
  %27 = and i64 %26, %10
  %28 = load i64, ptr %6, align 8, !tbaa !5
  %29 = or i64 %28, %27
  store i64 %29, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %.020, i64 32
  %31 = load i64, ptr %30, align 8, !tbaa !5
  %32 = and i64 %31, %10
  %33 = load i64, ptr %7, align 8, !tbaa !5
  %34 = or i64 %33, %32
  store i64 %34, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %.020, i64 40
  %36 = load i64, ptr %35, align 8, !tbaa !5
  %37 = and i64 %36, %10
  %38 = load i64, ptr %8, align 8, !tbaa !5
  %39 = or i64 %38, %37
  store i64 %39, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %.020, i64 48
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 65
  br i1 %exitcond.not, label %41, label %9, !llvm.loop !9

41:                                               ; preds = %9
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @cpIsEqu_ct(i64 noundef, i64 noundef) local_unnamed_addr #1

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

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" }
attributes #1 = { inlinehint 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: write) }

!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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass