; LLVM IR from china-hai/yd_crypto :: src/aes (yd_aes_ecb)

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

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

10:                                               ; preds = %31, %4
  %11 = load i32, ptr %8, align 4, !tbaa !9
  %12 = icmp ugt i32 %11, 0
  br i1 %12, label %13, label %40

13:                                               ; preds = %10
  store i8 0, ptr %9, align 1, !tbaa !11
  br label %14

14:                                               ; preds = %28, %13
  %15 = load i8, ptr %9, align 1, !tbaa !11
  %16 = zext i8 %15 to i32
  %17 = icmp slt i32 %16, 16
  br i1 %17, label %18, label %31

18:                                               ; preds = %14
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = load i8, ptr %9, align 1, !tbaa !11
  %21 = zext i8 %20 to i64
  %22 = getelementptr inbounds i8, ptr %19, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !11
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = load i8, ptr %9, align 1, !tbaa !11
  %26 = zext i8 %25 to i64
  %27 = getelementptr inbounds i8, ptr %24, i64 %26
  store i8 %23, ptr %27, align 1, !tbaa !11
  br label %28

28:                                               ; preds = %18
  %29 = load i8, ptr %9, align 1, !tbaa !11
  %30 = add i8 %29, 1
  store i8 %30, ptr %9, align 1, !tbaa !11
  br label %14, !llvm.loop !12

31:                                               ; preds = %14
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  call void @yd_aes_decrypt(ptr noundef %32, ptr noundef %33)
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i64 16
  store ptr %35, ptr %5, align 8, !tbaa !5
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %36, i64 16
  store ptr %37, ptr %6, align 8, !tbaa !5
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = add i32 %38, -1
  store i32 %39, ptr %8, align 4, !tbaa !9
  br label %10, !llvm.loop !14

40:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  ret void
}

declare void @yd_aes_decrypt(ptr noundef, ptr 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 = { "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)"}
!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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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: nounwind uwtable
define dso_local void @yd_aes_ecb_decrypt(ptr nocapture noundef readonly %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %.not15 = icmp eq i32 %3, 0
  br i1 %.not15, label %._crit_edge, label %.preheader

.preheader:                                       ; preds = %4, %.preheader
  %.01118 = phi i32 [ %53, %.preheader ], [ %3, %4 ]
  %.01217 = phi ptr [ %51, %.preheader ], [ %0, %4 ]
  %.01316 = phi ptr [ %52, %.preheader ], [ %1, %4 ]
  %5 = load i8, ptr %.01217, align 1, !tbaa !5
  store i8 %5, ptr %.01316, align 1, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %.01217, i64 1
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %.01316, i64 1
  store i8 %7, ptr %8, align 1, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %.01217, i64 2
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %.01316, i64 2
  store i8 %10, ptr %11, align 1, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %.01217, i64 3
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %.01316, i64 3
  store i8 %13, ptr %14, align 1, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %.01217, i64 4
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %.01316, i64 4
  store i8 %16, ptr %17, align 1, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %.01217, i64 5
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %.01316, i64 5
  store i8 %19, ptr %20, align 1, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %.01217, i64 6
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %.01316, i64 6
  store i8 %22, ptr %23, align 1, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %.01217, i64 7
  %25 = load i8, ptr %24, align 1, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %.01316, i64 7
  store i8 %25, ptr %26, align 1, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %.01217, i64 8
  %28 = load i8, ptr %27, align 1, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %.01316, i64 8
  store i8 %28, ptr %29, align 1, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %.01217, i64 9
  %31 = load i8, ptr %30, align 1, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %.01316, i64 9
  store i8 %31, ptr %32, align 1, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %.01217, i64 10
  %34 = load i8, ptr %33, align 1, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %.01316, i64 10
  store i8 %34, ptr %35, align 1, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %.01217, i64 11
  %37 = load i8, ptr %36, align 1, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %.01316, i64 11
  store i8 %37, ptr %38, align 1, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %.01217, i64 12
  %40 = load i8, ptr %39, align 1, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %.01316, i64 12
  store i8 %40, ptr %41, align 1, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %.01217, i64 13
  %43 = load i8, ptr %42, align 1, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %.01316, i64 13
  store i8 %43, ptr %44, align 1, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %.01217, i64 14
  %46 = load i8, ptr %45, align 1, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %.01316, i64 14
  store i8 %46, ptr %47, align 1, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %.01217, i64 15
  %49 = load i8, ptr %48, align 1, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %.01316, i64 15
  store i8 %49, ptr %50, align 1, !tbaa !5
  tail call void @yd_aes_decrypt(ptr noundef nonnull %.01316, ptr noundef %2) #2
  %51 = getelementptr inbounds i8, ptr %.01217, i64 16
  %52 = getelementptr inbounds i8, ptr %.01316, i64 16
  %53 = add i32 %.01118, -1
  %.not = icmp eq i32 %53, 0
  br i1 %.not, label %._crit_edge, label %.preheader, !llvm.loop !8

._crit_edge:                                      ; preds = %.preheader, %4
  ret void
}

declare void @yd_aes_decrypt(ptr noundef, ptr noundef) local_unnamed_addr #1

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 = { 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 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


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