#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 */
scalar_t__ BN_abs_is_word(int /*<<< orphan*/ const *, int /*<<< orphan*/);
int /*<<< orphan*/ *BN_dup(int /*<<< orphan*/ const *);
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_new();
int /*<<< orphan*/ BN_set_negative(int /*<<< orphan*/ *, int /*<<< orphan*/);
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*/ *,
                                            int /*<<< orphan*/ *);
int test_BN_abs_eq_word(const char *file, int line, const char *bns,
                        const char *ws, const BIGNUM *a, BN_ULONG w) {
  BIGNUM *bw, *aa;
  if (a != NULL && BN_abs_is_word(a, w))
    return 1;
  bw = BN_new();
  aa = BN_dup(a);
  BN_set_negative(aa, 0);
  BN_set_word(bw, w);
  test_fail_bignum_message(NULL, file, line, "BIGNUM", bns, ws, "abs==", aa,
                           bw);
  BN_free(bw);
  BN_free(aa);
  return 0;
}


x86 assembly (clang, -O0):
<test_BN_abs_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     11bc <test_BN_abs_eq_word+0x4c>
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1090 <BN_abs_is_word@plt>
cmp    $0x0,%rax
je     11bc <test_BN_abs_eq_word+0x4c>
movl   $0x1,-0x4(%rbp)
jmp    1240 <test_BN_abs_eq_word+0xd0>
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <BN_dup@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
xor    %esi,%esi
call   1050 <BN_set_negative@plt>
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    -0x48(%rbp),%r10
mov    -0x40(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edi
lea    0xdf3(%rip),%rcx
lea    0xdf3(%rip),%r11
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1080 <test_fail_bignum_message@plt>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
mov    -0x48(%rbp),%rdi
call   1070 <BN_free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_BN_abs_eq_word>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%ebp
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%r13d
mov    %rdi,0x10(%rsp)
test   %r8,%r8
je     11ac <test_BN_abs_eq_word+0x3c>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1090 <BN_abs_is_word@plt>
mov    $0x1,%r12d
test   %rax,%rax
jne    1222 <test_BN_abs_eq_word+0xb2>
xor    %r12d,%r12d
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %r14,0x8(%rsp)
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <BN_dup@plt>
mov    %r15,%rbx
mov    %rax,%r15
mov    %rax,%rdi
xor    %esi,%esi
call   1050 <BN_set_negative@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <BN_set_word@plt>
sub    $0x8,%rsp
lea    0xe1c(%rip),%rax
lea    0xe0e(%rip),%rcx
xor    %edi,%edi
mov    0x18(%rsp),%rsi
mov    %r13d,%edx
mov    %rbx,%r8
mov    0x10(%rsp),%r9
push   %r14
push   %r15
push   %rax
call   1080 <test_fail_bignum_message@plt>
add    $0x20,%rsp
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    %r15,%rdi
call   1070 <BN_free@plt>
mov    %r12d,%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 = [6 x i8] c"abs==\00"
define i32 @test_BN_abs_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*
%15 = 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
%16 = load i32*, i32** %12
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %24
18: ; preds = %6
%19 = load i32*, i32** %12
%20 = load i32, i32* %13
%21 = call i64 @BN_abs_is_word(i32* %19, i32 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 1, i32* %7
br label %44
24: ; preds = %18, %6
%25 = call i32* (...) @BN_new()
store i32* %25, i32** %14
%26 = load i32*, i32** %12
%27 = call i32* @BN_dup(i32* %26)
store i32* %27, i32** %15
%28 = load i32*, i32** %15
%29 = call i32 @BN_set_negative(i32* %28, i32 0)
%30 = load i32*, i32** %14
%31 = load i32, i32* %13
%32 = call i32 @BN_set_word(i32* %30, i32 %31)
%33 = load i8*, i8** %8
%34 = load i32, i32* %9
%35 = load i8*, i8** %10
%36 = load i8*, i8** %11
%37 = load i32*, i32** %15
%38 = load i32*, i32** %14
%39 = call i32 @test_fail_bignum_message(i32* null, i8* %33, i32 %34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %35, i8* %36, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %37, i32* %38)
%40 = load i32*, i32** %14
%41 = call i32 @BN_free(i32* %40)
%42 = load i32*, i32** %15
%43 = call i32 @BN_free(i32* %42)
store i32 0, i32* %7
br label %44
44: ; preds = %24, %23
%45 = load i32, i32* %7
ret i32 %45
}

LLVM IR (-O2):
@.str = [7 x i8] c"BIGNUM\00"
@.str.1 = [6 x i8] c"abs==\00"
define i32 @test_BN_abs_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_abs_is_word(i32* %4, i32 %5)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %8, %6
%12 = tail call i32* (...) @BN_new()
%13 = tail call i32* @BN_dup(i32* %4)
%14 = tail call i32 @BN_set_negative(i32* %13, i32 0)
%15 = tail call i32 @BN_set_word(i32* %12, i32 %5)
%16 = 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 ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %13, i32* %12)
%17 = tail call i32 @BN_free(i32* %12)
%18 = tail call i32 @BN_free(i32* %13)
br label %19
19: ; preds = %8, %11
%20 = phi i32 [ 0, %11 ], [ 1, %8 ]
ret i32 %20
}