; LLVM IR from CactiLab/Sherloc-Cortex-M-CFVD :: Sherloc_runtime/evaluation/src/nettle_arcfour (arcfour)

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

@result = external hidden global [16 x i8], align 16
@__const.verify_benchmark_arcfour.exp = external hidden unnamed_addr constant [16 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: nounwind uwtable
define dso_local i32 @verify_benchmark_arcfour(i32 noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca [16 x i32], align 16
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %4) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %4, ptr align 16 @__const.verify_benchmark_arcfour.exp, i64 64, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %23, %1
  %8 = load i32, ptr %5, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 16
  br i1 %9, label %10, label %26

10:                                               ; preds = %7
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [16 x i8], ptr @result, i64 0, i64 %12
  %14 = load i8, ptr %13, align 1, !tbaa !9
  %15 = zext i8 %14 to i32
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [16 x i32], ptr %4, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = icmp ne i32 %15, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %10
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %27

22:                                               ; preds = %10
  br label %23

23:                                               ; preds = %22
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %5, align 4, !tbaa !5
  br label %7, !llvm.loop !10

26:                                               ; preds = %7
  store i32 1, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %27

27:                                               ; preds = %26, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 64, ptr %4) #3
  %28 = load i32, ptr %2, align 4
  ret i32 %28
}

; 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"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"

@result = external hidden local_unnamed_addr global [16 x i8], align 16
@__const.verify_benchmark_arcfour.exp = external hidden unnamed_addr constant [16 x i32], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local range(i32 0, 2) i32 @verify_benchmark_arcfour(i32 noundef %0) local_unnamed_addr #0 {
  %2 = load i8, ptr @result, align 16, !tbaa !5
  %3 = zext i8 %2 to i32
  %4 = load i32, ptr @__const.verify_benchmark_arcfour.exp, align 16, !tbaa !8
  %.not = icmp eq i32 %4, %3
  br i1 %.not, label %5, label %65

5:                                                ; preds = %1
  %6 = load i8, ptr getelementptr inbounds (i8, ptr @result, i64 1), align 1, !tbaa !5
  %7 = zext i8 %6 to i32
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @__const.verify_benchmark_arcfour.exp, i64 4), align 4, !tbaa !8
  %.not.1 = icmp eq i32 %8, %7
  br i1 %.not.1, label %9, label %65

9:                                                ; preds = %5
  %10 = load i8, ptr getelementptr inbounds (i8, ptr @result, i64 2), align 2, !tbaa !5
  %11 = zext i8 %10 to i32
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @__const.verify_benchmark_arcfour.exp, i64 8), align 8, !tbaa !8
  %.not.2 = icmp eq i32 %12, %11
  br i1 %.not.2, label %13, label %65

13:                                               ; preds = %9
  %14 = load i8, ptr getelementptr inbounds (i8, ptr @result, i64 3), align 1, !tbaa !5
  %15 = zext i8 %14 to i32
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @__const.verify_benchmark_arcfour.exp, i64 12), align 4, !tbaa !8
  %.not.3 = icmp eq i32 %16, %15
  br i1 %.not.3, label %17, label %65

17:                                               ; preds = %13
  %18 = load i8, ptr getelementptr inbounds (i8, ptr @result, i64 4), align 4, !tbaa !5
  %19 = zext i8 %18 to i32
  %20 = load i32, ptr getelementptr inbounds (i8, ptr @__const.verify_benchmark_arcfour.exp, i64 16), align 16, !tbaa !8
  %.not.4 = icmp eq i32 %20, %19
  br i1 %.not.4, label %21, label %65

21:                                               ; preds = %17
  %22 = load i8, ptr getelementptr inbounds (i8, ptr @result, i64 5), align 1, !tbaa !5
  %23 = zext i8 %22 to i32
  %24 = load i32, ptr getelementptr inbounds (i8, ptr @__const.verify_benchmark_arcfour.exp, i64 20), align 4, !tbaa !8
  %.not.5 = icmp eq i32 %24, %23
  br i1 %.not.5, label %25, label %65

25:                                               ; preds = %21
  %26 = load i8, ptr getelementptr inbounds (i8, ptr @result, i64 6), align 2, !tbaa !5
  %27 = zext i8 %26 to i32
  %28 = load i32, ptr getelementptr inbounds (i8, ptr @__const.verify_benchmark_arcfour.exp, i64 24), align 8, !tbaa !8
  %.not.6 = icmp eq i32 %28, %27
  br i1 %.not.6, label %29, label %65

