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

@derive_tests = external dso_local global [2 x %struct.test_derive], align 16
@.str.17 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.38 = 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

declare i32 @printf(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: nounwind uwtable
declare dso_local i32 @test_derive_pair(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @test_derive_alg(ptr noundef, ptr noundef, i32 noundef) #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 i32, align 4
  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 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %20, %2
  %10 = load i32, ptr %7, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = icmp ult i64 %11, 2
  br i1 %12, label %13, label %23

13:                                               ; preds = %9
  %14 = load i32, ptr %7, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [2 x %struct.test_derive], ptr @derive_tests, i64 0, i64 %15
  %17 = call i32 @test_derive_pair(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 = %13
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %7, align 4, !tbaa !5
  br label %9, !llvm.loop !11

23:                                               ; preds = %9
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %68, %23
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = icmp slt i32 %25, 4
  br i1 %26, label %27, label %71

27:                                               ; preds = %24
  %28 = load i32, ptr %7, align 4, !tbaa !5
  %29 = call i32 @test_derive_alg(ptr noundef @.str.28, ptr noundef @.str.17, i32 noundef %28)
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = or i32 %30, %29
  store i32 %31, ptr %6, align 4, !tbaa !5
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = call i32 @test_derive_alg(ptr noundef @.str.28, ptr noundef @.str.18, i32 noundef %32)
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = or i32 %34, %33
  store i32 %35, ptr %6, align 4, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = call i32 @test_derive_alg(ptr noundef @.str.28, ptr noundef @.str.33, i32 noundef %36)
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = or i32 %38, %37
  store i32 %39, ptr %6, align 4, !tbaa !5
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = call i32 @test_derive_alg(ptr noundef @.str.34, ptr noundef @.str.17, i32 noundef %40)
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = or i32 %42, %41
  store i32 %43, ptr %6, align 4, !tbaa !5
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = call i32 @test_derive_alg(ptr noundef @.str.34, ptr noundef @.str.18, i32 noundef %44)
  %46 = load i32, ptr %6, align 4, !tbaa !5
  %47 = or i32 %46, %45
  store i32 %47, ptr %6, align 4, !tbaa !5
  %48 = load i32, ptr %7, align 4, !tbaa !5
  %49 = call i32 @test_derive_alg(ptr noundef @.str.34, ptr noundef @.str.33, i32 noundef %48)
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = or i32 %50, %49
  store i32 %51, ptr %6, align 4, !tbaa !5
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = call i32 @test_derive_alg(ptr noundef @.str.34, ptr noundef @.str.35, i32 noundef %52)
  %54 = load i32, ptr %6, align 4, !tbaa !5
  %55 = or i32 %54, %53
  store i32 %55, ptr %6, align 4, !tbaa !5
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = call i32 @test_derive_alg(ptr noundef @.str.36, ptr noundef @.str.17, i32 noundef %56)
  %58 = load i32, ptr %6, align 4, !tbaa !5
  %59 = or i32 %58, %57
  store i32 %59, ptr %6, align 4, !tbaa !5
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = call i32 @test_derive_alg(ptr noundef @.str.36, ptr noundef @.str.18, i32 noundef %60)
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = or i32 %62, %61
  store i32 %63, ptr %6, align 4, !tbaa !5
  %64 = load i32, ptr %7, align 4, !tbaa !5
  %65 = call i32 @test_derive_alg(ptr noundef @.str.36, ptr noundef @.str.33, i32 noundef %64)
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = or i32 %66, %65
  store i32 %67, ptr %6, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %27
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %7, align 4, !tbaa !5
  br label %24, !llvm.loop !13

71:                                               ; preds = %24
  %72 = load i32, ptr %6, align 4, !tbaa !5
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %74, label %76

74:                                               ; preds = %71
  %75 = call i32 (ptr, ...) @printf(ptr noundef @.str.37)
  br label %78

76:                                               ; preds = %71
  %77 = call i32 (ptr, ...) @printf(ptr noundef @.str.38)
  br label %78

78:                                               ; preds = %76, %74
  %79 = load i32, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  ret i32 %79
}

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

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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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_derive = type { ptr, i32, i32, i32, ptr, i32, ptr, ptr, ptr, ptr, ptr, i32 }

@derive_tests = external dso_local global [2 x %struct.test_derive], align 16
@.str.17 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.38 = 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 i32 @test_derive_pair(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @test_derive_alg(ptr noundef, ptr noundef, i32 noundef) 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 {
.preheader.preheader:
  %2 = tail call i32 @OPENSSL_init_crypto(i64 noundef 76, ptr noundef null) #3
  %3 = tail call i32 @test_derive_pair(ptr noundef nonnull @derive_tests)
  %4 = tail call i32 @test_derive_pair(ptr noundef nonnull getelementptr inbounds (i8, ptr @derive_tests, i64 88))
  %5 = or i32 %4, %3
  %6 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.17, i32 noundef 0)
  %7 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.18, i32 noundef 0)
  %8 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.33, i32 noundef 0)
  %9 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.17, i32 noundef 0)
  %10 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.18, i32 noundef 0)
  %11 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.33, i32 noundef 0)
  %12 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.35, i32 noundef 0)
  %13 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.17, i32 noundef 0)
  %14 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.18, i32 noundef 0)
  %15 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.33, i32 noundef 0)
  %16 = or i32 %6, %5
  %17 = or i32 %16, %7
  %18 = or i32 %17, %8
  %19 = or i32 %18, %9
  %20 = or i32 %19, %10
  %21 = or i32 %20, %11
  %22 = or i32 %21, %12
  %23 = or i32 %22, %13
  %24 = or i32 %23, %14
  %25 = or i32 %24, %15
  %26 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.17, i32 noundef 1)
  %27 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.18, i32 noundef 1)
  %28 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.33, i32 noundef 1)
  %29 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.17, i32 noundef 1)
  %30 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.18, i32 noundef 1)
  %31 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.33, i32 noundef 1)
  %32 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.35, i32 noundef 1)
  %33 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.17, i32 noundef 1)
  %34 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.18, i32 noundef 1)
  %35 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.33, i32 noundef 1)
  %36 = or i32 %26, %25
  %37 = or i32 %36, %27
  %38 = or i32 %37, %28
  %39 = or i32 %38, %29
  %40 = or i32 %39, %30
  %41 = or i32 %40, %31
  %42 = or i32 %41, %32
  %43 = or i32 %42, %33
  %44 = or i32 %43, %34
  %45 = or i32 %44, %35
  %46 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.17, i32 noundef 2)
  %47 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.18, i32 noundef 2)
  %48 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.33, i32 noundef 2)
  %49 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.17, i32 noundef 2)
  %50 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.18, i32 noundef 2)
  %51 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.33, i32 noundef 2)
  %52 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.35, i32 noundef 2)
  %53 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.17, i32 noundef 2)
  %54 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.18, i32 noundef 2)
  %55 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.33, i32 noundef 2)
  %56 = or i32 %46, %45
  %57 = or i32 %56, %47
  %58 = or i32 %57, %48
  %59 = or i32 %58, %49
  %60 = or i32 %59, %50
  %61 = or i32 %60, %51
  %62 = or i32 %61, %52
  %63 = or i32 %62, %53
  %64 = or i32 %63, %54
  %65 = or i32 %64, %55
  %66 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.17, i32 noundef 3)
  %67 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.18, i32 noundef 3)
  %68 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.33, i32 noundef 3)
  %69 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.17, i32 noundef 3)
  %70 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.18, i32 noundef 3)
  %71 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.33, i32 noundef 3)
  %72 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.35, i32 noundef 3)
  %73 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.17, i32 noundef 3)
  %74 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.18, i32 noundef 3)
  %75 = tail call i32 @test_derive_alg(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.33, i32 noundef 3)
  %76 = or i32 %66, %65
  %77 = or i32 %76, %67
  %78 = or i32 %77, %68
  %79 = or i32 %78, %69
  %80 = or i32 %79, %70
  %81 = or i32 %80, %71
  %82 = or i32 %81, %72
  %83 = or i32 %82, %73
  %84 = or i32 %83, %74
  %85 = or i32 %84, %75
  %.not = icmp eq i32 %85, 0
  %.str.38..str.37 = select i1 %.not, ptr @.str.38, ptr @.str.37
  %86 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.38..str.37)
  ret i32 %85
}

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

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)"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass