; LLVM IR from gost-engine/engine :: test_mgm (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.testcase = type { ptr, ptr, ptr, i64, ptr, i64, ptr, i64, ptr, ptr }

@testcases = external hidden global [3 x %struct.testcase], align 16
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1

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

11:                                               ; preds = %90, %0
  %12 = load ptr, ptr %3, align 8, !tbaa !9
  %13 = getelementptr inbounds %struct.testcase, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %93

16:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %17 = load ptr, ptr %3, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.testcase, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = call ptr @EVP_get_cipherbyname(ptr noundef %19)
  store ptr %20, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %21 = load ptr, ptr %3, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.testcase, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = call ptr @EVP_CIPHER_fetch(ptr noundef null, ptr noundef %23, ptr noundef null)
  store ptr %24, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %25 = load ptr, ptr %5, align 8, !tbaa !9
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %29

27:                                               ; preds = %16
  %28 = load ptr, ptr %5, align 8, !tbaa !9
  br label %31

29:                                               ; preds = %16
  %30 = load ptr, ptr %6, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %29, %27
  %32 = phi ptr [ %28, %27 ], [ %30, %29 ]
  store ptr %32, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %33 = load ptr, ptr %7, align 8, !tbaa !9
  %34 = icmp ne ptr %33, null
  br i1 %34, label %40, label %35

35:                                               ; preds = %31
  %36 = load ptr, ptr %3, align 8, !tbaa !9
  %37 = getelementptr inbounds %struct.testcase, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef %38)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %9, align 4
  br label %87

40:                                               ; preds = %31
  %41 = load ptr, ptr %7, align 8, !tbaa !9
  %42 = call ptr @EVP_CIPHER_get0_name(ptr noundef %41)
  store ptr %42, ptr %8, align 8, !tbaa !9
  %43 = load ptr, ptr %8, align 8, !tbaa !9
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, ptr noundef %43)
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %82, %40
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = icmp sle i32 %46, 1
  br i1 %47, label %48, label %85

48:                                               ; preds = %45
  %49 = load ptr, ptr %7, align 8, !tbaa !9
  %50 = load ptr, ptr %8, align 8, !tbaa !9
  %51 = load ptr, ptr %3, align 8, !tbaa !9
  %52 = getelementptr inbounds %struct.testcase, ptr %51, i32 0, i32 2
  %53 = load ptr, ptr %52, align 8, !tbaa !14
  %54 = load ptr, ptr %3, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.testcase, ptr %54, i32 0, i32 3
  %56 = load i64, ptr %55, align 8, !tbaa !15
  %57 = load ptr, ptr %3, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.testcase, ptr %57, i32 0, i32 4
  %59 = load ptr, ptr %58, align 8, !tbaa !16
  %60 = load ptr, ptr %3, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.testcase, ptr %60, i32 0, i32 5
  %62 = load i64, ptr %61, align 8, !tbaa !17
  %63 = load ptr, ptr %3, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.testcase, ptr %63, i32 0, i32 6
  %65 = load ptr, ptr %64, align 8, !tbaa !18
  %66 = load ptr, ptr %3, align 8, !tbaa !9
  %67 = getelementptr inbounds %struct.testcase, ptr %66, i32 0, i32 7
  %68 = load i64, ptr %67, align 8, !tbaa !19
  %69 = load ptr, ptr %3, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct.testcase, ptr %69, i32 0, i32 8
  %71 = load ptr, ptr %70, align 8, !tbaa !20
  %72 = load ptr, ptr %3, align 8, !tbaa !9
  %73 = getelementptr inbounds %struct.testcase, ptr %72, i32 0, i32 9
  %74 = load ptr, ptr %73, align 8, !tbaa !21
  %75 = load ptr, ptr %3, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct.testcase, ptr %75, i32 0, i32 1
  %77 = load ptr, ptr %76, align 8, !tbaa !22
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = call i32 @test_block(ptr noundef %49, ptr noundef %50, ptr noundef %53, i64 noundef %56, ptr noundef %59, i64 noundef %62, ptr noundef %65, i64 noundef %68, ptr noundef %71, ptr noundef %74, ptr noundef %77, i32 noundef %78)
  %80 = load i32, ptr %2, align 4, !tbaa !5
  %81 = or i32 %80, %79
  store i32 %81, ptr %2, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %48
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %4, align 4, !tbaa !5
  br label %45, !llvm.loop !23

