; LLVM IR from openssl/openssl :: crypto/des (set_key)

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

@weak_keys = external hidden constant [16 x [8 x i8]], 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 @DES_is_weak_key(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %21, %1
  %7 = load i32, ptr %3, align 4, !tbaa !9
  %8 = zext i32 %7 to i64
  %9 = icmp ult i64 %8, 16
  br i1 %9, label %10, label %24

10:                                               ; preds = %6
  %11 = load i32, ptr %3, align 4, !tbaa !9
  %12 = zext i32 %11 to i64
  %13 = getelementptr inbounds [16 x [8 x i8]], ptr @weak_keys, i64 0, i64 %12
  %14 = getelementptr inbounds [8 x i8], ptr %13, i64 0, i64 0
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = call i32 @CRYPTO_memcmp(ptr noundef %14, ptr noundef %15, i64 noundef 8)
  store i32 %16, ptr %5, align 4, !tbaa !9
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = call i32 @constant_time_is_zero(i32 noundef %17)
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = or i32 %19, %18
  store i32 %20, ptr %4, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %10
  %22 = load i32, ptr %3, align 4, !tbaa !9
  %23 = add i32 %22, 1
  store i32 %23, ptr %3, align 4, !tbaa !9
  br label %6, !llvm.loop !11

24:                                               ; preds = %6
  %25 = load i32, ptr %4, align 4, !tbaa !9
  %26 = and i32 %25, 1
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret i32 %26
}

declare i32 @CRYPTO_memcmp(ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @constant_time_is_zero(i32 noundef) #3

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 = { "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 = { 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 #4 = { 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 = distinct !{!11, !12}
!12 = !{!"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"

@weak_keys = external hidden constant [16 x [8 x i8]], align 16

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @DES_is_weak_key(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull @weak_keys, ptr noundef %0, i64 noundef 8) #3
  %3 = tail call i32 @constant_time_is_zero(i32 noundef %2)
  %4 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @weak_keys, i64 8), ptr noundef %0, i64 noundef 8) #3
  %5 = tail call i32 @constant_time_is_zero(i32 noundef %4)
  %6 = or i32 %5, %3
  %7 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @weak_keys, i64 16), ptr noundef %0, i64 noundef 8) #3
  %8 = tail call i32 @constant_time_is_zero(i32 noundef %7)
  %9 = or i32 %8, %6
  %10 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @weak_keys, i64 24), ptr noundef %0, i64 noundef 8) #3
  %11 = tail call i32 @constant_time_is_zero(i32 noundef %10)
  %12 = or i32 %11, %9
  %13 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @weak_keys, i64 32), ptr noundef %0, i64 noundef 8) #3
  %14 = tail call i32 @constant_time_is_zero(i32 noundef %13)
  %15 = or i32 %14, %12
  %16 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @weak_keys, i64 40), ptr noundef %0, i64 noundef 8) #3
  %17 = tail call i32 @constant_time_is_zero(i32 noundef %16)
  %18 = or i32 %17, %15
  %19 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @weak_keys, i64 48), ptr noundef %0, i64 noundef 8) #3
  %20 = tail call i32 @constant_time_is_zero(i32 noundef %19)
  %21 = or i32 %20, %18
  %22 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @weak_keys, i64 56), ptr noundef %0, i64 noundef 8) #3
  %23 = tail call i32 @constant_time_is_zero(i32 noundef %22)
  %24 = or i32 %23, %21
  %25 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @weak_keys, i64 64), ptr noundef %0, i64 noundef 8) #3
  %26 = tail call i32 @constant_time_is_zero(i32 noundef %25)
  %27 = or i32 %26, %24
  %28 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @weak_keys, i64 72), ptr noundef %0, i64 noundef 8) #3
  %29 = tail call i32 @constant_time_is_zero(i32 noundef %28)
  %30 = or i32 %29, %27
  %31 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @weak_keys, i64 80), ptr noundef %0, i64 noundef 8) #3
  %32 = tail call i32 @constant_time_is_zero(i32 noundef %31)
  %33 = or i32 %32, %30
  %34 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @weak_keys, i64 88), ptr noundef %0, i64 noundef 8) #3
  %35 = tail call i32 @constant_time_is_zero(i32 noundef %34)
  %36 = or i32 %35, %33
  %37 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @weak_keys, i64 96), ptr noundef %0, i64 noundef 8) #3
  %38 = tail call i32 @constant_time_is_zero(i32 noundef %37)
  %39 = or i32 %38, %36
  %40 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @weak_keys, i64 104), ptr noundef %0, i64 noundef 8) #3
  %41 = tail call i32 @constant_time_is_zero(i32 noundef %40)
  %42 = or i32 %41, %39
  %43 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @weak_keys, i64 112), ptr noundef %0, i64 noundef 8) #3
  %44 = tail call i32 @constant_time_is_zero(i32 noundef %43)
  %45 = or i32 %44, %42
  %46 = tail call i32 @CRYPTO_memcmp(ptr noundef nonnull getelementptr inbounds (i8, ptr @weak_keys, i64 120), ptr noundef %0, i64 noundef 8) #3
  %47 = tail call i32 @constant_time_is_zero(i32 noundef %46)
  %48 = or i32 %47, %45
  %49 = and i32 %48, 1
  ret i32 %49
}

declare i32 @CRYPTO_memcmp(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @constant_time_is_zero(i32 noundef) local_unnamed_addr #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 = { "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" }
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)"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass