; LLVM IR from gost-engine/engine :: test_digest (main)

; 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.hash_testvec = type { ptr, ptr, ptr, ptr, ptr, ptr, i32, i64, i32, i32, i32, i32, i32 }

@testvecs = external hidden constant [26 x %struct.hash_testvec], align 16
@.str.8 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [31 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

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

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local void @warn_all_untested() #2

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !5
  %8 = call i32 @OPENSSL_init_crypto(i64 noundef 76, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store ptr @testvecs, ptr %7, align 8, !tbaa !9
  br label %9

9:                                                ; preds = %30, %2
  %10 = load ptr, ptr %7, align 8, !tbaa !9
  %11 = getelementptr inbounds %struct.hash_testvec, ptr %10, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %33

14:                                               ; preds = %9
  %15 = load ptr, ptr %7, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.hash_testvec, ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %24

19:                                               ; preds = %14
  %20 = load ptr, ptr %7, align 8, !tbaa !9
  %21 = call i32 @do_test(ptr noundef %20)
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = or i32 %22, %21
  store i32 %23, ptr %6, align 4, !tbaa !5
  br label %29

24:                                               ; preds = %14
  %25 = load ptr, ptr %7, align 8, !tbaa !9
  %26 = call i32 @do_synthetic_test(ptr noundef %25)
  %27 = load i32, ptr %6, align 4, !tbaa !5
  %28 = or i32 %27, %26
  store i32 %28, ptr %6, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %24, %19
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr %7, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.hash_testvec, ptr %31, i32 1
  store ptr %32, ptr %7, align 8, !tbaa !9
  br label %9, !llvm.loop !15

33:                                               ; preds = %9
  call void @warn_all_untested()
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %33
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  br label %40

38:                                               ; preds = %33
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  br label %40

40:                                               ; preds = %38, %36
  %41 = load i32, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  ret i32 %41
}

declare i32 @OPENSSL_init_crypto(i64 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @do_test(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @do_synthetic_test(ptr noundef) #2

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"hash_testvec", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !6, i64 48, !13, i64 56, !6, i64 64, !6, i64 68, !6, i64 72, !6, i64 76, !6, i64 80}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !10, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"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"

%struct.hash_testvec = type { ptr, ptr, ptr, ptr, ptr, ptr, i32, i64, i32, i32, i32, i32, i32 }

@testvecs = external hidden constant [26 x %struct.hash_testvec], align 16
@.str.8 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @warn_all_untested() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #1 {
  %3 = tail call i32 @OPENSSL_init_crypto(i64 noundef 76, ptr noundef null) #3
  %4 = load ptr, ptr @testvecs, align 16, !tbaa !5
  %.not11 = icmp eq ptr %4, null
  br i1 %.not11, label %._crit_edge.thread, label %.lr.ph

._crit_edge.thread:                               ; preds = %2
  tail call void @warn_all_untested()
  br label %14

.lr.ph:                                           ; preds = %2, %11
  %.013 = phi ptr [ %12, %11 ], [ @testvecs, %2 ]
  %.0812 = phi i32 [ %.1, %11 ], [ 0, %2 ]
  %5 = getelementptr inbounds i8, ptr %.013, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %.not10 = icmp eq ptr %6, null
  br i1 %.not10, label %9, label %7

7:                                                ; preds = %.lr.ph
  %8 = tail call i32 @do_test(ptr noundef nonnull %.013)
  br label %11

9:                                                ; preds = %.lr.ph
  %10 = tail call i32 @do_synthetic_test(ptr noundef nonnull %.013)
  br label %11

11:                                               ; preds = %7, %9
  %.pn = phi i32 [ %8, %7 ], [ %10, %9 ]
  %.1 = or i32 %.pn, %.0812
  %12 = getelementptr inbounds i8, ptr %.013, i64 88
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %11
  tail call void @warn_all_untested()
  %.not9 = icmp eq i32 %.1, 0
  br i1 %.not9, label %14, label %15

14:                                               ; preds = %._crit_edge.thread, %._crit_edge
  br label %15

15:                                               ; preds = %._crit_edge, %14
  %.str.9.sink = phi ptr [ @.str.9, %14 ], [ @.str.8, %._crit_edge ]
  %.08.lcssa16 = phi i32 [ 0, %14 ], [ %.1, %._crit_edge ]
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.9.sink)
  ret i32 %.08.lcssa16
}

declare i32 @OPENSSL_init_crypto(i64 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @do_test(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @do_synthetic_test(ptr noundef) local_unnamed_addr #1

attributes #0 = { nofree nounwind "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 = { "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 = !{!"hash_testvec", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !10, i64 48, !11, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !7, i64 16}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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