#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*/ BN_ULONG;
typedef int /*<<< orphan*/ BIGNUM;

/* Variables and functions */
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ *);
scalar_t__ BN_is_word(int /*<<< orphan*/ const *, int /*<<< orphan*/);
int /*<<< orphan*/ *BN_new();
int /*<<< orphan*/ BN_set_word(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ test_fail_bignum_message(int /*<<< orphan*/ *, char const *,
                                            int, char *, char const *,
                                            char const *, char *,
                                            int /*<<< orphan*/ const *,
                                            int /*<<< orphan*/ *);
int test_BN_eq_word(const char *file, int line, const char *bns, const char *ws,
                    const BIGNUM *a, BN_ULONG w) {
  BIGNUM *bw;
  if (a != NULL && BN_is_word(a, w))
    return 1;
  bw = BN_new();
  BN_set_word(bw, w);
  test_fail_bignum_message(NULL, file, line, "BIGNUM", bns, ws, "==", a, bw);
  BN_free(bw);
  return 0;
}


x86 assembly (clang, -O0):
<test_BN_eq_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     119c <test_BN_eq_word+0x4c>
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1050 <BN_is_word@plt>
cmp    $0x0,%rax
je     119c <test_BN_eq_word+0x4c>
movl   $0x1,-0x4(%rbp)
jmp    11ff <test_BN_eq_word+0xaf>
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1030 <BN_set_word@plt>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
mov    -0x30(%rbp),%r10
mov    -0x40(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edi
lea    0xe2b(%rip),%rcx
lea    0xe2b(%rip),%r11
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1070 <test_fail_bignum_message@plt>
mov    -0x40(%rbp),%rdi
call   1060 <BN_free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_BN_eq_word>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%r14d
mov    %r8,%rbx
mov    %rcx,%r12
mov    %rdx,%r13
mov    %esi,%ebp
mov    %rdi,0x10(%rsp)
test   %r8,%r8
je     118c <test_BN_eq_word+0x3c>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1050 <BN_is_word@plt>
mov    $0x1,%r15d
test   %rax,%rax
jne    11e1 <test_BN_eq_word+0x91>
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %r12,0x8(%rsp)
mov    %rax,%r12
mov    %rax,%rdi
mov    %r14d,%esi
call   1030 <BN_set_word@plt>
sub    $0x8,%rsp
lea    0xe53(%rip),%rax
lea    0xe45(%rip),%rcx
xor    %edi,%edi
mov    0x18(%rsp),%rsi
mov    %ebp,%edx
mov    %r13,%r8
mov    0x10(%rsp),%r9
push   %r12
push   %rbx
push   %rax
call   1070 <test_fail_bignum_message@plt>
add    $0x20,%rsp
mov    %r12,%rdi
call   1060 <BN_free@plt>
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"BIGNUM\00"
@.str.1 = [3 x i8] c"==\00"
define i32 @test_BN_eq_word(i8* %0, i32 %1, i8* %2, i8* %3, i32* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32*
store i8* %0, i8** %8
store i32 %1, i32* %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i32* %4, i32** %12
store i32 %5, i32* %13
%15 = load i32*, i32** %12
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %23
17: ; preds = %6
%18 = load i32*, i32** %12
%19 = load i32, i32* %13
%20 = call i64 @BN_is_word(i32* %18, i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %17
store i32 1, i32* %7
br label %37
23: ; preds = %17, %6
%24 = call i32* (...) @BN_new()
store i32* %24, i32** %14
%25 = load i32*, i32** %14
%26 = load i32, i32* %13
%27 = call i32 @BN_set_word(i32* %25, i32 %26)
%28 = load i8*, i8** %8
%29 = load i32, i32* %9
%30 = load i8*, i8** %10
%31 = load i8*, i8** %11
%32 = load i32*, i32** %12
%33 = load i32*, i32** %14
%34 = call i32 @test_fail_bignum_message(i32* null, i8* %28, i32 %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %30, i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %32, i32* %33)
%35 = load i32*, i32** %14
%36 = call i32 @BN_free(i32* %35)
store i32 0, i32* %7
br label %37
37: ; preds = %23, %22
%38 = load i32, i32* %7
ret i32 %38
}

LLVM IR (-O2):
@.str = [7 x i8] c"BIGNUM\00"
@.str.1 = [3 x i8] c"==\00"
define i32 @test_BN_eq_word(i8* %0, i32 %1, i8* %2, i8* %3, i32* %4, i32 %5) {
%7 = icmp eq i32* %4, null
br i1 %7, label %11, label %8
8: ; preds = %6
%9 = tail call i64 @BN_is_word(i32* %4, i32 %5)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %8, %6
%12 = tail call i32* (...) @BN_new()
%13 = tail call i32 @BN_set_word(i32* %12, i32 %5)
%14 = tail call i32 @test_fail_bignum_message(i32* null, i8* %0, i32 %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %12)
%15 = tail call i32 @BN_free(i32* %12)
br label %16
16: ; preds = %8, %11
%17 = phi i32 [ 0, %11 ], [ 1, %8 ]
ret i32 %17
}