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

; 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: nounwind uwtable
define dso_local void @yd_aes_ofb_enc_dec_crypto(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) #0 {
  %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 = %61, %29
  %31 = load i32, ptr %10, align 4, !tbaa !9
  %32 = icmp ugt i32 %31, 0
  br i1 %32, label %33, label %68

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 = %58, %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 %61

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

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

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

68:                                               ; 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
}

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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}
!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: nounwind uwtable
define dso_local void @yd_aes_ofb_enc_dec_crypto(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, ptr noundef %2, ptr nocapture noundef readonly %3, i32 noundef %4) local_unnamed_addr #0 {
.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
  %.not21 = icmp eq i32 %4, 0
  br i1 %.not21, 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
  %.01624 = phi i32 [ %101, %.lr.ph ], [ %4, %.lr.ph.preheader ]
  %.01723 = phi ptr [ %99, %.lr.ph ], [ %0, %.lr.ph.preheader ]
  %.01822 = 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 %5, align 16, !tbaa !5
  %22 = load i8, ptr %.01723, align 1, !tbaa !5
  %23 = xor i8 %22, %21
  store i8 %23, ptr %.01822, align 1, !tbaa !5
  %24 = load i8, ptr %6, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %.01723, i64 1
  %26 = load i8, ptr %25, align 1, !tbaa !5
  %27 = xor i8 %26, %24
  %28 = getelementptr inbounds i8, ptr %.01822, i64 1
  store i8 %27, ptr %28, align 1, !tbaa !5
  %29 = load i8, ptr %7, align 2, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %.01723, i64 2
  %31 = load i8, ptr %30, align 1, !tbaa !5
  %32 = xor i8 %31, %29
  %33 = getelementptr inbounds i8, ptr %.01822, i64 2
  store i8 %32, ptr %33, align 1, !tbaa !5
  %34 = load i8, ptr %8, align 1, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %.01723, i64 3
  %36 = load i8, ptr %35, align 1, !tbaa !5
  %37 = xor i8 %36, %34
  %38 = getelementptr inbounds i8, ptr %.01822, i64 3
  store i8 %37, ptr %38, align 1, !tbaa !5
  %39 = load i8, ptr %9, align 4, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %.01723, i64 4
  %41 = load i8, ptr %40, align 1, !tbaa !5
  %42 = xor i8 %41, %39
  %43 = getelementptr inbounds i8, ptr %.01822, i64 4
  store i8 %42, ptr %43, align 1, !tbaa !5
  %44 = load i8, ptr %10, align 1, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %.01723, i64 5
  %46 = load i8, ptr %45, align 1, !tbaa !5
  %47 = xor i8 %46, %44
  %48 = getelementptr inbounds i8, ptr %.01822, i64 5
  store i8 %47, ptr %48, align 1, !tbaa !5
  %49 = load i8, ptr %11, align 2, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %.01723, i64 6
  %51 = load i8, ptr %50, align 1, !tbaa !5
  %52 = xor i8 %51, %49
  %53 = getelementptr inbounds i8, ptr %.01822, i64 6
  store i8 %52, ptr %53, align 1, !tbaa !5
  %54 = load i8, ptr %12, align 1, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %.01723, i64 7
  %56 = load i8, ptr %55, align 1, !tbaa !5
  %57 = xor i8 %56, %54
  %58 = getelementptr inbounds i8, ptr %.01822, i64 7
  store i8 %57, ptr %58, align 1, !tbaa !5
  %59 = load i8, ptr %13, align 8, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %.01723, i64 8
  %61 = load i8, ptr %60, align 1, !tbaa !5
  %62 = xor i8 %61, %59
  %63 = getelementptr inbounds i8, ptr %.01822, i64 8
  store i8 %62, ptr %63, align 1, !tbaa !5
  %64 = load i8, ptr %14, align 1, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %.01723, i64 9
  %66 = load i8, ptr %65, align 1, !tbaa !5
  %67 = xor i8 %66, %64
  %68 = getelementptr inbounds i8, ptr %.01822, i64 9
  store i8 %67, ptr %68, align 1, !tbaa !5
  %69 = load i8, ptr %15, align 2, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %.01723, i64 10
  %71 = load i8, ptr %70, align 1, !tbaa !5
  %72 = xor i8 %71, %69
  %73 = getelementptr inbounds i8, ptr %.01822, i64 10
  store i8 %72, ptr %73, align 1, !tbaa !5
  %74 = load i8, ptr %16, align 1, !tbaa !5
  %75 = getelementptr inbounds i8, ptr %.01723, i64 11
  %76 = load i8, ptr %75, align 1, !tbaa !5
  %77 = xor i8 %76, %74
  %78 = getelementptr inbounds i8, ptr %.01822, i64 11
  store i8 %77, ptr %78, align 1, !tbaa !5
  %79 = load i8, ptr %17, align 4, !tbaa !5
  %80 = getelementptr inbounds i8, ptr %.01723, i64 12
  %81 = load i8, ptr %80, align 1, !tbaa !5
  %82 = xor i8 %81, %79
  %83 = getelementptr inbounds i8, ptr %.01822, i64 12
  store i8 %82, ptr %83, align 1, !tbaa !5
  %84 = load i8, ptr %18, align 1, !tbaa !5
  %85 = getelementptr inbounds i8, ptr %.01723, i64 13
  %86 = load i8, ptr %85, align 1, !tbaa !5
  %87 = xor i8 %86, %84
  %88 = getelementptr inbounds i8, ptr %.01822, i64 13
  store i8 %87, ptr %88, align 1, !tbaa !5
  %89 = load i8, ptr %19, align 2, !tbaa !5
  %90 = getelementptr inbounds i8, ptr %.01723, i64 14
  %91 = load i8, ptr %90, align 1, !tbaa !5
  %92 = xor i8 %91, %89
  %93 = getelementptr inbounds i8, ptr %.01822, i64 14
  store i8 %92, ptr %93, align 1, !tbaa !5
  %94 = load i8, ptr %20, align 1, !tbaa !5
  %95 = getelementptr inbounds i8, ptr %.01723, i64 15
  %96 = load i8, ptr %95, align 1, !tbaa !5
  %97 = xor i8 %96, %94
  %98 = getelementptr inbounds i8, ptr %.01822, i64 15
  store i8 %97, ptr %98, align 1, !tbaa !5
  %99 = getelementptr inbounds i8, ptr %.01723, i64 16
  %100 = getelementptr inbounds i8, ptr %.01822, i64 16
  %101 = add i32 %.01624, -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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

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

; 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 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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,ReassociatePass,SROAPass,SimplifyCFGPass