#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_CTX_new();
int /*<<< orphan*/ BN_bin2bn(char *, int, int /*<<< orphan*/ *);
scalar_t__ BN_cmp(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_new();
int /*<<< orphan*/ SANDSHREW_BN_mul(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                    int /*<<< orphan*/ *);
int /*<<< orphan*/ SANDSHREW_BN_sqr(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                    int /*<<< orphan*/ *);
int /*<<< orphan*/ abort();
int main(int argc, char *argv[]) {
  BN_CTX *ctx = BN_CTX_new();
  BIGNUM *x = BN_new();
  BIGNUM *r1 = BN_new();
  BIGNUM *r2 = BN_new();
  BN_bin2bn(argv[1], 32, x);
  SANDSHREW_BN_sqr(r1, x, ctx);
  SANDSHREW_BN_mul(r2, x, ctx);
  if (BN_cmp(r1, r2) != 0)
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1080 <BN_CTX_new@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x20,%esi
call   1050 <BN_bin2bn@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <SANDSHREW_BN_sqr@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <SANDSHREW_BN_mul@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1090 <BN_cmp@plt>
cmp    $0x0,%rax
je     1208 <main+0x98>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
xor    %eax,%eax
call   1080 <BN_CTX_new@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,%r13
mov    0x8(%r14),%rdi
mov    $0x20,%esi
mov    %rbx,%rdx
call   1050 <BN_bin2bn@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1060 <SANDSHREW_BN_sqr@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1070 <SANDSHREW_BN_mul@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1090 <BN_cmp@plt>
test   %rax,%rax
jne    11ed <main+0x7d>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32* (...) @BN_CTX_new()
store i32* %10, i32** %6
%11 = call i32* (...) @BN_new()
store i32* %11, i32** %7
%12 = call i32* (...) @BN_new()
store i32* %12, i32** %8
%13 = call i32* (...) @BN_new()
store i32* %13, i32** %9
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = load i32*, i32** %7
%18 = call i32 @BN_bin2bn(i8* %16, i32 32, i32* %17)
%19 = load i32*, i32** %8
%20 = load i32*, i32** %7
%21 = load i32*, i32** %6
%22 = call i32 @SANDSHREW_BN_sqr(i32* %19, i32* %20, i32* %21)
%23 = load i32*, i32** %9
%24 = load i32*, i32** %7
%25 = load i32*, i32** %6
%26 = call i32 @SANDSHREW_BN_mul(i32* %23, i32* %24, i32* %25)
%27 = load i32*, i32** %8
%28 = load i32*, i32** %9
%29 = call i64 @BN_cmp(i32* %27, i32* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %2
%32 = call i32 (...) @abort()
unreachable
33: ; preds = %2
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32* (...) @BN_CTX_new()
%4 = tail call i32* (...) @BN_new()
%5 = tail call i32* (...) @BN_new()
%6 = tail call i32* (...) @BN_new()
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @BN_bin2bn(i8* %8, i32 32, i32* %4)
%10 = tail call i32 @SANDSHREW_BN_sqr(i32* %5, i32* %4, i32* %3)
%11 = tail call i32 @SANDSHREW_BN_mul(i32* %6, i32* %4, i32* %3)
%12 = tail call i64 @BN_cmp(i32* %5, i32* %6)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %2
%15 = tail call i32 (...) @abort()
unreachable
16: ; preds = %2
ret i32 0
}