; LLVM IR from specinfo-ua/UAPKI :: library/uapkic/src (gostr3411-2012)

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

%struct.ByteArray_st = type { ptr, i64 }
%struct.GostR3411Ctx_st = type { [8 x i64], [8 x i64], [8 x i64], [64 x i8], i64, i32 }

@.str = external hidden unnamed_addr constant [24 x i8], align 1

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

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 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: 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 i32 @gostr3411_update(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  br label %8

8:                                                ; preds = %2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %13, label %11

11:                                               ; preds = %8
  store i32 2, ptr %5, align 4, !tbaa !9
  %12 = load i32, ptr %5, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 754, i32 noundef %12, ptr noundef null)
  br label %106

13:                                               ; preds = %8
  br label %14

14:                                               ; preds = %13
  br label %15

15:                                               ; preds = %14
  br label %16

16:                                               ; preds = %15
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %21, label %19

19:                                               ; preds = %16
  store i32 2, ptr %5, align 4, !tbaa !9
  %20 = load i32, ptr %5, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 755, i32 noundef %20, ptr noundef null)
  br label %106

21:                                               ; preds = %16
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ByteArray_st, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  store ptr %26, ptr %6, align 8, !tbaa !5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ByteArray_st, ptr %27, i32 0, i32 1
  %29 = load i64, ptr %28, align 8, !tbaa !14
  store i64 %29, ptr %7, align 8, !tbaa !15
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.GostR3411Ctx_st, ptr %30, i32 0, i32 4
  %32 = load i64, ptr %31, align 8, !tbaa !16
  %33 = icmp ne i64 %32, 0
  br i1 %33, label %34, label %86

34:                                               ; preds = %23
  %35 = load i64, ptr %7, align 8, !tbaa !15
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.GostR3411Ctx_st, ptr %36, i32 0, i32 4
  %38 = load i64, ptr %37, align 8, !tbaa !16
  %39 = sub i64 64, %38
  %40 = icmp ult i64 %35, %39
  br i1 %40, label %41, label %56

41:                                               ; preds = %34
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.GostR3411Ctx_st, ptr %42, i32 0, i32 3
  %44 = getelementptr inbounds [64 x i8], ptr %43, i64 0, i64 0
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.GostR3411Ctx_st, ptr %45, i32 0, i32 4
  %47 = load i64, ptr %46, align 8, !tbaa !16
  %48 = getelementptr inbounds i8, ptr %44, i64 %47
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load i64, ptr %7, align 8, !tbaa !15
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %48, ptr align 1 %49, i64 %50, i1 false)
  %51 = load i64, ptr %7, align 8, !tbaa !15
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.GostR3411Ctx_st, ptr %52, i32 0, i32 4
  %54 = load i64, ptr %53, align 8, !tbaa !16
  %55 = add i64 %54, %51
  store i64 %55, ptr %53, align 8, !tbaa !16
  br label %106

56:                                               ; preds = %34
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.GostR3411Ctx_st, ptr %57, i32 0, i32 3
  %59 = getelementptr inbounds [64 x i8], ptr %58, i64 0, i64 0
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.GostR3411Ctx_st, ptr %60, i32 0, i32 4
  %62 = load i64, ptr %61, align 8, !tbaa !16
  %63 = getelementptr inbounds i8, ptr %59, i64 %62
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.GostR3411Ctx_st, ptr %65, i32 0, i32 4
  %67 = load i64, ptr %66, align 8, !tbaa !16
  %68 = sub i64 64, %67
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %63, ptr align 1 %64, i64 %68, i1 false)
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.GostR3411Ctx_st, ptr %70, i32 0, i32 3
  %72 = getelementptr inbounds [64 x i8], ptr %71, i64 0, i64 0
  call void @gostr3411_compress(ptr noundef %69, ptr noundef %72, i64 noundef 512)
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.GostR3411Ctx_st, ptr %73, i32 0, i32 4
  %75 = load i64, ptr %74, align 8, !tbaa !16
  %76 = sub i64 64, %75
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds i8, ptr %77, i64 %76
  store ptr %78, ptr %6, align 8, !tbaa !5
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.GostR3411Ctx_st, ptr %79, i32 0, i32 4
  %81 = load i64, ptr %80, align 8, !tbaa !16
  %82 = sub i64 64, %81
  %83 = load i64, ptr %7, align 8, !tbaa !15
  %84 = sub i64 %83, %82
  store i64 %84, ptr %7, align 8, !tbaa !15
  br label %85

85:                                               ; preds = %56
  br label %86

86:                                               ; preds = %85, %23
  br label %87

87:                                               ; preds = %90, %86
  %88 = load i64, ptr %7, align 8, !tbaa !15
  %89 = icmp uge i64 %88, 64
  br i1 %89, label %90, label %97

90:                                               ; preds = %87
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  call void @gostr3411_compress(ptr noundef %91, ptr noundef %92, i64 noundef 512)
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = getelementptr inbounds i8, ptr %93, i64 64
  store ptr %94, ptr %6, align 8, !tbaa !5
  %95 = load i64, ptr %7, align 8, !tbaa !15
  %96 = sub i64 %95, 64
  store i64 %96, ptr %7, align 8, !tbaa !15
  br label %87, !llvm.loop !18

