#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_dec2bn(int /*<<< orphan*/ **, char *);
int /*<<< orphan*/ BN_mod_sqr(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                              int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_new();
int main() {
  BIGNUM *a = BN_new();
  BIGNUM *b = BN_new();
  BIGNUM *n = BN_new();
  BN_dec2bn(&a, "12345678901234567890123456789012345678901234567890");
  BN_dec2bn(&n, "98742135498168543216864656576516168165373218943519");
  BN_CTX *ctx = BN_CTX_new();
  for (int i = 0; i < 16; i++) {
    BN_mod_sqr(b, a, n, ctx);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x20(%rbp)
lea    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1030 <BN_dec2bn@plt>
lea    -0x20(%rbp),%rdi
lea    0xea8(%rip),%rsi
call   1030 <BN_dec2bn@plt>
mov    $0x0,%al
call   1050 <BN_CTX_new@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x10,-0x2c(%rbp)
jge    11cf <main+0x8f>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1060 <BN_mod_sqr@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11a2 <main+0x62>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,0x10(%rsp)
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,0x8(%rsp)
lea    0xe90(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <BN_dec2bn@plt>
lea    0xeb2(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1030 <BN_dec2bn@plt>
xor    %eax,%eax
call   1050 <BN_CTX_new@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rax,%rcx
call   1060 <BN_mod_sqr@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <BN_mod_sqr@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <BN_mod_sqr@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <BN_mod_sqr@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <BN_mod_sqr@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <BN_mod_sqr@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <BN_mod_sqr@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <BN_mod_sqr@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <BN_mod_sqr@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <BN_mod_sqr@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <BN_mod_sqr@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <BN_mod_sqr@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <BN_mod_sqr@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <BN_mod_sqr@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <BN_mod_sqr@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <BN_mod_sqr@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [51 x i8] c"12345678901234567890123456789012345678901234567890\00"
@.str.1 = [51 x i8] c"98742135498168543216864656576516168165373218943519\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32* (...) @BN_new()
store i32* %7, i32** %2
%8 = call i32* (...) @BN_new()
store i32* %8, i32** %3
%9 = call i32* (...) @BN_new()
store i32* %9, i32** %4
%10 = call i32 @BN_dec2bn(i32** %2, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @BN_dec2bn(i32** %4, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32* (...) @BN_CTX_new()
store i32* %12, i32** %5
store i32 0, i32* %6
br label %13
13: ; preds = %22, %0
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 16
br i1 %15, label %16, label %25
16: ; preds = %13
%17 = load i32*, i32** %3
%18 = load i32*, i32** %2
%19 = load i32*, i32** %4
%20 = load i32*, i32** %5
%21 = call i32 @BN_mod_sqr(i32* %17, i32* %18, i32* %19, i32* %20)
br label %22
22: ; preds = %16
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %13
25: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [51 x i8] c"12345678901234567890123456789012345678901234567890\00"
@.str.1 = [51 x i8] c"98742135498168543216864656576516168165373218943519\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca i32*
%3 = bitcast i32** %1 to i8*
%4 = tail call i32* (...) @BN_new()
store i32* %4, i32** %1
%5 = tail call i32* (...) @BN_new()
%6 = bitcast i32** %2 to i8*
%7 = tail call i32* (...) @BN_new()
store i32* %7, i32** %2
%8 = call i32 @BN_dec2bn(i32** %1, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @BN_dec2bn(i32** %2, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32* (...) @BN_CTX_new()
%11 = load i32*, i32** %1
%12 = load i32*, i32** %2
%13 = call i32 @BN_mod_sqr(i32* %5, i32* %11, i32* %12, i32* %10)
%14 = load i32*, i32** %1
%15 = load i32*, i32** %2
%16 = call i32 @BN_mod_sqr(i32* %5, i32* %14, i32* %15, i32* %10)
%17 = load i32*, i32** %1
%18 = load i32*, i32** %2
%19 = call i32 @BN_mod_sqr(i32* %5, i32* %17, i32* %18, i32* %10)
%20 = load i32*, i32** %1
%21 = load i32*, i32** %2
%22 = call i32 @BN_mod_sqr(i32* %5, i32* %20, i32* %21, i32* %10)
%23 = load i32*, i32** %1
%24 = load i32*, i32** %2
%25 = call i32 @BN_mod_sqr(i32* %5, i32* %23, i32* %24, i32* %10)
%26 = load i32*, i32** %1
%27 = load i32*, i32** %2
%28 = call i32 @BN_mod_sqr(i32* %5, i32* %26, i32* %27, i32* %10)
%29 = load i32*, i32** %1
%30 = load i32*, i32** %2
%31 = call i32 @BN_mod_sqr(i32* %5, i32* %29, i32* %30, i32* %10)
%32 = load i32*, i32** %1
%33 = load i32*, i32** %2
%34 = call i32 @BN_mod_sqr(i32* %5, i32* %32, i32* %33, i32* %10)
%35 = load i32*, i32** %1
%36 = load i32*, i32** %2
%37 = call i32 @BN_mod_sqr(i32* %5, i32* %35, i32* %36, i32* %10)
%38 = load i32*, i32** %1
%39 = load i32*, i32** %2
%40 = call i32 @BN_mod_sqr(i32* %5, i32* %38, i32* %39, i32* %10)
%41 = load i32*, i32** %1
%42 = load i32*, i32** %2
%43 = call i32 @BN_mod_sqr(i32* %5, i32* %41, i32* %42, i32* %10)
%44 = load i32*, i32** %1
%45 = load i32*, i32** %2
%46 = call i32 @BN_mod_sqr(i32* %5, i32* %44, i32* %45, i32* %10)
%47 = load i32*, i32** %1
%48 = load i32*, i32** %2
%49 = call i32 @BN_mod_sqr(i32* %5, i32* %47, i32* %48, i32* %10)
%50 = load i32*, i32** %1
%51 = load i32*, i32** %2
%52 = call i32 @BN_mod_sqr(i32* %5, i32* %50, i32* %51, i32* %10)
%53 = load i32*, i32** %1
%54 = load i32*, i32** %2
%55 = call i32 @BN_mod_sqr(i32* %5, i32* %53, i32* %54, i32* %10)
%56 = load i32*, i32** %1
%57 = load i32*, i32** %2
%58 = call i32 @BN_mod_sqr(i32* %5, i32* %56, i32* %57, i32* %10)
ret i32 0
}