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

; 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

declare void @yd_aes_encrypt(ptr noundef, ptr noundef) #1

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

13:                                               ; preds = %26, %5
  %14 = load i8, ptr %11, align 1, !tbaa !11
  %15 = zext i8 %14 to i32
  %16 = icmp slt i32 %15, 16
  br i1 %16, label %17, label %29

17:                                               ; preds = %13
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = load i8, ptr %11, align 1, !tbaa !11
  %20 = zext i8 %19 to i64
  %21 = getelementptr inbounds i8, ptr %18, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !11
  %23 = load i8, ptr %11, align 1, !tbaa !11
  %24 = zext i8 %23 to i64
  %25 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 %24
  store i8 %22, ptr %25, align 1, !tbaa !11
  br label %26

26:                                               ; preds = %17
  %27 = load i8, ptr %11, align 1, !tbaa !11
  %28 = add i8 %27, 1
  store i8 %28, ptr %11, align 1, !tbaa !11
  br label %13, !llvm.loop !12

29:                                               ; preds = %13
  br label %30

30:                                               ; preds = %65, %29
  %31 = load i32, ptr %10, align 4, !tbaa !9
  %32 = icmp ugt i32 %31, 0
  br i1 %32, label %33, label %72

33:                                               ; preds = %30
  %34 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 0
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  call void @yd_aes_encrypt(ptr noundef %34, ptr noundef %35)
  store i8 0, ptr %11, align 1, !tbaa !11
  br label %36

36:                                               ; preds = %62, %33
  %37 = load i8, ptr %11, align 1, !tbaa !11
  %38 = zext i8 %37 to i32
  %39 = icmp slt i32 %38, 16
  br i1 %39, label %40, label %65

40:                                               ; preds = %36
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load i8, ptr %11, align 1, !tbaa !11
  %43 = zext i8 %42 to i64
  %44 = getelementptr inbounds i8, ptr %41, i64 %43
  %45 = load i8, ptr %44, align 1, !tbaa !11
  %46 = zext i8 %45 to i32
  %47 = load i8, ptr %11, align 1, !tbaa !11
  %48 = zext i8 %47 to i64
  %49 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !11
  %51 = zext i8 %50 to i32
  %52 = xor i32 %51, %46
  %53 = trunc i32 %52 to i8
  store i8 %53, ptr %49, align 1, !tbaa !11
  %54 = load i8, ptr %11, align 1, !tbaa !11
  %55 = zext i8 %54 to i64
  %56 = getelementptr inbounds [16 x i8], ptr %12, i64 0, i64 %55
  %57 = load i8, ptr %56, align 1, !tbaa !11
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load i8, ptr %11, align 1, !tbaa !11
  %60 = zext i8 %59 to i64
  %61 = getelementptr inbounds i8, ptr %58, i64 %60
  store i8 %57, ptr %61, align 1, !tbaa !11
  br label %62

62:                                               ; preds = %40
  %63 = load i8, ptr %11, align 1, !tbaa !11
  %64 = add i8 %63, 1
  store i8 %64, ptr %11, align 1, !tbaa !11
  br label %36, !llvm.loop !14

65:                                               ; preds = %36
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %66, i64 16
  store ptr %67, ptr %6, align 8, !tbaa !5
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = getelementptr inbounds i8, ptr %68, i64 16
  store ptr %69, ptr %7, align 8, !tbaa !5
  %70 = load i32, ptr %10, align 4, !tbaa !9
  %71 = add i32 %70, -1
  store i32 %71, ptr %10, align 4, !tbaa !9
  br label %30, !llvm.loop !15

72:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  ret void
}

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 = { 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)"}
!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}
!15 = distinct !{!15, !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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: mustprogress 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_cfb128_encrypt(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, ptr noundef %2, ptr nocapture noundef readonly %3, i32 noundef %4) local_unnamed_addr #2 {
.preheader:
  %5 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %5, ptr noundef nonnull align 1 dereferenceable(16) %3, i64 16, i1 false), !tbaa !5
  %.not22 = icmp eq i32 %4, 0
  br i1 %.not22, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader
  %6 = getelementptr inbounds i8, ptr %5, i64 1
  %7 = getelementptr inbounds i8, ptr %5, i64 2
  %8 = getelementptr inbounds i8, ptr %5, i64 3
  %9 = getelementptr inbounds i8, ptr %5, i64 4
  %10 = getelementptr inbounds i8, ptr %5, i64 5
  %11 = getelementptr inbounds i8, ptr %5, i64 6
  %12 = getelementptr inbounds i8, ptr %5, i64 7
  %13 = getelementptr inbounds i8, ptr %5, i64 8
  %14 = getelementptr inbounds i8, ptr %5, i64 9
  %15 = getelementptr inbounds i8, ptr %5, i64 10
  %16 = getelementptr inbounds i8, ptr %5, i64 11
  %17 = getelementptr inbounds i8, ptr %5, i64 12
  %18 = getelementptr inbounds i8, ptr %5, i64 13
  %19 = getelementptr inbounds i8, ptr %5, i64 14
  %20 = getelementptr inbounds i8, ptr %5, i64 15
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.01725 = phi i32 [ %101, %.lr.ph ], [ %4, %.lr.ph.preheader ]
  %.01824 = phi ptr [ %99, %.lr.ph ], [ %0, %.lr.ph.preheader ]
  %.01923 = phi ptr [ %100, %.lr.ph ], [ %1, %.lr.ph.preheader ]
  call void @yd_aes_encrypt(ptr noundef nonnull %5, ptr noundef %2) #4
  %21 = load i8, ptr %.01824, align 1, !tbaa !5
  %22 = load i8, ptr %5, align 16, !tbaa !5
  %23 = xor i8 %22, %21
  store i8 %23, ptr %5, align 16, !tbaa !5
  store i8 %23, ptr %.01923, align 1, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %.01824, i64 1
  %25 = load i8, ptr %24, align 1, !tbaa !5
  %26 = load i8, ptr %6, align 1, !tbaa !5
  %27 = xor i8 %26, %25
  store i8 %27, ptr %6, align 1, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %.01923, i64 1
  store i8 %27, ptr %28, align 1, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %.01824, i64 2
  %30 = load i8, ptr %29, align 1, !tbaa !5
  %31 = load i8, ptr %7, align 2, !tbaa !5
  %32 = xor i8 %31, %30
  store i8 %32, ptr %7, align 2, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %.01923, i64 2
  store i8 %32, ptr %33, align 1, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %.01824, i64 3
  %35 = load i8, ptr %34, align 1, !tbaa !5
  %36 = load i8, ptr %8, align 1, !tbaa !5
  %37 = xor i8 %36, %35
  store i8 %37, ptr %8, align 1, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %.01923, i64 3
  store i8 %37, ptr %38, align 1, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %.01824, i64 4
  %40 = load i8, ptr %39, align 1, !tbaa !5
  %41 = load i8, ptr %9, align 4, !tbaa !5
  %42 = xor i8 %41, %40
  store i8 %42, ptr %9, align 4, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %.01923, i64 4
  store i8 %42, ptr %43, align 1, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %.01824, i64 5
  %45 = load i8, ptr %44, align 1, !tbaa !5
  %46 = load i8, ptr %10, align 1, !tbaa !5
  %47 = xor i8 %46, %45
  store i8 %47, ptr %10, align 1, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %.01923, i64 5
  store i8 %47, ptr %48, align 1, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %.01824, i64 6
  %50 = load i8, ptr %49, align 1, !tbaa !5
  %51 = load i8, ptr %11, align 2, !tbaa !5
  %52 = xor i8 %51, %50
  store i8 %52, ptr %11, align 2, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %.01923, i64 6
  store i8 %52, ptr %53, align 1, !tbaa !5
  %54 = getelementptr inbounds i8, ptr %.01824, i64 7
  %55 = load i8, ptr %54, align 1, !tbaa !5
  %56 = load i8, ptr %12, align 1, !tbaa !5
  %57 = xor i8 %56, %55
  store i8 %57, ptr %12, align 1, !tbaa !5
  %58 = getelementptr inbounds i8, ptr %.01923, i64 7
  store i8 %57, ptr %58, align 1, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %.01824, i64 8
  %60 = load i8, ptr %59, align 1, !tbaa !5
  %61 = load i8, ptr %13, align 8, !tbaa !5
  %62 = xor i8 %61, %60
  store i8 %62, ptr %13, align 8, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %.01923, i64 8
  store i8 %62, ptr %63, align 1, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %.01824, i64 9
  %65 = load i8, ptr %64, align 1, !tbaa !5
  %66 = load i8, ptr %14, align 1, !tbaa !5
  %67 = xor i8 %66, %65
  store i8 %67, ptr %14, align 1, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %.01923, i64 9
  store i8 %67, ptr %68, align 1, !tbaa !5
  %69 = getelementptr inbounds i8, ptr %.01824, i64 10
  %70 = load i8, ptr %69, align 1, !tbaa !5
  %71 = load i8, ptr %15, align 2, !tbaa !5
  %72 = xor i8 %71, %70
  store i8 %72, ptr %15, align 2, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %.01923, i64 10
  store i8 %72, ptr %73, align 1, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %.01824, i64 11
  %75 = load i8, ptr %74, align 1, !tbaa !5
  %76 = load i8, ptr %16, align 1, !tbaa !5
  %77 = xor i8 %76, %75
  store i8 %77, ptr %16, align 1, !tbaa !5
  %78 = getelementptr inbounds i8, ptr %.01923, i64 11
  store i8 %77, ptr %78, align 1, !tbaa !5
  %79 = getelementptr inbounds i8, ptr %.01824, i64 12
  %80 = load i8, ptr %79, align 1, !tbaa !5
  %81 = load i8, ptr %17, align 4, !tbaa !5
  %82 = xor i8 %81, %80
  store i8 %82, ptr %17, align 4, !tbaa !5
  %83 = getelementptr inbounds i8, ptr %.01923, i64 12
  store i8 %82, ptr %83, align 1, !tbaa !5
  %84 = getelementptr inbounds i8, ptr %.01824, i64 13
  %85 = load i8, ptr %84, align 1, !tbaa !5
  %86 = load i8, ptr %18, align 1, !tbaa !5
  %87 = xor i8 %86, %85
  store i8 %87, ptr %18, align 1, !tbaa !5
  %88 = getelementptr inbounds i8, ptr %.01923, i64 13
  store i8 %87, ptr %88, align 1, !tbaa !5
  %89 = getelementptr inbounds i8, ptr %.01824, i64 14
  %90 = load i8, ptr %89, align 1, !tbaa !5
  %91 = load i8, ptr %19, align 2, !tbaa !5
  %92 = xor i8 %91, %90
  store i8 %92, ptr %19, align 2, !tbaa !5
  %93 = getelementptr inbounds i8, ptr %.01923, i64 14
  store i8 %92, ptr %93, align 1, !tbaa !5
  %94 = getelementptr inbounds i8, ptr %.01824, i64 15
  %95 = load i8, ptr %94, align 1, !tbaa !5
  %96 = load i8, ptr %20, align 1, !tbaa !5
  %97 = xor i8 %96, %95
  store i8 %97, ptr %20, align 1, !tbaa !5
  %98 = getelementptr inbounds i8, ptr %.01923, i64 15
  store i8 %97, ptr %98, align 1, !tbaa !5
  %99 = getelementptr inbounds i8, ptr %.01824, i64 16
  %100 = getelementptr inbounds i8, ptr %.01923, i64 16
  %101 = add i32 %.01725, -1
  %.not = icmp eq i32 %101, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  ret void
}

; 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) #3

attributes #0 = { mustprogress 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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass