; LLVM IR from cryspen/libcrux :: sys/hacl/c/src (Hacl_RSAPSS)

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

@.str = external hidden unnamed_addr constant [70 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [78 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

declare i32 @printf(ptr noundef, ...) #1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @Hacl_RSAPSS_rsapss_verify(i8 noundef zeroext, i32 noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef) #5

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @Hacl_RSAPSS_rsapss_pkey_verify(i8 noundef zeroext %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6, ptr noundef %7, i32 noundef %8, ptr noundef %9) #5 {
  %11 = alloca i1, align 1
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca i64, align 8
  %24 = alloca i8, align 1
  %25 = alloca i32, align 4
  store i8 %0, ptr %12, align 1, !tbaa !5
  store i32 %1, ptr %13, align 4, !tbaa !8
  store i32 %2, ptr %14, align 4, !tbaa !8
  store ptr %3, ptr %15, align 8, !tbaa !10
  store ptr %4, ptr %16, align 8, !tbaa !10
  store i32 %5, ptr %17, align 4, !tbaa !8
  store i32 %6, ptr %18, align 4, !tbaa !8
  store ptr %7, ptr %19, align 8, !tbaa !10
  store i32 %8, ptr %20, align 4, !tbaa !8
  store ptr %9, ptr %21, align 8, !tbaa !10
  br label %26

26:                                               ; preds = %10
  %27 = load i32, ptr %13, align 4, !tbaa !8
  %28 = sub i32 %27, 1
  %29 = udiv i32 %28, 64
  %30 = add i32 %29, 1
  %31 = mul i32 2, %30
  %32 = load i32, ptr %14, align 4, !tbaa !8
  %33 = sub i32 %32, 1
  %34 = udiv i32 %33, 64
  %35 = add i32 %31, %34
  %36 = add i32 %35, 1
  %37 = zext i32 %36 to i64
  %38 = icmp ugt i64 %37, 2305843009213693951
  br i1 %38, label %39, label %41

39:                                               ; preds = %26
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 863)
  call void @exit(i32 noundef 253) #7
  unreachable

41:                                               ; preds = %26
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %13, align 4, !tbaa !8
  %44 = sub i32 %43, 1
  %45 = udiv i32 %44, 64
  %46 = add i32 %45, 1
  %47 = mul i32 2, %46
  %48 = load i32, ptr %14, align 4, !tbaa !8
  %49 = sub i32 %48, 1
  %50 = udiv i32 %49, 64
  %51 = add i32 %47, %50
  %52 = add i32 %51, 1
  %53 = zext i32 %52 to i64
  %54 = call ptr @llvm.stacksave.p0()
  store ptr %54, ptr %22, align 8
  %55 = alloca i64, i64 %53, align 16
  store i64 %53, ptr %23, align 8
  %56 = load i32, ptr %13, align 4, !tbaa !8
  %57 = sub i32 %56, 1
  %58 = udiv i32 %57, 64
  %59 = add i32 %58, 1
  %60 = mul i32 2, %59
  %61 = load i32, ptr %14, align 4, !tbaa !8
  %62 = sub i32 %61, 1
  %63 = udiv i32 %62, 64
  %64 = add i32 %60, %63
  %65 = add i32 %64, 1
  %66 = zext i32 %65 to i64
  %67 = mul i64 %66, 8
  call void @llvm.memset.p0.i64(ptr align 16 %55, i8 0, i64 %67, i1 false)
  call void @llvm.lifetime.start.p0(i64 1, ptr %24) #8
  %68 = load i32, ptr %13, align 4, !tbaa !8
  %69 = load i32, ptr %14, align 4, !tbaa !8
  %70 = load ptr, ptr %15, align 8, !tbaa !10
  %71 = load ptr, ptr %16, align 8, !tbaa !10
  %72 = call zeroext i1 @load_pkey(i32 noundef %68, i32 noundef %69, ptr noundef %70, ptr noundef %71, ptr noundef %55)
  %73 = zext i1 %72 to i8
  store i8 %73, ptr %24, align 1, !tbaa !12
  %74 = load i8, ptr %24, align 1, !tbaa !12, !range !14, !noundef !15
  %75 = trunc i8 %74 to i1
  br i1 %75, label %76, label %86

76:                                               ; preds = %42
  %77 = load i8, ptr %12, align 1, !tbaa !5
  %78 = load i32, ptr %13, align 4, !tbaa !8
  %79 = load i32, ptr %14, align 4, !tbaa !8
  %80 = load i32, ptr %17, align 4, !tbaa !8
  %81 = load i32, ptr %18, align 4, !tbaa !8
  %82 = load ptr, ptr %19, align 8, !tbaa !10
  %83 = load i32, ptr %20, align 4, !tbaa !8
  %84 = load ptr, ptr %21, align 8, !tbaa !10
  %85 = call zeroext i1 @Hacl_RSAPSS_rsapss_verify(i8 noundef zeroext %77, i32 noundef %78, i32 noundef %79, ptr noundef %55, i32 noundef %80, i32 noundef %81, ptr noundef %82, i32 noundef %83, ptr noundef %84)
  store i1 %85, ptr %11, align 1
  store i32 1, ptr %25, align 4
  br label %87

86:                                               ; preds = %42
  store i1 false, ptr %11, align 1
  store i32 1, ptr %25, align 4
  br label %87

87:                                               ; preds = %86, %76
  call void @llvm.lifetime.end.p0(i64 1, ptr %24) #8
  %88 = load ptr, ptr %22, align 8
  call void @llvm.stackrestore.p0(ptr %88)
  %89 = load i1, ptr %11, align 1
  ret i1 %89
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @load_pkey(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { nocallback nofree nosync nounwind willreturn }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 #6 = { 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 #7 = { noreturn nounwind }
attributes #8 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"_Bool", !6, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}


; 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: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @Hacl_RSAPSS_rsapss_verify(i8 noundef zeroext, i32 noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @Hacl_RSAPSS_rsapss_pkey_verify(i8 noundef zeroext %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6, ptr noundef %7, i32 noundef %8, ptr noundef %9) local_unnamed_addr #1 {
  %11 = add i32 %1, -1
  %12 = lshr i32 %11, 5
  %13 = and i32 %12, 134217726
  %14 = add i32 %2, -1
  %15 = lshr i32 %14, 6
  %16 = add nuw nsw i32 %13, 3
  %17 = add nuw nsw i32 %16, %15
  %18 = zext nneg i32 %17 to i64
  %19 = alloca i64, i64 %18, align 16
  %20 = shl nuw nsw i64 %18, 3
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) %19, i8 0, i64 %20, i1 false)
  %21 = call zeroext i1 @load_pkey(i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef nonnull %19)
  br i1 %21, label %22, label %24

22:                                               ; preds = %10
  %23 = call zeroext i1 @Hacl_RSAPSS_rsapss_verify(i8 noundef zeroext %0, i32 noundef %1, i32 noundef %2, ptr noundef nonnull %19, i32 noundef %5, i32 noundef %6, ptr noundef %7, i32 noundef %8, ptr noundef %9)
  br label %24

24:                                               ; preds = %10, %22
  %.0 = phi i1 [ %23, %22 ], [ false, %10 ]
  ret i1 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @load_pkey(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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" }

!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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass