#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_free(int /*<<< orphan*/ *);
int BN_kronecker(int /*<<< orphan*/ *, int /*<<< orphan*/ const *,
                 int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_mod_add(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                              int /*<<< orphan*/ *const,
                              int /*<<< orphan*/ const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_mod_mul(int /*<<< orphan*/ *, int /*<<< orphan*/ const *,
                              int /*<<< orphan*/ *const,
                              int /*<<< orphan*/ const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_new();
int gt(int /*<<< orphan*/ const *, int /*<<< orphan*/ *const *,
       int /*<<< orphan*/ const *, int /*<<< orphan*/ *);
int decrypt_component(BIGNUM *const *enc, const BIGNUM *N, const BIGNUM *a,
                      const BIGNUM *r, int blind, BN_CTX *ctx) {
  BIGNUM *tmp;
  BIGNUM *tmp2;
  int ret;
  tmp = BN_new();
  tmp2 = BN_new();
  BN_mod_mul(tmp, r, enc[1], N, ctx);
  BN_mod_add(tmp2, tmp, enc[0], N, ctx);
  ret = BN_kronecker(tmp2, N, ctx);
  if (gt(a, enc, N, ctx) == -1)
    ret *= blind;
  BN_free(tmp);
  return ret;
}


x86 assembly (clang, -O0):
<decrypt_component>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1060 <BN_mod_mul@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1080 <BN_mod_add@plt>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <BN_kronecker@plt>
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1070 <gt@plt>
cmp    $0xffffffff,%eax
jne    120b <decrypt_component+0xab>
mov    -0x24(%rbp),%eax
imul   -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <BN_free@plt>
mov    -0x44(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decrypt_component>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%rbx
mov    %r8d,0xc(%rsp)
mov    %rcx,%r14
mov    %rdx,0x10(%rsp)
mov    %rsi,%rbp
mov    %rdi,%r13
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,%r12
mov    0x8(%r13),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbp,%rcx
mov    %rbx,%r8
call   1060 <BN_mod_mul@plt>
mov    0x0(%r13),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbp,%rcx
mov    %rbx,%r8
call   1080 <BN_mod_add@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1030 <BN_kronecker@plt>
mov    %eax,%r14d
mov    0x10(%rsp),%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   1070 <gt@plt>
cmp    $0xffffffff,%eax
mov    $0x1,%ebx
cmove  0xc(%rsp),%ebx
imul   %r14d,%ebx
mov    %r15,%rdi
call   1050 <BN_free@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @decrypt_component(i32** %0, i32* %1, i32* %2, i32* %3, i32 %4, i32* %5) {
%7 = alloca i32**
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32
store i32** %0, i32*** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32 %4, i32* %11
store i32* %5, i32** %12
%16 = call i32* (...) @BN_new()
store i32* %16, i32** %13
%17 = call i32* (...) @BN_new()
store i32* %17, i32** %14
%18 = load i32*, i32** %13
%19 = load i32*, i32** %10
%20 = load i32**, i32*** %7
%21 = getelementptr inbounds i32*, i32** %20, i64 1
%22 = load i32*, i32** %21
%23 = load i32*, i32** %8
%24 = load i32*, i32** %12
%25 = call i32 @BN_mod_mul(i32* %18, i32* %19, i32* %22, i32* %23, i32* %24)
%26 = load i32*, i32** %14
%27 = load i32*, i32** %13
%28 = load i32**, i32*** %7
%29 = getelementptr inbounds i32*, i32** %28, i64 0
%30 = load i32*, i32** %29
%31 = load i32*, i32** %8
%32 = load i32*, i32** %12
%33 = call i32 @BN_mod_add(i32* %26, i32* %27, i32* %30, i32* %31, i32* %32)
%34 = load i32*, i32** %14
%35 = load i32*, i32** %8
%36 = load i32*, i32** %12
%37 = call i32 @BN_kronecker(i32* %34, i32* %35, i32* %36)
store i32 %37, i32* %15
%38 = load i32*, i32** %9
%39 = load i32**, i32*** %7
%40 = load i32*, i32** %8
%41 = load i32*, i32** %12
%42 = call i32 @gt(i32* %38, i32** %39, i32* %40, i32* %41)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %48
44: ; preds = %6
%45 = load i32, i32* %11
%46 = load i32, i32* %15
%47 = mul nsw i32 %46, %45
store i32 %47, i32* %15
br label %48
48: ; preds = %44, %6
%49 = load i32*, i32** %13
%50 = call i32 @BN_free(i32* %49)
%51 = load i32, i32* %15
ret i32 %51
}

LLVM IR (-O2):
define i32 @decrypt_component(i32** %0, i32* %1, i32* %2, i32* %3, i32 %4, i32* %5) {
%7 = tail call i32* (...) @BN_new()
%8 = tail call i32* (...) @BN_new()
%9 = getelementptr inbounds i32*, i32** %0, i64 1
%10 = load i32*, i32** %9
%11 = tail call i32 @BN_mod_mul(i32* %7, i32* %3, i32* %10, i32* %1, i32* %5)
%12 = load i32*, i32** %0
%13 = tail call i32 @BN_mod_add(i32* %8, i32* %7, i32* %12, i32* %1, i32* %5)
%14 = tail call i32 @BN_kronecker(i32* %8, i32* %1, i32* %5)
%15 = tail call i32 @gt(i32* %2, i32** %0, i32* %1, i32* %5)
%16 = icmp eq i32 %15, -1
%17 = select i1 %16, i32 %4, i32 1
%18 = mul nsw i32 %17, %14
%19 = tail call i32 @BN_free(i32* %7)
ret i32 %18
}