; LLVM IR from ARMmbed/mbed-crypto :: library (des)

; 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_key_table = 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 @mbedtls_des_key_check_weak(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %19, %1
  %7 = load i32, ptr %4, align 4, !tbaa !9
  %8 = icmp slt i32 %7, 16
  br i1 %8, label %9, label %22

9:                                                ; preds = %6
  %10 = load i32, ptr %4, align 4, !tbaa !9
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [16 x [8 x i8]], ptr @weak_key_table, i64 0, i64 %11
  %13 = getelementptr inbounds [8 x i8], ptr %12, i64 0, i64 0
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = call i32 @memcmp(ptr noundef %13, ptr noundef %14, i64 noundef 8) #4
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %9
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %23

18:                                               ; preds = %9
  br label %19

19:                                               ; preds = %18
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %4, align 4, !tbaa !9
  br label %6, !llvm.loop !11

22:                                               ; preds = %6
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %23

23:                                               ; preds = %22, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %24 = load i32, ptr %2, align 4
  ret i32 %24
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #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 = { 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 #3 = { nounwind }
attributes #4 = { 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/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_key_table = external hidden constant [16 x [8 x i8]], align 16

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read) uwtable
define dso_local range(i32 0, 2) i32 @mbedtls_des_key_check_weak(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %bcmp = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) @weak_key_table, ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %2 = icmp eq i32 %bcmp, 0
  br i1 %2, label %33, label %3

3:                                                ; preds = %1
  %bcmp.1 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) getelementptr inbounds (i8, ptr @weak_key_table, i64 8), ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %4 = icmp eq i32 %bcmp.1, 0
  br i1 %4, label %33, label %5

5:                                                ; preds = %3
  %bcmp.2 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) getelementptr inbounds (i8, ptr @weak_key_table, i64 16), ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %6 = icmp eq i32 %bcmp.2, 0
  br i1 %6, label %33, label %7

7:                                                ; preds = %5
  %bcmp.3 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) getelementptr inbounds (i8, ptr @weak_key_table, i64 24), ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %8 = icmp eq i32 %bcmp.3, 0
  br i1 %8, label %33, label %9

9:                                                ; preds = %7
  %bcmp.4 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) getelementptr inbounds (i8, ptr @weak_key_table, i64 32), ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %10 = icmp eq i32 %bcmp.4, 0
  br i1 %10, label %33, label %11

11:                                               ; preds = %9
  %bcmp.5 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) getelementptr inbounds (i8, ptr @weak_key_table, i64 40), ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %12 = icmp eq i32 %bcmp.5, 0
  br i1 %12, label %33, label %13

13:                                               ; preds = %11
  %bcmp.6 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) getelementptr inbounds (i8, ptr @weak_key_table, i64 48), ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %14 = icmp eq i32 %bcmp.6, 0
  br i1 %14, label %33, label %15

15:                                               ; preds = %13
  %bcmp.7 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) getelementptr inbounds (i8, ptr @weak_key_table, i64 56), ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %16 = icmp eq i32 %bcmp.7, 0
  br i1 %16, label %33, label %17

17:                                               ; preds = %15
  %bcmp.8 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) getelementptr inbounds (i8, ptr @weak_key_table, i64 64), ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %18 = icmp eq i32 %bcmp.8, 0
  br i1 %18, label %33, label %19

19:                                               ; preds = %17
  %bcmp.9 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) getelementptr inbounds (i8, ptr @weak_key_table, i64 72), ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %20 = icmp eq i32 %bcmp.9, 0
  br i1 %20, label %33, label %21

21:                                               ; preds = %19
  %bcmp.10 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) getelementptr inbounds (i8, ptr @weak_key_table, i64 80), ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %22 = icmp eq i32 %bcmp.10, 0
  br i1 %22, label %33, label %23

23:                                               ; preds = %21
  %bcmp.11 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) getelementptr inbounds (i8, ptr @weak_key_table, i64 88), ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %24 = icmp eq i32 %bcmp.11, 0
  br i1 %24, label %33, label %25

25:                                               ; preds = %23
  %bcmp.12 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) getelementptr inbounds (i8, ptr @weak_key_table, i64 96), ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %26 = icmp eq i32 %bcmp.12, 0
  br i1 %26, label %33, label %27

27:                                               ; preds = %25
  %bcmp.13 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) getelementptr inbounds (i8, ptr @weak_key_table, i64 104), ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %28 = icmp eq i32 %bcmp.13, 0
  br i1 %28, label %33, label %29

29:                                               ; preds = %27
  %bcmp.14 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) getelementptr inbounds (i8, ptr @weak_key_table, i64 112), ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %30 = icmp eq i32 %bcmp.14, 0
  br i1 %30, label %33, label %31

31:                                               ; preds = %29
  %bcmp.15 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(8) getelementptr inbounds (i8, ptr @weak_key_table, i64 120), ptr noundef nonnull dereferenceable(8) %0, i64 8)
  %32 = icmp eq i32 %bcmp.15, 0
  %spec.select = zext i1 %32 to i32
  br label %33

33:                                               ; preds = %31, %29, %27, %25, %23, %21, %19, %17, %15, %13, %11, %9, %7, %5, %3, %1
  %.04 = phi i32 [ 1, %1 ], [ 1, %3 ], [ 1, %5 ], [ 1, %7 ], [ 1, %9 ], [ 1, %11 ], [ 1, %13 ], [ 1, %15 ], [ 1, %17 ], [ 1, %19 ], [ 1, %21 ], [ 1, %23 ], [ 1, %25 ], [ 1, %27 ], [ 1, %29 ], [ %spec.select, %31 ]
  ret i32 %.04
}

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #1

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


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