; LLVM IR from intuitive-robots/mdt_policy :: pyhash-0.9.3/src/smhasher/Types.ll (Z7isprimej)

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

@__const._Z7isprimej.p = external hidden unnamed_addr constant [54 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z7isprimej(i32 noundef %0) #0 {
  %2 = alloca i1, align 1
  %3 = alloca i32, align 4
  %4 = alloca [54 x i32], align 16
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 216, ptr %4) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %4, ptr align 16 @__const._Z7isprimej.p, i64 216, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %8

8:                                                ; preds = %21, %1
  %9 = load i64, ptr %5, align 8, !tbaa !9
  %10 = icmp ult i64 %9, 54
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  store i32 2, ptr %6, align 4
  br label %24

12:                                               ; preds = %8
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = load i64, ptr %5, align 8, !tbaa !9
  %15 = getelementptr inbounds [54 x i32], ptr %4, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = urem i32 %13, %16
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %12
  store i1 false, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %24

20:                                               ; preds = %12
  br label %21

21:                                               ; preds = %20
  %22 = load i64, ptr %5, align 8, !tbaa !9
  %23 = add i64 %22, 1
  store i64 %23, ptr %5, align 8, !tbaa !9
  br label %8, !llvm.loop !11

24:                                               ; preds = %19, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  %25 = load i32, ptr %6, align 4
  switch i32 %25, label %44 [
    i32 2, label %26
  ]

26:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 257, ptr %7, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %38, %26
  %28 = load i32, ptr %7, align 4, !tbaa !5
  %29 = icmp slt i32 %28, 65536
  br i1 %29, label %31, label %30

30:                                               ; preds = %27
  store i32 5, ptr %6, align 4
  br label %41

31:                                               ; preds = %27
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = urem i32 %32, %33
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %31
  store i1 false, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %41

37:                                               ; preds = %31
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = add nsw i32 %39, 2
  store i32 %40, ptr %7, align 4, !tbaa !5
  br label %27, !llvm.loop !13

41:                                               ; preds = %36, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %42 = load i32, ptr %6, align 4
  switch i32 %42, label %44 [
    i32 5, label %43
  ]

43:                                               ; preds = %41
  store i1 true, ptr %2, align 1
  store i32 1, ptr %6, align 4
  br label %44

44:                                               ; preds = %43, %41, %24
  call void @llvm.lifetime.end.p0(i64 216, ptr %4) #3
  %45 = load i1, ptr %2, align 1
  ret i1 %45
}

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

; 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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@__const._Z7isprimej.p = external hidden unnamed_addr constant [54 x i32], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef zeroext i1 @_Z7isprimej(i32 noundef %0) local_unnamed_addr #0 {
  br label %16

2:                                                ; preds = %16
  %3 = add nuw nsw i64 %.01216, 1
  %4 = getelementptr inbounds [54 x i32], ptr @__const._Z7isprimej.p, i64 0, i64 %3
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = urem i32 %0, %5
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %.loopexit, label %8

8:                                                ; preds = %2
  %9 = add nuw nsw i64 %.01216, 2
  %10 = getelementptr inbounds [54 x i32], ptr @__const._Z7isprimej.p, i64 0, i64 %9
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = urem i32 %0, %11
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %.loopexit, label %14

14:                                               ; preds = %8
  %15 = add nuw nsw i64 %.01216, 3
  %exitcond.2 = icmp eq i64 %15, 54
  br i1 %exitcond.2, label %.critedge.preheader, label %16, !llvm.loop !9

16:                                               ; preds = %14, %1
  %.01216 = phi i64 [ 0, %1 ], [ %15, %14 ]
  %17 = getelementptr inbounds [54 x i32], ptr @__const._Z7isprimej.p, i64 0, i64 %.01216
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = urem i32 %0, %18
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %.loopexit, label %2

.critedge.preheader:                              ; preds = %14, %.critedge.preheader
  %.017 = phi i32 [ %22, %.critedge.preheader ], [ 257, %14 ]
  %21 = urem i32 %0, %.017
  %.not = icmp ne i32 %21, 0
  %22 = add nuw nsw i32 %.017, 2
  %23 = icmp ult i32 %.017, 65534
  %or.cond.not = and i1 %23, %.not
  br i1 %or.cond.not, label %.critedge.preheader, label %.loopexit, !llvm.loop !11

.loopexit:                                        ; preds = %16, %2, %8, %.critedge.preheader
  %.2 = phi i1 [ %.not, %.critedge.preheader ], [ false, %8 ], [ false, %2 ], [ false, %16 ]
  ret i1 %.2
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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