#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_printf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ NID_X9_62_c2tnb191v1;
int /*<<< orphan*/ NID_X9_62_c2tnb239v1;
int /*<<< orphan*/ NID_X9_62_prime192v1;
int /*<<< orphan*/ NID_X9_62_prime239v1;
int /*<<< orphan*/ change_rand();
int /*<<< orphan*/ restore_rand();
int /*<<< orphan*/ x9_62_test_internal(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                       char *, char *);
int x9_62_tests(BIO *out) {
  int ret = 0;
  BIO_printf(out, "some tests from X9.62:\n");
  if (!change_rand())
    goto x962_err;
  if (!x9_62_test_internal(
          out, NID_X9_62_prime192v1,
          "3342403536405981729393488334694600415596881826869351677613",
          "5735822328888155254683894997897571951568553642892029982342"))
    goto x962_err;
  if (!x9_62_test_internal(
          out, NID_X9_62_prime239v1,
          "3086361431751678114926225473006680188549593787585317781474"
          "62058306432176",
          "3238135532097973577080787768312505059318910517550078427819"
          "78505179448783"))
    goto x962_err;
  if (!x9_62_test_internal(
          out, NID_X9_62_c2tnb191v1,
          "87194383164871543355722284926904419997237591535066528048",
          "308992691965804947361541664549085895292153777025772063598"))
    goto x962_err;
  if (!x9_62_test_internal(
          out, NID_X9_62_c2tnb239v1,
          "2159633321041961198501834003903461262881815148684178964245"
          "5876922391552",
          "1970303740007316867383349976549972270528498040721988191026"
          "49413465737174"))
    goto x962_err;
  ret = 1;
x962_err:
  if (!restore_rand())
    ret = 0;
  return ret;
}


