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

@test_params = external hidden global [8 x ptr], align 16
@test_certs = external hidden global [11 x %struct.test_cert], align 16
@.str = external hidden unnamed_addr constant [32 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %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
  %8 = 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
  %9 = call i32 @OPENSSL_init_crypto(i64 noundef 76, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store ptr @test_params, ptr %7, align 8, !tbaa !9
  br label %10

10:                                               ; preds = %20, %2
  %11 = load ptr, ptr %7, align 8, !tbaa !9
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %23

14:                                               ; preds = %10
  %15 = load ptr, ptr %7, align 8, !tbaa !9
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = call i32 @test_param(ptr noundef %16)
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = or i32 %18, %17
  store i32 %19, ptr %6, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %14
  %21 = load ptr, ptr %7, align 8, !tbaa !9
  %22 = getelementptr inbounds ptr, ptr %21, i32 1
  store ptr %22, ptr %7, align 8, !tbaa !9
  br label %10, !llvm.loop !11

23:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store ptr @test_certs, ptr %8, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %34, %23
  %25 = load ptr, ptr %8, align 8, !tbaa !9
  %26 = getelementptr inbounds %struct.test_cert, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %37

29:                                               ; preds = %24
  %30 = load ptr, ptr %8, align 8, !tbaa !9
  %31 = call i32 @test_cert(ptr noundef %30)
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = or i32 %32, %31
  store i32 %33, ptr %6, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %29
  %35 = load ptr, ptr %8, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.test_cert, ptr %35, i32 1
  store ptr %36, ptr %8, align 8, !tbaa !9
  br label %24, !llvm.loop !15

37:                                               ; preds = %24
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %42

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

42:                                               ; preds = %37
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %44

44:                                               ; preds = %42, %40
  %45 = load i32, ptr %6, align 4, !tbaa !5
  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 4, ptr %6) #3
  ret i32 %45
}

; 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

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

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

declare i32 @printf(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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 8}
!14 = !{!"test_cert", !10, i64 0, !10, i64 8, !6, i64 16}
!15 = distinct !{!15, !12}


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

@test_params = external hidden local_unnamed_addr global [8 x ptr], align 16
@test_certs = external hidden global [11 x %struct.test_cert], align 16
@.str = external hidden unnamed_addr constant [32 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1

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

.preheader:                                       ; preds = %.lr.ph, %2
  %.010.lcssa = phi i32 [ 0, %2 ], [ %8, %.lr.ph ]
  %5 = load ptr, ptr getelementptr inbounds (i8, ptr @test_certs, i64 8), align 8, !tbaa !9
  %.not1217 = icmp eq ptr %5, null
  br i1 %.not1217, label %._crit_edge, label %.lr.ph20

.lr.ph:                                           ; preds = %2, %.lr.ph
  %6 = phi ptr [ %10, %.lr.ph ], [ %4, %2 ]
  %.0916 = phi ptr [ %9, %.lr.ph ], [ @test_params, %2 ]
  %.01015 = phi i32 [ %8, %.lr.ph ], [ 0, %2 ]
  %7 = tail call i32 @test_param(ptr noundef nonnull %6)
  %8 = or i32 %7, %.01015
  %9 = getelementptr inbounds i8, ptr %.0916, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %.preheader, label %.lr.ph, !llvm.loop !12

.lr.ph20:                                         ; preds = %.preheader, %.lr.ph20
  %.019 = phi ptr [ %13, %.lr.ph20 ], [ @test_certs, %.preheader ]
  %.118 = phi i32 [ %12, %.lr.ph20 ], [ %.010.lcssa, %.preheader ]
  %11 = tail call i32 @test_cert(ptr noundef nonnull %.019)
  %12 = or i32 %11, %.118
  %13 = getelementptr inbounds i8, ptr %.019, i64 24
  %14 = getelementptr inbounds i8, ptr %.019, i64 32
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %.not12 = icmp eq ptr %15, null
  br i1 %.not12, label %._crit_edge, label %.lr.ph20, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph20, %.preheader
  %.1.lcssa = phi i32 [ %.010.lcssa, %.preheader ], [ %12, %.lr.ph20 ]
  %.not13 = icmp eq i32 %.1.lcssa, 0
  %.str.1..str = select i1 %.not13, ptr @.str.1, ptr @.str
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.1..str)
  ret i32 %.1.lcssa
}

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

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

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

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

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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"test_cert", !6, i64 0, !6, i64 8, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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