29:                                               ; preds = %25
  %30 = load i8, ptr getelementptr inbounds (i8, ptr @result, i64 7), align 1, !tbaa !5
  %31 = zext i8 %30 to i32
  %32 = load i32, ptr getelementptr inbounds (i8, ptr @__const.verify_benchmark_arcfour.exp, i64 28), align 4, !tbaa !8
  %.not.7 = icmp eq i32 %32, %31
  br i1 %.not.7, label %33, label %65

33:                                               ; preds = %29
  %34 = load i8, ptr getelementptr inbounds (i8, ptr @result, i64 8), align 8, !tbaa !5
  %35 = zext i8 %34 to i32
  %36 = load i32, ptr getelementptr inbounds (i8, ptr @__const.verify_benchmark_arcfour.exp, i64 32), align 16, !tbaa !8
  %.not.8 = icmp eq i32 %36, %35
  br i1 %.not.8, label %37, label %65

37:                                               ; preds = %33
  %38 = load i8, ptr getelementptr inbounds (i8, ptr @result, i64 9), align 1, !tbaa !5
  %39 = zext i8 %38 to i32
  %40 = load i32, ptr getelementptr inbounds (i8, ptr @__const.verify_benchmark_arcfour.exp, i64 36), align 4, !tbaa !8
  %.not.9 = icmp eq i32 %40, %39
  br i1 %.not.9, label %41, label %65

41:                                               ; preds = %37
  %42 = load i8, ptr getelementptr inbounds (i8, ptr @result, i64 10), align 2, !tbaa !5
  %43 = zext i8 %42 to i32
  %44 = load i32, ptr getelementptr inbounds (i8, ptr @__const.verify_benchmark_arcfour.exp, i64 40), align 8, !tbaa !8
  %.not.10 = icmp eq i32 %44, %43
  br i1 %.not.10, label %45, label %65

45:                                               ; preds = %41
  %46 = load i8, ptr getelementptr inbounds (i8, ptr @result, i64 11), align 1, !tbaa !5
  %47 = zext i8 %46 to i32
  %48 = load i32, ptr getelementptr inbounds (i8, ptr @__const.verify_benchmark_arcfour.exp, i64 44), align 4, !tbaa !8
  %.not.11 = icmp eq i32 %48, %47
  br i1 %.not.11, label %49, label %65

49:                                               ; preds = %45
  %50 = load i8, ptr getelementptr inbounds (i8, ptr @result, i64 12), align 4, !tbaa !5
  %51 = zext i8 %50 to i32
  %52 = load i32, ptr getelementptr inbounds (i8, ptr @__const.verify_benchmark_arcfour.exp, i64 48), align 16, !tbaa !8
  %.not.12 = icmp eq i32 %52, %51
  br i1 %.not.12, label %53, label %65

53:                                               ; preds = %49
  %54 = load i8, ptr getelementptr inbounds (i8, ptr @result, i64 13), align 1, !tbaa !5
  %55 = zext i8 %54 to i32
  %56 = load i32, ptr getelementptr inbounds (i8, ptr @__const.verify_benchmark_arcfour.exp, i64 52), align 4, !tbaa !8
  %.not.13 = icmp eq i32 %56, %55
  br i1 %.not.13, label %57, label %65

57:                                               ; preds = %53
  %58 = load i8, ptr getelementptr inbounds (i8, ptr @result, i64 14), align 2, !tbaa !5
  %59 = zext i8 %58 to i32
  %60 = load i32, ptr getelementptr inbounds (i8, ptr @__const.verify_benchmark_arcfour.exp, i64 56), align 8, !tbaa !8
  %.not.14 = icmp eq i32 %60, %59
  br i1 %.not.14, label %61, label %65

61:                                               ; preds = %57
  %62 = load i8, ptr getelementptr inbounds (i8, ptr @result, i64 15), align 1, !tbaa !5
  %63 = zext i8 %62 to i32
  %64 = load i32, ptr getelementptr inbounds (i8, ptr @__const.verify_benchmark_arcfour.exp, i64 60), align 4, !tbaa !8
  %.not.15 = icmp eq i32 %64, %63
  %spec.select = zext i1 %.not.15 to i32
  br label %65

65:                                               ; preds = %61, %57, %53, %49, %45, %41, %37, %33, %29, %25, %21, %17, %13, %9, %5, %1
  %.05 = phi i32 [ 0, %1 ], [ 0, %5 ], [ 0, %9 ], [ 0, %13 ], [ 0, %17 ], [ 0, %21 ], [ 0, %25 ], [ 0, %29 ], [ 0, %33 ], [ 0, %37 ], [ 0, %41 ], [ 0, %45 ], [ 0, %49 ], [ 0, %53 ], [ 0, %57 ], [ %spec.select, %61 ]
  ret i32 %.05
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass