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

/* Variables and functions */
int /*<<< orphan*/ BN_clear_free(int /*<<< orphan*/ *);
scalar_t__ BN_mul(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                  int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_new();
scalar_t__ BN_sub(int /*<<< orphan*/ *, int /*<<< orphan*/ const *,
                  int /*<<< orphan*/);
int /*<<< orphan*/ BN_value_one();
int euler(BIGNUM *_result, BIGNUM const *_p, BIGNUM const *_q, BN_CTX *_ctx) {
  BIGNUM *_tmp1 = BN_new();
  BIGNUM *_tmp2 = BN_new();
  int ret = 1;
  if (BN_sub(_tmp1, _p, BN_value_one()) == 0)
    ret = 0;
  if (BN_sub(_tmp2, _q, BN_value_one()) == 0)
    ret = 0;
  if (BN_mul(_result, _tmp1, _tmp2, _ctx) == 0)
    ret = 0;
  BN_clear_free(_tmp1);
  BN_clear_free(_tmp2);
  return ret;
}


x86 assembly (clang, -O0):
<euler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1030 <BN_value_one@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
call   1050 <BN_sub@plt>
cmp    $0x0,%rax
jne    11bc <euler+0x6c>
movl   $0x0,-0x34(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    $0x0,%al
call   1030 <BN_value_one@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
call   1050 <BN_sub@plt>
cmp    $0x0,%rax
jne    11f3 <euler+0xa3>
movl   $0x0,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1060 <BN_mul@plt>
cmp    $0x0,%rax
jne    1219 <euler+0xc9>
movl   $0x0,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <BN_clear_free@plt>
mov    -0x30(%rbp),%rdi
call   1070 <BN_clear_free@plt>
mov    -0x34(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<euler>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%r12
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <BN_value_one@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1050 <BN_sub@plt>
test   %rax,%rax
setne  %bpl
xor    %eax,%eax
call   1030 <BN_value_one@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1050 <BN_sub@plt>
test   %rax,%rax
setne  %r13b
mov    %r12,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1060 <BN_mul@plt>
test   %rax,%rax
setne  %al
and    %r13b,%al
and    %bpl,%al
movzbl %al,%ebp
mov    %r14,%rdi
call   1070 <BN_clear_free@plt>
mov    %rbx,%rdi
call   1070 <BN_clear_free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @euler(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%12 = call i32* (...) @BN_new()
store i32* %12, i32** %9
%13 = call i32* (...) @BN_new()
store i32* %13, i32** %10
store i32 1, i32* %11
%14 = load i32*, i32** %9
%15 = load i32*, i32** %6
%16 = call i32 (...) @BN_value_one()
%17 = call i64 @BN_sub(i32* %14, i32* %15, i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %4
store i32 0, i32* %11
br label %20
20: ; preds = %19, %4
%21 = load i32*, i32** %10
%22 = load i32*, i32** %7
%23 = call i32 (...) @BN_value_one()
%24 = call i64 @BN_sub(i32* %21, i32* %22, i32 %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
store i32 0, i32* %11
br label %27
27: ; preds = %26, %20
%28 = load i32*, i32** %5
%29 = load i32*, i32** %9
%30 = load i32*, i32** %10
%31 = load i32*, i32** %8
%32 = call i64 @BN_mul(i32* %28, i32* %29, i32* %30, i32* %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %27
store i32 0, i32* %11
br label %35
35: ; preds = %34, %27
%36 = load i32*, i32** %9
%37 = call i32 @BN_clear_free(i32* %36)
%38 = load i32*, i32** %10
%39 = call i32 @BN_clear_free(i32* %38)
%40 = load i32, i32* %11
ret i32 %40
}

LLVM IR (-O2):
define i32 @euler(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = tail call i32* (...) @BN_new()
%6 = tail call i32* (...) @BN_new()
%7 = tail call i32 (...) @BN_value_one()
%8 = tail call i64 @BN_sub(i32* %5, i32* %1, i32 %7)
%9 = icmp ne i64 %8, 0
%10 = tail call i32 (...) @BN_value_one()
%11 = tail call i64 @BN_sub(i32* %6, i32* %2, i32 %10)
%12 = icmp ne i64 %11, 0
%13 = tail call i64 @BN_mul(i32* %0, i32* %5, i32* %6, i32* %3)
%14 = icmp ne i64 %13, 0
%15 = select i1 %14, i1 %12, i1 false
%16 = select i1 %15, i1 %9, i1 false
%17 = zext i1 %16 to i32
%18 = tail call i32 @BN_clear_free(i32* %5)
%19 = tail call i32 @BN_clear_free(i32* %6)
ret i32 %17
}