85:                                               ; preds = %45
  %86 = load ptr, ptr %6, align 8, !tbaa !9
  call void @EVP_CIPHER_free(ptr noundef %86)
  store i32 0, ptr %9, align 4
  br label %87

87:                                               ; preds = %85, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %88 = load i32, ptr %9, align 4
  switch i32 %88, label %102 [
    i32 0, label %89
  ]

89:                                               ; preds = %87
  br label %90

90:                                               ; preds = %89
  %91 = load ptr, ptr %3, align 8, !tbaa !9
  %92 = getelementptr inbounds %struct.testcase, ptr %91, i32 1
  store ptr %92, ptr %3, align 8, !tbaa !9
  br label %11, !llvm.loop !25

93:                                               ; preds = %11
  %94 = load i32, ptr %2, align 4, !tbaa !5
  %95 = icmp ne i32 %94, 0
  br i1 %95, label %96, label %98

96:                                               ; preds = %93
  %97 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %100

98:                                               ; preds = %93
  %99 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %100

100:                                              ; preds = %98, %96
  %101 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %101, ptr %1, align 4
  store i32 1, ptr %9, align 4
  br label %102

102:                                              ; preds = %100, %87
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %103 = load i32, ptr %1, align 4
  ret i32 %103
}

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

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

declare ptr @EVP_get_cipherbyname(ptr noundef) #2

declare ptr @EVP_CIPHER_fetch(ptr noundef, ptr noundef, ptr noundef) #2

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

declare ptr @EVP_CIPHER_get0_name(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @test_block(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #0

declare void @EVP_CIPHER_free(ptr noundef) #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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 = !{!"testcase", !10, i64 0, !10, i64 8, !10, i64 16, !13, i64 24, !10, i64 32, !13, i64 40, !10, i64 48, !13, i64 56, !10, i64 64, !10, i64 72}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !13, i64 24}
!16 = !{!12, !10, i64 32}
!17 = !{!12, !13, i64 40}
!18 = !{!12, !10, i64 48}
!19 = !{!12, !13, i64 56}
!20 = !{!12, !10, i64 64}
!21 = !{!12, !10, i64 72}
!22 = !{!12, !10, i64 8}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}


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

@testcases = external hidden local_unnamed_addr global [3 x %struct.testcase], align 16
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1

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

.lr.ph:                                           ; preds = %.split, %9
  %2 = phi ptr [ %44, %9 ], [ %1, %.split ]
  %.03151 = phi i32 [ %42, %9 ], [ 0, %.split ]
  %.03450 = phi ptr [ %43, %9 ], [ @testcases, %.split ]
  %3 = tail call ptr @EVP_get_cipherbyname(ptr noundef nonnull %2) #3
  %4 = load ptr, ptr %.03450, align 8, !tbaa !5
  %5 = tail call ptr @EVP_CIPHER_fetch(ptr noundef null, ptr noundef %4, ptr noundef null) #3
  %.not39 = icmp eq ptr %3, null
  %6 = select i1 %.not39, ptr %5, ptr %3
  %.not40.not = icmp eq ptr %6, null
  br i1 %.not40.not, label %.thread, label %9

.thread:                                          ; preds = %.lr.ph
  %7 = load ptr, ptr %.03450, align 8, !tbaa !5
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef %7)
  br label %48

