; LLVM IR from albertobsd/keyhunt :: keyhunt.ll (Z14vanityrmdmatchPh)

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

@vanity_rmd_targets = external dso_local global i32, align 4
@vanity_rmd_limits = external dso_local global ptr, align 8
@vanity_rmd_limit_values_A = external dso_local global ptr, align 8
@vanity_rmd_limit_values_B = external dso_local global ptr, align 8
@vanity_rmd_minimun_bytes_check_length = external dso_local global i32, align 4
@vanity_bloom = external dso_local global ptr, align 8
@stderr = external global ptr, align 8
@.str.275 = external hidden unnamed_addr constant [30 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #3

declare i32 @bloom_check(ptr noundef, ptr noundef, i32 noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z14vanityrmdmatchPh(ptr noundef %0) #5 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #6
  store i8 0, ptr %3, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %9 = load ptr, ptr @vanity_bloom, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = load i32, ptr @vanity_rmd_minimun_bytes_check_length, align 4, !tbaa !11
  %12 = call i32 @bloom_check(ptr noundef %9, ptr noundef %10, i32 noundef %11)
  store i32 %12, ptr %8, align 4, !tbaa !11
  %13 = load i32, ptr %8, align 4, !tbaa !11
  switch i32 %13, label %81 [
    i32 -1, label %14
    i32 1, label %17
  ]

14:                                               ; preds = %1
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef @.str.275) #6
  call void @exit(i32 noundef 1) #7
  unreachable

17:                                               ; preds = %1
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %18

18:                                               ; preds = %77, %17
  %19 = load i32, ptr %4, align 4, !tbaa !11
  %20 = load i32, ptr @vanity_rmd_targets, align 4, !tbaa !11
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %22, label %26

22:                                               ; preds = %18
  %23 = load i8, ptr %3, align 1, !tbaa !9, !range !13, !noundef !14
  %24 = trunc i8 %23 to i1
  %25 = xor i1 %24, true
  br label %26

26:                                               ; preds = %22, %18
  %27 = phi i1 [ false, %18 ], [ %25, %22 ]
  br i1 %27, label %28, label %80

28:                                               ; preds = %26
  store i32 0, ptr %5, align 4, !tbaa !11
  br label %29

29:                                               ; preds = %73, %28
  %30 = load i32, ptr %5, align 4, !tbaa !11
  %31 = load ptr, ptr @vanity_rmd_limits, align 8, !tbaa !5
  %32 = load i32, ptr %4, align 4, !tbaa !11
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i32, ptr %31, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !11
  %36 = icmp slt i32 %30, %35
  br i1 %36, label %37, label %41

37:                                               ; preds = %29
  %38 = load i8, ptr %3, align 1, !tbaa !9, !range !13, !noundef !14
  %39 = trunc i8 %38 to i1
  %40 = xor i1 %39, true
  br label %41

41:                                               ; preds = %37, %29
  %42 = phi i1 [ false, %29 ], [ %40, %37 ]
  br i1 %42, label %43, label %76

43:                                               ; preds = %41
  %44 = load ptr, ptr @vanity_rmd_limit_values_A, align 8, !tbaa !5
  %45 = load i32, ptr %4, align 4, !tbaa !11
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds ptr, ptr %44, i64 %46
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = load i32, ptr %5, align 4, !tbaa !11
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds ptr, ptr %48, i64 %50
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = call i32 @memcmp(ptr noundef %52, ptr noundef %53, i64 noundef 20) #8
  store i32 %54, ptr %6, align 4, !tbaa !11
  %55 = load ptr, ptr @vanity_rmd_limit_values_B, align 8, !tbaa !5
  %56 = load i32, ptr %4, align 4, !tbaa !11
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds ptr, ptr %55, i64 %57
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %60 = load i32, ptr %5, align 4, !tbaa !11
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds ptr, ptr %59, i64 %61
  %63 = load ptr, ptr %62, align 8, !tbaa !5
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = call i32 @memcmp(ptr noundef %63, ptr noundef %64, i64 noundef 20) #8
  store i32 %65, ptr %7, align 4, !tbaa !11
  %66 = load i32, ptr %6, align 4, !tbaa !11
  %67 = icmp sle i32 %66, 0
  br i1 %67, label %68, label %72

68:                                               ; preds = %43
  %69 = load i32, ptr %7, align 4, !tbaa !11
  %70 = icmp sge i32 %69, 0
  br i1 %70, label %71, label %72

71:                                               ; preds = %68
  store i8 1, ptr %3, align 1, !tbaa !9
  br label %72

72:                                               ; preds = %71, %68, %43
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %5, align 4, !tbaa !11
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %5, align 4, !tbaa !11
  br label %29, !llvm.loop !15

76:                                               ; preds = %41
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %4, align 4, !tbaa !11
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %4, align 4, !tbaa !11
  br label %18, !llvm.loop !17

80:                                               ; preds = %26
  br label %82

81:                                               ; preds = %1
  store i8 0, ptr %3, align 1, !tbaa !9
  br label %82

82:                                               ; preds = %81, %80
  %83 = load i8, ptr %3, align 1, !tbaa !9, !range !13, !noundef !14
  %84 = trunc i8 %83 to i1
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #6
  ret i1 %84
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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 = { noreturn nounwind "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 willreturn memory(read) "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 = { "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 #5 = { 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 #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { nounwind willreturn memory(read) }

!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 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


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

@vanity_rmd_targets = external dso_local local_unnamed_addr global i32, align 4
@vanity_rmd_limits = external dso_local local_unnamed_addr global ptr, align 8
@vanity_rmd_limit_values_A = external dso_local local_unnamed_addr global ptr, align 8
@vanity_rmd_limit_values_B = external dso_local local_unnamed_addr global ptr, align 8
@vanity_rmd_minimun_bytes_check_length = external dso_local local_unnamed_addr global i32, align 4
@vanity_bloom = external dso_local local_unnamed_addr global ptr, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.275 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @memcmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #2

declare i32 @bloom_check(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z14vanityrmdmatchPh(ptr noundef %0) local_unnamed_addr #4 {
  %2 = load ptr, ptr @vanity_bloom, align 8, !tbaa !5
  %3 = load i32, ptr @vanity_rmd_minimun_bytes_check_length, align 4, !tbaa !9
  %4 = tail call i32 @bloom_check(ptr noundef %2, ptr noundef %0, i32 noundef %3)
  switch i32 %4, label %.loopexit [
    i32 -1, label %11
    i32 1, label %.preheader22
  ]

.preheader22:                                     ; preds = %1
  %5 = load i32, ptr @vanity_rmd_targets, align 4, !tbaa !9
  %6 = icmp slt i32 %5, 1
  br i1 %6, label %.loopexit, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %.preheader22
  %7 = load ptr, ptr @vanity_rmd_limits, align 8, !tbaa !5
  %8 = load ptr, ptr @vanity_rmd_limit_values_A, align 8
  %9 = load ptr, ptr @vanity_rmd_limit_values_B, align 8
  %10 = zext nneg i32 %5 to i64
  br label %.preheader

11:                                               ; preds = %1
  %12 = load ptr, ptr @stderr, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.275) #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %indvars.iv29 = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next30, %._crit_edge ]
  %.027 = phi i8 [ 0, %.preheader.lr.ph ], [ %.1.lcssa, %._crit_edge ]
  %14 = getelementptr inbounds i32, ptr %7, i64 %indvars.iv29
  %15 = load i32, ptr %14, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 1
  %17 = trunc nuw i8 %.027 to i1
  %.not2123 = select i1 %16, i1 true, i1 %17
  br i1 %.not2123, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %18 = getelementptr inbounds ptr, ptr %8, i64 %indvars.iv29
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %20 = getelementptr inbounds ptr, ptr %9, i64 %indvars.iv29
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  %22 = zext nneg i32 %15 to i64
  br label %23

23:                                               ; preds = %.lr.ph, %23
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %23 ]
  %.125 = phi i8 [ %.027, %.lr.ph ], [ %spec.select, %23 ]
  %24 = getelementptr inbounds ptr, ptr %19, i64 %indvars.iv
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = tail call i32 @memcmp(ptr noundef nonnull dereferenceable(20) %25, ptr noundef nonnull dereferenceable(20) %0, i64 noundef 20) #7
  %27 = getelementptr inbounds ptr, ptr %21, i64 %indvars.iv
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = tail call i32 @memcmp(ptr noundef nonnull dereferenceable(20) %28, ptr noundef nonnull dereferenceable(20) %0, i64 noundef 20) #7
  %30 = icmp slt i32 %26, 1
  %31 = icmp sgt i32 %29, -1
  %or.cond = select i1 %30, i1 %31, i1 false
  %spec.select = select i1 %or.cond, i8 1, i8 %.125
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %32 = icmp uge i64 %indvars.iv.next, %22
  %33 = trunc nuw i8 %spec.select to i1
  %.not21 = select i1 %32, i1 true, i1 %33
  br i1 %.not21, label %._crit_edge, label %23, !llvm.loop !11

._crit_edge:                                      ; preds = %23, %.preheader
  %.pre-phi = phi i1 [ %17, %.preheader ], [ %33, %23 ]
  %.1.lcssa = phi i8 [ %.027, %.preheader ], [ %spec.select, %23 ]
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %34 = icmp uge i64 %indvars.iv.next30, %10
  %.not20 = select i1 %34, i1 true, i1 %.pre-phi
  br i1 %.not20, label %.loopexit.loopexit, label %.preheader, !llvm.loop !13

.loopexit.loopexit:                               ; preds = %._crit_edge
  %35 = trunc nuw i8 %.1.lcssa to i1
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.preheader22, %1
  %.3 = phi i1 [ false, %1 ], [ false, %.preheader22 ], [ %35, %.loopexit.loopexit ]
  ret i1 %.3
}

attributes #0 = { nofree nounwind "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 = { noreturn nounwind "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 nofree nounwind willreturn memory(argmem: read) "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 = { "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 = { 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 #5 = { cold nounwind }
attributes #6 = { noreturn nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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