; LLVM IR from china-hai/yd_crypto :: src/des_tdes (yd_tdes_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

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

14:                                               ; preds = %35, %6
  %15 = load i32, ptr %12, align 4, !tbaa !9
  %16 = icmp ugt i32 %15, 0
  br i1 %16, label %17, label %48

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

18:                                               ; preds = %32, %17
  %19 = load i8, ptr %13, align 1, !tbaa !11
  %20 = zext i8 %19 to i32
  %21 = icmp slt i32 %20, 8
  br i1 %21, label %22, label %35

22:                                               ; preds = %18
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = load i8, ptr %13, align 1, !tbaa !11
  %25 = zext i8 %24 to i64
  %26 = getelementptr inbounds i8, ptr %23, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !11
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = load i8, ptr %13, align 1, !tbaa !11
  %30 = zext i8 %29 to i64
  %31 = getelementptr inbounds i8, ptr %28, i64 %30
  store i8 %27, ptr %31, align 1, !tbaa !11
  br label %32

32:                                               ; preds = %22
  %33 = load i8, ptr %13, align 1, !tbaa !11
  %34 = add i8 %33, 1
  store i8 %34, ptr %13, align 1, !tbaa !11
  br label %18, !llvm.loop !12

35:                                               ; preds = %18
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  call void @yd_des_crypto(ptr noundef %36, ptr noundef %37, i8 noundef zeroext 1)
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %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 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  call void @yd_des_crypto(ptr noundef %40, ptr noundef %41, i8 noundef zeroext 1)
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %42, i64 8
  store ptr %43, ptr %7, align 8, !tbaa !5
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i64 8
  store ptr %45, ptr %8, align 8, !tbaa !5
  %46 = load i32, ptr %12, align 4, !tbaa !9
  %47 = add i32 %46, -1
  store i32 %47, ptr %12, align 4, !tbaa !9
  br label %14, !llvm.loop !14

48:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #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}


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

declare void @yd_des_crypto(ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @yd_tdes_ecb_decrypt(ptr nocapture noundef readonly %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) local_unnamed_addr #1 {
  %.not19 = icmp eq i32 %5, 0
  br i1 %.not19, label %._crit_edge, label %.preheader

.preheader:                                       ; preds = %6, %.preheader
  %.01522 = phi i32 [ %31, %.preheader ], [ %5, %6 ]
  %.01621 = phi ptr [ %29, %.preheader ], [ %0, %6 ]
  %.01720 = phi ptr [ %30, %.preheader ], [ %1, %6 ]
  %7 = load i8, ptr %.01621, align 1, !tbaa !5
  store i8 %7, ptr %.01720, align 1, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %.01621, i64 1
  %9 = load i8, ptr %8, align 1, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %.01720, i64 1
  store i8 %9, ptr %10, align 1, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %.01621, i64 2
  %12 = load i8, ptr %11, align 1, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %.01720, i64 2
  store i8 %12, ptr %13, align 1, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %.01621, i64 3
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %.01720, i64 3
  store i8 %15, ptr %16, align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %.01621, i64 4
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %.01720, i64 4
  store i8 %18, ptr %19, align 1, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %.01621, i64 5
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %.01720, i64 5
  store i8 %21, ptr %22, align 1, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %.01621, i64 6
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %.01720, i64 6
  store i8 %24, ptr %25, align 1, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %.01621, i64 7
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %.01720, i64 7
  store i8 %27, ptr %28, align 1, !tbaa !5
  tail call void @yd_des_crypto(ptr noundef nonnull %.01720, ptr noundef %4, i8 noundef zeroext 1) #2
  tail call void @yd_des_crypto(ptr noundef nonnull %.01720, ptr noundef %3, i8 noundef zeroext 0) #2
  tail call void @yd_des_crypto(ptr noundef nonnull %.01720, ptr noundef %2, i8 noundef zeroext 1) #2
  %29 = getelementptr inbounds i8, ptr %.01621, i64 8
  %30 = getelementptr inbounds i8, ptr %.01720, i64 8
  %31 = add i32 %.01522, -1
  %.not = icmp eq i32 %31, 0
  br i1 %.not, label %._crit_edge, label %.preheader, !llvm.loop !8

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

attributes #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 = { 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 }

!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