; LLVM IR from gost-engine/engine :: gost89 (gost_dec_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

; 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
declare dso_local void @gostcrypt(ptr noundef, ptr noundef, ptr noundef) #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) #2

; Function Attrs: nounwind uwtable
define dso_local void @gost_dec_cfb(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) #1 {
  %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 [8 x i8], align 1
  %12 = alloca [8 x i8], align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  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 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %17 = getelementptr inbounds [8 x i8], ptr %11, i64 0, i64 0
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %17, ptr align 1 %18, i64 8, i1 false)
  store i32 0, ptr %13, align 4, !tbaa !9
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %19, ptr %15, align 8, !tbaa !5
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %20, ptr %16, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %57, %5
  %22 = load i32, ptr %13, align 4, !tbaa !9
  %23 = load i32, ptr %10, align 4, !tbaa !9
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %25, label %64

25:                                               ; preds = %21
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds [8 x i8], ptr %11, i64 0, i64 0
  %28 = getelementptr inbounds [8 x i8], ptr %12, i64 0, i64 0
  call void @gostcrypt(ptr noundef %26, ptr noundef %27, ptr noundef %28)
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %53, %25
  %30 = load i32, ptr %14, align 4, !tbaa !9
  %31 = icmp slt i32 %30, 8
  br i1 %31, label %32, label %56

32:                                               ; preds = %29
  %33 = load ptr, ptr %15, align 8, !tbaa !5
  %34 = load i32, ptr %14, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i8, ptr %33, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !11
  %38 = load i32, ptr %14, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [8 x i8], ptr %11, i64 0, i64 %39
  store i8 %37, ptr %40, align 1, !tbaa !11
  %41 = zext i8 %37 to i32
  %42 = load i32, ptr %14, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [8 x i8], ptr %12, i64 0, i64 %43
  %45 = load i8, ptr %44, align 1, !tbaa !11
  %46 = zext i8 %45 to i32
  %47 = xor i32 %41, %46
  %48 = trunc i32 %47 to i8
  %49 = load ptr, ptr %16, align 8, !tbaa !5
  %50 = load i32, ptr %14, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i8, ptr %49, i64 %51
  store i8 %48, ptr %52, align 1, !tbaa !11
  br label %53

53:                                               ; preds = %32
  %54 = load i32, ptr %14, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %14, align 4, !tbaa !9
  br label %29, !llvm.loop !12

56:                                               ; preds = %29
  br label %57

57:                                               ; preds = %56
  %58 = load i32, ptr %13, align 4, !tbaa !9
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %13, align 4, !tbaa !9
  %60 = load ptr, ptr %15, align 8, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %60, i64 8
  store ptr %61, ptr %15, align 8, !tbaa !5
  %62 = load ptr, ptr %16, align 8, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %62, i64 8
  store ptr %63, ptr %16, align 8, !tbaa !5
  br label %21, !llvm.loop !14

64:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  ret void
}

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

; 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
declare dso_local void @gostcrypt(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @gost_dec_cfb(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef writeonly %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = alloca [8 x i8], align 8
  %7 = alloca [8 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #2
  %8 = load i64, ptr %1, align 1
  store i64 %8, ptr %6, align 8
  %9 = icmp sgt i32 %4, 0
  br i1 %9, label %.lr.ph.preheader, label %._crit_edge

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

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.022 = phi ptr [ %64, %.lr.ph ], [ %3, %.lr.ph.preheader ]
  %.01621 = phi ptr [ %63, %.lr.ph ], [ %2, %.lr.ph.preheader ]
  %.01820 = phi i32 [ %62, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  call void @gostcrypt(ptr noundef %0, ptr noundef nonnull %6, ptr noundef nonnull %7)
  %24 = load i8, ptr %.01621, align 1, !tbaa !5
  store i8 %24, ptr %6, align 8, !tbaa !5
  %25 = load i8, ptr %7, align 1, !tbaa !5
  %26 = xor i8 %25, %24
  store i8 %26, ptr %.022, align 1, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %.01621, i64 1
  %28 = load i8, ptr %27, align 1, !tbaa !5
  store i8 %28, ptr %10, align 1, !tbaa !5
  %29 = load i8, ptr %11, align 1, !tbaa !5
  %30 = xor i8 %29, %28
  %31 = getelementptr inbounds i8, ptr %.022, i64 1
  store i8 %30, ptr %31, align 1, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %.01621, i64 2
  %33 = load i8, ptr %32, align 1, !tbaa !5
  store i8 %33, ptr %12, align 2, !tbaa !5
  %34 = load i8, ptr %13, align 1, !tbaa !5
  %35 = xor i8 %34, %33
  %36 = getelementptr inbounds i8, ptr %.022, i64 2
  store i8 %35, ptr %36, align 1, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %.01621, i64 3
  %38 = load i8, ptr %37, align 1, !tbaa !5
  store i8 %38, ptr %14, align 1, !tbaa !5
  %39 = load i8, ptr %15, align 1, !tbaa !5
  %40 = xor i8 %39, %38
  %41 = getelementptr inbounds i8, ptr %.022, i64 3
  store i8 %40, ptr %41, align 1, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %.01621, i64 4
  %43 = load i8, ptr %42, align 1, !tbaa !5
  store i8 %43, ptr %16, align 4, !tbaa !5
  %44 = load i8, ptr %17, align 1, !tbaa !5
  %45 = xor i8 %44, %43
  %46 = getelementptr inbounds i8, ptr %.022, i64 4
  store i8 %45, ptr %46, align 1, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %.01621, i64 5
  %48 = load i8, ptr %47, align 1, !tbaa !5
  store i8 %48, ptr %18, align 1, !tbaa !5
  %49 = load i8, ptr %19, align 1, !tbaa !5
  %50 = xor i8 %49, %48
  %51 = getelementptr inbounds i8, ptr %.022, i64 5
  store i8 %50, ptr %51, align 1, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %.01621, i64 6
  %53 = load i8, ptr %52, align 1, !tbaa !5
  store i8 %53, ptr %20, align 2, !tbaa !5
  %54 = load i8, ptr %21, align 1, !tbaa !5
  %55 = xor i8 %54, %53
  %56 = getelementptr inbounds i8, ptr %.022, i64 6
  store i8 %55, ptr %56, align 1, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %.01621, i64 7
  %58 = load i8, ptr %57, align 1, !tbaa !5
  store i8 %58, ptr %22, align 1, !tbaa !5
  %59 = load i8, ptr %23, align 1, !tbaa !5
  %60 = xor i8 %59, %58
  %61 = getelementptr inbounds i8, ptr %.022, i64 7
  store i8 %60, ptr %61, align 1, !tbaa !5
  %62 = add nuw nsw i32 %.01820, 1
  %63 = getelementptr i8, ptr %.01621, i64 8
  %64 = getelementptr inbounds i8, ptr %.022, i64 8
  %exitcond.not = icmp eq i32 %62, %4
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %.lr.ph, %5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #2
  ret void
}

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