97:                                               ; preds = %87
  %98 = load ptr, ptr %3, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.GostR3411Ctx_st, ptr %98, i32 0, i32 3
  %100 = getelementptr inbounds [64 x i8], ptr %99, i64 0, i64 0
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  %102 = load i64, ptr %7, align 8, !tbaa !15
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %100, ptr align 1 %101, i64 %102, i1 false)
  %103 = load i64, ptr %7, align 8, !tbaa !15
  %104 = load ptr, ptr %3, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.GostR3411Ctx_st, ptr %104, i32 0, i32 4
  store i64 %103, ptr %105, align 8, !tbaa !16
  br label %106

106:                                              ; preds = %97, %41, %19, %11
  %107 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret i32 %107
}

; Function Attrs: nounwind uwtable
declare hidden void @gostr3411_compress(ptr noundef, ptr noundef, i64 noundef) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = !{!"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 = !{!12, !6, i64 0}
!12 = !{!"ByteArray_st", !6, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 8}
!15 = !{!13, !13, i64 0}
!16 = !{!17, !13, i64 256}
!17 = !{!"GostR3411Ctx_st", !7, i64 0, !7, i64 64, !7, i64 128, !7, i64 192, !13, i64 256, !10, i64 264}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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

@.str = external hidden unnamed_addr constant [24 x i8], align 1

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress 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) #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @gostr3411_update(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %2
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 754, i32 noundef 2, ptr noundef null) #3
  br label %31

4:                                                ; preds = %2
  %.not44 = icmp eq ptr %1, null
  br i1 %.not44, label %5, label %6

5:                                                ; preds = %4
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 755, i32 noundef 2, ptr noundef null) #3
  br label %31

6:                                                ; preds = %4
  %7 = load ptr, ptr %1, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load i64, ptr %8, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %0, i64 256
  %11 = load i64, ptr %10, align 8, !tbaa !12
  %.not45 = icmp eq i64 %11, 0
  br i1 %.not45, label %25, label %12

12:                                               ; preds = %6
  %13 = sub i64 64, %11
  %14 = icmp ult i64 %9, %13
  %15 = getelementptr inbounds i8, ptr %0, i64 192
  %16 = getelementptr inbounds i8, ptr %15, i64 %11
  br i1 %14, label %17, label %20

17:                                               ; preds = %12
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %16, ptr align 1 %7, i64 %9, i1 false)
  %18 = load i64, ptr %10, align 8, !tbaa !12
  %19 = add i64 %18, %9
  store i64 %19, ptr %10, align 8, !tbaa !12
  br label %31

20:                                               ; preds = %12
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %16, ptr align 1 %7, i64 %13, i1 false)
  tail call void @gostr3411_compress(ptr noundef nonnull %0, ptr noundef nonnull %15, i64 noundef 512)
  %21 = load i64, ptr %10, align 8, !tbaa !12
  %22 = sub i64 64, %21
  %23 = getelementptr inbounds i8, ptr %7, i64 %22
  %24 = sub i64 %9, %22
  br label %25

25:                                               ; preds = %20, %6
  %.035 = phi ptr [ %23, %20 ], [ %7, %6 ]
  %.0 = phi i64 [ %24, %20 ], [ %9, %6 ]
  %26 = icmp ugt i64 %.0, 63
  br i1 %26, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %25, %.lr.ph
  %.147 = phi i64 [ %28, %.lr.ph ], [ %.0, %25 ]
  %.13646 = phi ptr [ %27, %.lr.ph ], [ %.035, %25 ]
  tail call void @gostr3411_compress(ptr noundef nonnull %0, ptr noundef %.13646, i64 noundef 512)
  %27 = getelementptr inbounds i8, ptr %.13646, i64 64
  %28 = add i64 %.147, -64
  %29 = icmp ugt i64 %28, 63
  br i1 %29, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph, %25
  %.136.lcssa = phi ptr [ %.035, %25 ], [ %27, %.lr.ph ]
  %.1.lcssa = phi i64 [ %.0, %25 ], [ %28, %.lr.ph ]
  %30 = getelementptr inbounds i8, ptr %0, i64 192
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %30, ptr align 1 %.136.lcssa, i64 %.1.lcssa, i1 false)
  store i64 %.1.lcssa, ptr %10, align 8, !tbaa !12
  br label %31

31:                                               ; preds = %._crit_edge, %17, %5, %3
  %.037 = phi i32 [ 0, %17 ], [ 0, %._crit_edge ], [ 2, %5 ], [ 2, %3 ]
  ret i32 %.037
}

; Function Attrs: nounwind uwtable
declare hidden void @gostr3411_compress(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !7, i64 0}
!6 = !{!"ByteArray_st", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !10, i64 256}
!13 = !{!"GostR3411Ctx_st", !8, i64 0, !8, i64 64, !8, i64 128, !8, i64 192, !10, i64 256, !14, i64 264}
!14 = !{!"int", !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass