#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*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ ecn_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ ecn_square(int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_si(int /*<<< orphan*/, int);
scalar_t__ mpz_sizeinbase(int /*<<< orphan*/, int);
scalar_t__ mpz_tstbit(int /*<<< orphan*/, int);
void ecn_exp(mpz_t t1, mpz_t t2, mpz_t s, mpz_t rx, mpz_t ry, mpz_t modulus,
             mpz_t a, mpz_t b, mpz_t x, mpz_t y, mpz_t exponent) {
  int i;
  mpz_set_si(rx, -1);
  mpz_set_si(ry, -1);
  int bitLength = (int)mpz_sizeinbase(exponent, 2);
  for (i = bitLength; i >= 0; i--) {
    ecn_square(t1, t2, s, rx, ry, modulus, a, b, rx, ry);
    if (mpz_tstbit(exponent, i)) {
      ecn_mul(t1, t2, s, rx, ry, modulus, a, b, rx, ry, x, y);
    }
  }
  return;
}


x86 assembly (clang, -O0):
<ecn_exp>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %edi,-0x1c(%rbp)
mov    %esi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    %ecx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9d,-0x30(%rbp)
mov    -0x28(%rbp),%edi
mov    $0xffffffff,%esi
call   1040 <mpz_set_si@plt>
mov    -0x2c(%rbp),%edi
mov    $0xffffffff,%esi
call   1040 <mpz_set_si@plt>
mov    0x30(%rbp),%edi
mov    $0x2,%esi
call   1050 <mpz_sizeinbase@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     1264 <ecn_exp+0x114>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    0x10(%rbp),%ebx
mov    0x18(%rbp),%r11d
mov    -0x28(%rbp),%r10d
mov    -0x2c(%rbp),%eax
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1060 <ecn_square@plt>
mov    0x30(%rbp),%edi
mov    -0x34(%rbp),%esi
call   1030 <mpz_tstbit@plt>
cmp    $0x0,%rax
je     1251 <ecn_exp+0x101>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    0x10(%rbp),%r15d
mov    0x18(%rbp),%r14d
mov    -0x28(%rbp),%ebx
mov    -0x2c(%rbp),%r11d
mov    0x20(%rbp),%r10d
mov    0x28(%rbp),%eax
mov    %r15d,(%rsp)
mov    %r14d,0x8(%rsp)
mov    %ebx,0x10(%rsp)
mov    %r11d,0x18(%rsp)
mov    %r10d,0x20(%rsp)
mov    %eax,0x28(%rsp)
call   1070 <ecn_mul@plt>
jmp    1256 <ecn_exp+0x106>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    11b0 <ecn_exp+0x60>
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<ecn_exp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%ebp
mov    %ecx,%ebx
mov    %edx,%r15d
mov    %esi,%r12d
mov    %edi,%r13d
mov    %ecx,%edi
mov    $0xffffffff,%esi
call   1040 <mpz_set_si@plt>
mov    %ebp,%edi
mov    $0xffffffff,%esi
call   1040 <mpz_set_si@plt>
mov    0x60(%rsp),%edi
mov    $0x2,%esi
call   1050 <mpz_sizeinbase@plt>
mov    %rbx,%rcx
mov    %r13d,%ebx
mov    %r12d,%r13d
mov    %r15d,%r12d
mov    %r14d,%r15d
mov    %rax,%r14
test   %r14d,%r14d
js     123b <ecn_exp+0xeb>
mov    %rbp,%r8
mov    0x48(%rsp),%eax
mov    0x40(%rsp),%ebp
mov    %rcx,(%rsp)
jmp    11db <ecn_exp+0x8b>
xchg   %ax,%ax
lea    -0x1(%r14),%eax
test   %r14d,%r14d
mov    %eax,%r14d
mov    %rbp,%r8
mov    (%rsp),%rcx
mov    0x48(%rsp),%eax
mov    0x40(%rsp),%ebp
jle    123b <ecn_exp+0xeb>
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15d,%r9d
push   %r8
push   %rcx
push   %rax
push   %rbp
mov    %r8,%rbp
call   1060 <ecn_square@plt>
add    $0x20,%rsp
mov    0x60(%rsp),%edi
mov    %r14d,%esi
call   1030 <mpz_tstbit@plt>
test   %rax,%rax
je     11c0 <ecn_exp+0x70>
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r12d,%edx
mov    (%rsp),%rcx
mov    %ebp,%r8d
mov    %r15d,%r9d
mov    0x58(%rsp),%eax
push   %rax
mov    0x58(%rsp),%eax
push   %rax
push   %rbp
push   %rcx
mov    0x68(%rsp),%eax
push   %rax
mov    0x68(%rsp),%eax
push   %rax
call   1070 <ecn_mul@plt>
add    $0x30,%rsp
jmp    11c0 <ecn_exp+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ecn_exp(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10) {
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
store i32 %0, i32* %12
store i32 %1, i32* %13
store i32 %2, i32* %14
store i32 %3, i32* %15
store i32 %4, i32* %16
store i32 %5, i32* %17
store i32 %6, i32* %18
store i32 %7, i32* %19
store i32 %8, i32* %20
store i32 %9, i32* %21
store i32 %10, i32* %22
%25 = load i32, i32* %15
%26 = call i32 @mpz_set_si(i32 %25, i32 -1)
%27 = load i32, i32* %16
%28 = call i32 @mpz_set_si(i32 %27, i32 -1)
%29 = load i32, i32* %22
%30 = call i64 @mpz_sizeinbase(i32 %29, i32 2)
%31 = trunc i64 %30 to i32
store i32 %31, i32* %24
%32 = load i32, i32* %24
store i32 %32, i32* %23
br label %33
33: ; preds = %67, %11
%34 = load i32, i32* %23
%35 = icmp sge i32 %34, 0
br i1 %35, label %36, label %70
36: ; preds = %33
%37 = load i32, i32* %12
%38 = load i32, i32* %13
%39 = load i32, i32* %14
%40 = load i32, i32* %15
%41 = load i32, i32* %16
%42 = load i32, i32* %17
%43 = load i32, i32* %18
%44 = load i32, i32* %19
%45 = load i32, i32* %15
%46 = load i32, i32* %16
%47 = call i32 @ecn_square(i32 %37, i32 %38, i32 %39, i32 %40, i32 %41, i32 %42, i32 %43, i32 %44, i32 %45, i32 %46)
%48 = load i32, i32* %22
%49 = load i32, i32* %23
%50 = call i64 @mpz_tstbit(i32 %48, i32 %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %66
52: ; preds = %36
%53 = load i32, i32* %12
%54 = load i32, i32* %13
%55 = load i32, i32* %14
%56 = load i32, i32* %15
%57 = load i32, i32* %16
%58 = load i32, i32* %17
%59 = load i32, i32* %18
%60 = load i32, i32* %19
%61 = load i32, i32* %15
%62 = load i32, i32* %16
%63 = load i32, i32* %20
%64 = load i32, i32* %21
%65 = call i32 @ecn_mul(i32 %53, i32 %54, i32 %55, i32 %56, i32 %57, i32 %58, i32 %59, i32 %60, i32 %61, i32 %62, i32 %63, i32 %64)
br label %66
66: ; preds = %52, %36
br label %67
67: ; preds = %66
%68 = load i32, i32* %23
%69 = add nsw i32 %68, -1
store i32 %69, i32* %23
br label %33
70: ; preds = %33
ret void
}

LLVM IR (-O2):
define void @ecn_exp(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10) {
%12 = tail call i32 @mpz_set_si(i32 %3, i32 -1)
%13 = tail call i32 @mpz_set_si(i32 %4, i32 -1)
%14 = tail call i64 @mpz_sizeinbase(i32 %10, i32 2)
%15 = trunc i64 %14 to i32
%16 = icmp sgt i32 %15, -1
br i1 %16, label %17, label %27
17: ; preds = %11, %24
%18 = phi i32 [ %25, %24 ], [ %15, %11 ]
%19 = tail call i32 @ecn_square(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %3, i32 %4)
%20 = tail call i64 @mpz_tstbit(i32 %10, i32 %18)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = tail call i32 @ecn_mul(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %3, i32 %4, i32 %8, i32 %9)
br label %24
24: ; preds = %17, %22
%25 = add nsw i32 %18, -1
%26 = icmp sgt i32 %18, 0
br i1 %26, label %17, label %27
27: ; preds = %24, %11
ret void
}