x86 assembly (clang, -O0):
<x9_62_tests>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1040 <BIO_printf@plt>
mov    $0x0,%al
call   1060 <change_rand@plt>
cmp    $0x0,%eax
jne    1178 <x9_62_tests+0x38>
jmp    1237 <x9_62_tests+0xf7>
mov    -0x8(%rbp),%rdi
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
lea    0xe8c(%rip),%rdx
lea    0xec0(%rip),%rcx
call   1030 <x9_62_test_internal@plt>
cmp    $0x0,%eax
jne    11a6 <x9_62_tests+0x66>
jmp    1237 <x9_62_tests+0xf7>
mov    -0x8(%rbp),%rdi
mov    0x2e27(%rip),%rax
mov    (%rax),%esi
lea    0xed4(%rip),%rdx
lea    0xf16(%rip),%rcx
call   1030 <x9_62_test_internal@plt>
cmp    $0x0,%eax
jne    11d4 <x9_62_tests+0x94>
jmp    1237 <x9_62_tests+0xf7>
mov    -0x8(%rbp),%rdi
mov    0x2df1(%rip),%rax
mov    (%rax),%esi
lea    0xf38(%rip),%rdx
lea    0xf6a(%rip),%rcx
call   1030 <x9_62_test_internal@plt>
cmp    $0x0,%eax
jne    1202 <x9_62_tests+0xc2>
jmp    1237 <x9_62_tests+0xf7>
mov    -0x8(%rbp),%rdi
mov    0x2ddb(%rip),%rax
mov    (%rax),%esi
lea    0xf7d(%rip),%rdx
lea    0xfbe(%rip),%rcx
call   1030 <x9_62_test_internal@plt>
cmp    $0x0,%eax
jne    1230 <x9_62_tests+0xf0>
jmp    1237 <x9_62_tests+0xf7>
movl   $0x1,-0xc(%rbp)
mov    $0x0,%al
call   1050 <restore_rand@plt>
cmp    $0x0,%eax
jne    124e <x9_62_tests+0x10e>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x9_62_tests>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xeb3(%rip),%rsi
call   1040 <BIO_printf@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <change_rand@plt>
test   %eax,%eax
je     11f3 <x9_62_tests+0xb3>
mov    0x2e5e(%rip),%rax
mov    (%rax),%esi
lea    0xea5(%rip),%rdx
lea    0xed9(%rip),%rcx
mov    %rbx,%rdi
call   1030 <x9_62_test_internal@plt>
test   %eax,%eax
je     11f3 <x9_62_tests+0xb3>
mov    0x2e4b(%rip),%rax
mov    (%rax),%esi
lea    0xef8(%rip),%rdx
lea    0xf3a(%rip),%rcx
mov    %rbx,%rdi
call   1030 <x9_62_test_internal@plt>
test   %eax,%eax
je     11f3 <x9_62_tests+0xb3>
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
lea    0xf67(%rip),%rdx
lea    0xf99(%rip),%rcx
mov    %rbx,%rdi
call   1030 <x9_62_test_internal@plt>
test   %eax,%eax
je     11f3 <x9_62_tests+0xb3>
mov    0x2e15(%rip),%rax
mov    (%rax),%esi
lea    0xfb7(%rip),%rdx
lea    0xff8(%rip),%rcx
mov    %rbx,%rdi
call   1030 <x9_62_test_internal@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
xor    %eax,%eax
call   1050 <restore_rand@plt>
test   %eax,%eax
cmovne %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"some tests from X9.62:\0A\00"
@NID_X9_62_prime192v1 = global i32 0
@.str.1 = [59 x i8] c"3342403536405981729393488334694600415596881826869351677613\00"
@.str.2 = [59 x i8] c"5735822328888155254683894997897571951568553642892029982342\00"
@NID_X9_62_prime239v1 = global i32 0
@.str.3 = [73 x i8] c"308636143175167811492622547300668018854959378758531778147462058306432176\00"
@.str.4 = [73 x i8] c"323813553209797357708078776831250505931891051755007842781978505179448783\00"
@NID_X9_62_c2tnb191v1 = global i32 0
@.str.5 = [57 x i8] c"87194383164871543355722284926904419997237591535066528048\00"
@.str.6 = [58 x i8] c"308992691965804947361541664549085895292153777025772063598\00"
@NID_X9_62_c2tnb239v1 = global i32 0
@.str.7 = [72 x i8] c"21596333210419611985018340039034612628818151486841789642455876922391552\00"
@.str.8 = [73 x i8] c"197030374000731686738334997654997227052849804072198819102649413465737174\00"
define i32 @x9_62_tests(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
%4 = load i32*, i32** %2
%5 = call i32 @BIO_printf(i32* %4, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (...) @change_rand()
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %1
br label %34
9: ; preds = %1
%10 = load i32*, i32** %2
%11 = load i32, i32* @NID_X9_62_prime192v1
%12 = call i32 @x9_62_test_internal(i32* %10, i32 %11, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %9
br label %34
15: ; preds = %9
%16 = load i32*, i32** %2
%17 = load i32, i32* @NID_X9_62_prime239v1
%18 = call i32 @x9_62_test_internal(i32* %16, i32 %17, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %15
br label %34
21: ; preds = %15
%22 = load i32*, i32** %2
%23 = load i32, i32* @NID_X9_62_c2tnb191v1
%24 = call i32 @x9_62_test_internal(i32* %22, i32 %23, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.6, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %21
br label %34
27: ; preds = %21
%28 = load i32*, i32** %2
%29 = load i32, i32* @NID_X9_62_c2tnb239v1
%30 = call i32 @x9_62_test_internal(i32* %28, i32 %29, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.8, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %27
br label %34
33: ; preds = %27
store i32 1, i32* %3
br label %34
34: ; preds = %33, %32, %26, %20, %14, %8
%35 = call i32 (...) @restore_rand()
%36 = icmp ne i32 %35, 0
br i1 %36, label %38, label %37
37: ; preds = %34
store i32 0, i32* %3
br label %38
38: ; preds = %37, %34
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [24 x i8] c"some tests from X9.62:\0A\00"
@NID_X9_62_prime192v1 = global i32 0
@.str.1 = [59 x i8] c"3342403536405981729393488334694600415596881826869351677613\00"
@.str.2 = [59 x i8] c"5735822328888155254683894997897571951568553642892029982342\00"
@NID_X9_62_prime239v1 = global i32 0
@.str.3 = [73 x i8] c"308636143175167811492622547300668018854959378758531778147462058306432176\00"
@.str.4 = [73 x i8] c"323813553209797357708078776831250505931891051755007842781978505179448783\00"
@NID_X9_62_c2tnb191v1 = global i32 0
@.str.5 = [57 x i8] c"87194383164871543355722284926904419997237591535066528048\00"
@.str.6 = [58 x i8] c"308992691965804947361541664549085895292153777025772063598\00"
@NID_X9_62_c2tnb239v1 = global i32 0
@.str.7 = [72 x i8] c"21596333210419611985018340039034612628818151486841789642455876922391552\00"
@.str.8 = [73 x i8] c"197030374000731686738334997654997227052849804072198819102649413465737174\00"
define i32 @x9_62_tests(i32* %0) {
%2 = tail call i32 @BIO_printf(i32* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (...) @change_rand()
%4 = icmp eq i32 %3, 0
br i1 %4, label %22, label %5
5: ; preds = %1
%6 = load i32, i32* @NID_X9_62_prime192v1
%7 = tail call i32 @x9_62_test_internal(i32* %0, i32 %6, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %22, label %9
9: ; preds = %5
%10 = load i32, i32* @NID_X9_62_prime239v1
%11 = tail call i32 @x9_62_test_internal(i32* %0, i32 %10, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.4, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %22, label %13
13: ; preds = %9
%14 = load i32, i32* @NID_X9_62_c2tnb191v1
%15 = tail call i32 @x9_62_test_internal(i32* %0, i32 %14, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.6, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %13
%18 = load i32, i32* @NID_X9_62_c2tnb239v1
%19 = tail call i32 @x9_62_test_internal(i32* %0, i32 %18, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.8, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %17, %13, %9, %5, %1
%23 = phi i32 [ 0, %13 ], [ 0, %9 ], [ 0, %5 ], [ 0, %1 ], [ %21, %17 ]
%24 = tail call i32 (...) @restore_rand()
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i32 0, i32 %23
ret i32 %26
}