; LLVM IR from china-hai/yd_crypto :: src/des_tdes (yd_tdes_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_des_crypto(ptr noundef, ptr noundef, i8 noundef zeroext) #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_tdes_cfb64_decrypt(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, i32 noundef %6) #2 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i8, align 1
  %16 = alloca [8 x i8], align 1
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store i32 %6, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  store i8 0, ptr %15, align 1, !tbaa !11
  br label %17

17:                                               ; preds = %30, %7
  %18 = load i8, ptr %15, align 1, !tbaa !11
  %19 = zext i8 %18 to i32
  %20 = icmp slt i32 %19, 8
  br i1 %20, label %21, label %33

21:                                               ; preds = %17
  %22 = load ptr, ptr %13, align 8, !tbaa !5
  %23 = load i8, ptr %15, align 1, !tbaa !11
  %24 = zext i8 %23 to i64
  %25 = getelementptr inbounds i8, ptr %22, i64 %24
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = load i8, ptr %15, align 1, !tbaa !11
  %28 = zext i8 %27 to i64
  %29 = getelementptr inbounds [8 x i8], ptr %16, i64 0, i64 %28
  store i8 %26, ptr %29, align 1, !tbaa !11
  br label %30

30:                                               ; preds = %21
  %31 = load i8, ptr %15, align 1, !tbaa !11
  %32 = add i8 %31, 1
  store i8 %32, ptr %15, align 1, !tbaa !11
  br label %17, !llvm.loop !12

33:                                               ; preds = %17
  br label %34

34:                                               ; preds = %77, %33
  %35 = load i32, ptr %14, align 4, !tbaa !9
  %36 = icmp ugt i32 %35, 0
  br i1 %36, label %37, label %84

37:                                               ; preds = %34
  %38 = getelementptr inbounds [8 x i8], ptr %16, i64 0, i64 0
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  call void @yd_des_crypto(ptr noundef %38, ptr noundef %39, i8 noundef zeroext 0)
  %40 = getelementptr inbounds [8 x i8], ptr %16, i64 0, i64 0
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  call void @yd_des_crypto(ptr noundef %40, ptr noundef %41, i8 noundef zeroext 1)
  %42 = getelementptr inbounds [8 x i8], ptr %16, i64 0, i64 0
  %43 = load ptr, ptr %12, align 8, !tbaa !5
  call void @yd_des_crypto(ptr noundef %42, ptr noundef %43, i8 noundef zeroext 0)
  store i8 0, ptr %15, align 1, !tbaa !11
  br label %44

44:                                               ; preds = %74, %37
  %45 = load i8, ptr %15, align 1, !tbaa !11
  %46 = zext i8 %45 to i32
  %47 = icmp slt i32 %46, 8
  br i1 %47, label %48, label %77

48:                                               ; preds = %44
  %49 = load i8, ptr %15, align 1, !tbaa !11
  %50 = zext i8 %49 to i64
  %51 = getelementptr inbounds [8 x i8], ptr %16, i64 0, i64 %50
  %52 = load i8, ptr %51, align 1, !tbaa !11
  %53 = zext i8 %52 to i32
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = load i8, ptr %15, align 1, !tbaa !11
  %56 = zext i8 %55 to i64
  %57 = getelementptr inbounds i8, ptr %54, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !11
  %59 = zext i8 %58 to i32
  %60 = xor i32 %53, %59
  %61 = trunc i32 %60 to i8
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = load i8, ptr %15, align 1, !tbaa !11
  %64 = zext i8 %63 to i64
  %65 = getelementptr inbounds i8, ptr %62, i64 %64
  store i8 %61, ptr %65, align 1, !tbaa !11
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = load i8, ptr %15, align 1, !tbaa !11
  %68 = zext i8 %67 to i64
  %69 = getelementptr inbounds i8, ptr %66, i64 %68
  %70 = load i8, ptr %69, align 1, !tbaa !11
  %71 = load i8, ptr %15, align 1, !tbaa !11
  %72 = zext i8 %71 to i64
  %73 = getelementptr inbounds [8 x i8], ptr %16, i64 0, i64 %72
  store i8 %70, ptr %73, align 1, !tbaa !11
  br label %74

74:                                               ; preds = %48
  %75 = load i8, ptr %15, align 1, !tbaa !11
  %76 = add i8 %75, 1
  store i8 %76, ptr %15, align 1, !tbaa !11
  br label %44, !llvm.loop !14

77:                                               ; preds = %44
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = getelementptr inbounds i8, ptr %78, i64 8
  store ptr %79, ptr %8, align 8, !tbaa !5
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = getelementptr inbounds i8, ptr %80, i64 8
  store ptr %81, ptr %9, align 8, !tbaa !5
  %82 = load i32, ptr %14, align 4, !tbaa !9
  %83 = add i32 %82, -1
  store i32 %83, ptr %14, align 4, !tbaa !9
  br label %34, !llvm.loop !15

84:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #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_des_crypto(ptr noundef, ptr noundef, i8 noundef zeroext) 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_tdes_cfb64_decrypt(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr nocapture noundef readonly %5, i32 noundef %6) local_unnamed_addr #2 {
.preheader:
  %7 = alloca [8 x i8], align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  %8 = load i64, ptr %5, align 1, !tbaa !5
  store i64 %8, ptr %7, align 8, !tbaa !5
  %.not26 = icmp eq i32 %6, 0
  br i1 %.not26, label %._crit_edge, label %.lr.ph.preheader

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

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.02129 = phi i32 [ %64, %.lr.ph ], [ %6, %.lr.ph.preheader ]
  %.02228 = phi ptr [ %62, %.lr.ph ], [ %0, %.lr.ph.preheader ]
  %.02327 = phi ptr [ %63, %.lr.ph ], [ %1, %.lr.ph.preheader ]
  call void @yd_des_crypto(ptr noundef nonnull %7, ptr noundef %2, i8 noundef zeroext 0) #3
  call void @yd_des_crypto(ptr noundef nonnull %7, ptr noundef %3, i8 noundef zeroext 1) #3
  call void @yd_des_crypto(ptr noundef nonnull %7, ptr noundef %4, i8 noundef zeroext 0) #3
  %16 = load i8, ptr %7, align 8, !tbaa !5
  %17 = load i8, ptr %.02228, align 1, !tbaa !5
  %18 = xor i8 %17, %16
  store i8 %18, ptr %.02327, align 1, !tbaa !5
  %19 = load i8, ptr %.02228, align 1, !tbaa !5
  store i8 %19, ptr %7, align 8, !tbaa !5
  %20 = load i8, ptr %9, align 1, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %.02228, i64 1
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %23 = xor i8 %22, %20
  %24 = getelementptr inbounds i8, ptr %.02327, i64 1
  store i8 %23, ptr %24, align 1, !tbaa !5
  %25 = load i8, ptr %21, align 1, !tbaa !5
  store i8 %25, ptr %9, align 1, !tbaa !5
  %26 = load i8, ptr %10, align 2, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %.02228, i64 2
  %28 = load i8, ptr %27, align 1, !tbaa !5
  %29 = xor i8 %28, %26
  %30 = getelementptr inbounds i8, ptr %.02327, i64 2
  store i8 %29, ptr %30, align 1, !tbaa !5
  %31 = load i8, ptr %27, align 1, !tbaa !5
  store i8 %31, ptr %10, align 2, !tbaa !5
  %32 = load i8, ptr %11, align 1, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %.02228, i64 3
  %34 = load i8, ptr %33, align 1, !tbaa !5
  %35 = xor i8 %34, %32
  %36 = getelementptr inbounds i8, ptr %.02327, i64 3
  store i8 %35, ptr %36, align 1, !tbaa !5
  %37 = load i8, ptr %33, align 1, !tbaa !5
  store i8 %37, ptr %11, align 1, !tbaa !5
  %38 = load i8, ptr %12, align 4, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %.02228, i64 4
  %40 = load i8, ptr %39, align 1, !tbaa !5
  %41 = xor i8 %40, %38
  %42 = getelementptr inbounds i8, ptr %.02327, i64 4
  store i8 %41, ptr %42, align 1, !tbaa !5
  %43 = load i8, ptr %39, align 1, !tbaa !5
  store i8 %43, ptr %12, align 4, !tbaa !5
  %44 = load i8, ptr %13, align 1, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %.02228, i64 5
  %46 = load i8, ptr %45, align 1, !tbaa !5
  %47 = xor i8 %46, %44
  %48 = getelementptr inbounds i8, ptr %.02327, i64 5
  store i8 %47, ptr %48, align 1, !tbaa !5
  %49 = load i8, ptr %45, align 1, !tbaa !5
  store i8 %49, ptr %13, align 1, !tbaa !5
  %50 = load i8, ptr %14, align 2, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %.02228, i64 6
  %52 = load i8, ptr %51, align 1, !tbaa !5
  %53 = xor i8 %52, %50
  %54 = getelementptr inbounds i8, ptr %.02327, i64 6
  store i8 %53, ptr %54, align 1, !tbaa !5
  %55 = load i8, ptr %51, align 1, !tbaa !5
  store i8 %55, ptr %14, align 2, !tbaa !5
  %56 = load i8, ptr %15, align 1, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %.02228, i64 7
  %58 = load i8, ptr %57, align 1, !tbaa !5
  %59 = xor i8 %58, %56
  %60 = getelementptr inbounds i8, ptr %.02327, i64 7
  store i8 %59, ptr %60, align 1, !tbaa !5
  %61 = load i8, ptr %57, align 1, !tbaa !5
  store i8 %61, ptr %15, align 1, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %.02228, i64 8
  %63 = getelementptr inbounds i8, ptr %.02327, i64 8
  %64 = add i32 %.02129, -1
  %.not = icmp eq i32 %64, 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 8, ptr nonnull %7) #3
  ret void
}

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 = { 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