9:                                                ; preds = %.lr.ph
  %10 = tail call ptr @EVP_CIPHER_get0_name(ptr noundef nonnull %6) #3
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, ptr noundef %10)
  %12 = getelementptr inbounds i8, ptr %.03450, i64 16
  %13 = getelementptr inbounds i8, ptr %.03450, i64 24
  %14 = getelementptr inbounds i8, ptr %.03450, i64 32
  %15 = getelementptr inbounds i8, ptr %.03450, i64 40
  %16 = getelementptr inbounds i8, ptr %.03450, i64 48
  %17 = getelementptr inbounds i8, ptr %.03450, i64 56
  %18 = getelementptr inbounds i8, ptr %.03450, i64 64
  %19 = getelementptr inbounds i8, ptr %.03450, i64 72
  %20 = getelementptr inbounds i8, ptr %.03450, i64 8
  %21 = load ptr, ptr %12, align 8, !tbaa !11
  %22 = load i64, ptr %13, align 8, !tbaa !12
  %23 = load ptr, ptr %14, align 8, !tbaa !13
  %24 = load i64, ptr %15, align 8, !tbaa !14
  %25 = load ptr, ptr %16, align 8, !tbaa !15
  %26 = load i64, ptr %17, align 8, !tbaa !16
  %27 = load ptr, ptr %18, align 8, !tbaa !17
  %28 = load ptr, ptr %19, align 8, !tbaa !18
  %29 = load ptr, ptr %20, align 8, !tbaa !19
  %30 = tail call i32 @test_block(ptr noundef nonnull %6, ptr noundef %10, ptr noundef %21, i64 noundef %22, ptr noundef %23, i64 noundef %24, ptr noundef %25, i64 noundef %26, ptr noundef %27, ptr noundef %28, ptr noundef %29, i32 noundef 0)
  %31 = or i32 %30, %.03151
  %32 = load ptr, ptr %12, align 8, !tbaa !11
  %33 = load i64, ptr %13, align 8, !tbaa !12
  %34 = load ptr, ptr %14, align 8, !tbaa !13
  %35 = load i64, ptr %15, align 8, !tbaa !14
  %36 = load ptr, ptr %16, align 8, !tbaa !15
  %37 = load i64, ptr %17, align 8, !tbaa !16
  %38 = load ptr, ptr %18, align 8, !tbaa !17
  %39 = load ptr, ptr %19, align 8, !tbaa !18
  %40 = load ptr, ptr %20, align 8, !tbaa !19
  %41 = tail call i32 @test_block(ptr noundef nonnull %6, ptr noundef %10, ptr noundef %32, i64 noundef %33, ptr noundef %34, i64 noundef %35, ptr noundef %36, i64 noundef %37, ptr noundef %38, ptr noundef %39, ptr noundef %40, i32 noundef 1)
  %42 = or i32 %41, %31
  tail call void @EVP_CIPHER_free(ptr noundef %5) #3
  %43 = getelementptr inbounds i8, ptr %.03450, i64 80
  %44 = load ptr, ptr %43, align 8, !tbaa !5
  %.not = icmp eq ptr %44, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !20

._crit_edge:                                      ; preds = %9
  %.not38 = icmp eq i32 %42, 0
  br i1 %.not38, label %._crit_edge.thread, label %45

45:                                               ; preds = %._crit_edge
  %46 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %48

._crit_edge.thread:                               ; preds = %.split, %._crit_edge
  %47 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %48

48:                                               ; preds = %.thread, %45, %._crit_edge.thread
  %.2 = phi i32 [ 0, %._crit_edge.thread ], [ %42, %45 ], [ 1, %.thread ]
  ret i32 %.2
}

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

declare ptr @EVP_get_cipherbyname(ptr noundef) local_unnamed_addr #1

declare ptr @EVP_CIPHER_fetch(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

declare ptr @EVP_CIPHER_get0_name(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @test_block(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare void @EVP_CIPHER_free(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 = { 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 #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 = !{!"testcase", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !7, i64 32, !10, i64 40, !7, i64 48, !10, i64 56, !7, i64 64, !7, i64 72}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !10, i64 24}
!13 = !{!6, !7, i64 32}
!14 = !{!6, !10, i64 40}
!15 = !{!6, !7, i64 48}
!16 = !{!6, !10, i64 56}
!17 = !{!6, !7, i64 64}
!18 = !{!6, !7, i64 72}
!19 = !{!6, !7, i64 8}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


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