#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_square(int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
scalar_t__ mpz_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ mpz_cmp_si(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_invert(int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mod(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_si(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_sub(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
void ecn_mul(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 x1, mpz_t y1, mpz_t x2, mpz_t y2) {
  if (mpz_cmp_si(x1, -1) == 0) {
    mpz_set(rx, x2);
    mpz_set(ry, y2);
    return;
  }
  if (mpz_cmp_si(x2, -1) == 0) {
    mpz_set(rx, x1);
    mpz_set(ry, y1);
    return;
  }
  mpz_add(t1, y1, y2);
  if (mpz_cmp(x1, x2) == 0 && mpz_cmp(t1, modulus) == 0) {
    mpz_set_si(rx, -1);
    mpz_set_si(ry, -1);
    return;
  }
  if (mpz_cmp(x1, x2) == 0 && mpz_cmp(y1, y2) == 0) {
    ecn_square(t1, t2, s, rx, ry, modulus, a, b, x1, x2);
    return;
  }
  mpz_sub(t1, y1, y2);
  mpz_sub(t2, x1, x2);
  mpz_invert(t2, t2, modulus);
  mpz_mul(s, t1, t2);
  mpz_mul(t1, s, s);
  mpz_sub(t1, t1, x1);
  mpz_sub(t1, t1, x2);
  mpz_sub(t2, x1, t1);
  mpz_mul(t2, s, t2);
  mpz_sub(t2, t2, y1);
  mpz_mod(rx, t1, modulus);
  mpz_mod(ry, t2, modulus);
  return;
}


x86 assembly (clang, -O0):
<ecn_mul>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x38,%rsp
mov    0x38(%rbp),%eax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    0x20(%rbp),%edi
mov    $0xffffffff,%esi
call   10b0 <mpz_cmp_si@plt>
cmp    $0x0,%rax
jne    1201 <ecn_mul+0x61>
mov    -0x18(%rbp),%edi
mov    0x30(%rbp),%esi
call   1040 <mpz_set@plt>
mov    -0x1c(%rbp),%edi
mov    0x38(%rbp),%esi
call   1040 <mpz_set@plt>
jmp    1399 <ecn_mul+0x1f9>
mov    0x30(%rbp),%edi
mov    $0xffffffff,%esi
call   10b0 <mpz_cmp_si@plt>
cmp    $0x0,%rax
jne    1233 <ecn_mul+0x93>
mov    -0x18(%rbp),%edi
mov    0x20(%rbp),%esi
call   1040 <mpz_set@plt>
mov    -0x1c(%rbp),%edi
mov    0x28(%rbp),%esi
call   1040 <mpz_set@plt>
jmp    1399 <ecn_mul+0x1f9>
mov    -0xc(%rbp),%edi
mov    0x28(%rbp),%esi
mov    0x38(%rbp),%edx
call   1070 <mpz_add@plt>
mov    0x20(%rbp),%edi
mov    0x30(%rbp),%esi
call   10a0 <mpz_cmp@plt>
cmp    $0x0,%rax
jne    128a <ecn_mul+0xea>
mov    -0xc(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10a0 <mpz_cmp@plt>
cmp    $0x0,%rax
jne    128a <ecn_mul+0xea>
mov    -0x18(%rbp),%edi
mov    $0xffffffff,%esi
call   1030 <mpz_set_si@plt>
mov    -0x1c(%rbp),%edi
mov    $0xffffffff,%esi
call   1030 <mpz_set_si@plt>
jmp    1399 <ecn_mul+0x1f9>
mov    0x20(%rbp),%edi
mov    0x30(%rbp),%esi
call   10a0 <mpz_cmp@plt>
cmp    $0x0,%rax
jne    12f1 <ecn_mul+0x151>
mov    0x28(%rbp),%edi
mov    0x38(%rbp),%esi
call   10a0 <mpz_cmp@plt>
cmp    $0x0,%rax
jne    12f1 <ecn_mul+0x151>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    0x10(%rbp),%ebx
mov    0x18(%rbp),%r11d
mov    0x20(%rbp),%r10d
mov    0x30(%rbp),%eax
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1090 <ecn_square@plt>
jmp    1399 <ecn_mul+0x1f9>
mov    -0xc(%rbp),%edi
mov    0x28(%rbp),%esi
mov    0x38(%rbp),%edx
call   1050 <mpz_sub@plt>
mov    -0x10(%rbp),%edi
mov    0x20(%rbp),%esi
mov    0x30(%rbp),%edx
call   1050 <mpz_sub@plt>
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1060 <mpz_invert@plt>
mov    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1080 <mpz_mul@plt>
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1080 <mpz_mul@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    0x20(%rbp),%edx
call   1050 <mpz_sub@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    0x30(%rbp),%edx
call   1050 <mpz_sub@plt>
mov    -0x10(%rbp),%edi
mov    0x20(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <mpz_sub@plt>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1080 <mpz_mul@plt>
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    0x28(%rbp),%edx
call   1050 <mpz_sub@plt>
mov    -0x18(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%edx
call   10c0 <mpz_mod@plt>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x20(%rbp),%edx
call   10c0 <mpz_mod@plt>
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<ecn_mul>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9d,0x20(%rsp)
mov    %r8d,%r13d
mov    %ecx,%r14d
mov    %edx,0x1c(%rsp)
mov    %esi,0x18(%rsp)
mov    %edi,0x14(%rsp)
mov    0x98(%rsp),%r15d
mov    0x90(%rsp),%r12d
mov    0x88(%rsp),%ebx
mov    0x80(%rsp),%edi
mov    0x78(%rsp),%eax
mov    %rax,0x28(%rsp)
mov    0x70(%rsp),%eax
mov    %rax,0x30(%rsp)
mov    %rdi,%rbp
mov    $0xffffffff,%esi
call   10b0 <mpz_cmp_si@plt>
test   %rax,%rax
je     134e <ecn_mul+0x1ae>
mov    %r14d,0xc(%rsp)
mov    %r13d,0x10(%rsp)
mov    %r12d,%edi
mov    $0xffffffff,%esi
call   10b0 <mpz_cmp_si@plt>
test   %rax,%rax
je     1361 <ecn_mul+0x1c1>
mov    0x14(%rsp),%r14d
mov    %r14d,%edi
mov    %ebx,0x24(%rsp)
mov    %ebx,%esi
mov    %r15d,%ebx
mov    %r15d,%edx
call   1070 <mpz_add@plt>
mov    %rbp,%r15
mov    %r15d,%edi
mov    %r12d,%esi
call   10a0 <mpz_cmp@plt>
test   %rax,%rax
mov    0x20(%rsp),%r13d
jne    1270 <ecn_mul+0xd0>
mov    %r14d,%edi
mov    %r13d,%esi
call   10a0 <mpz_cmp@plt>
test   %rax,%rax
je     1385 <ecn_mul+0x1e5>
mov    %r15d,%edi
mov    %r12d,%esi
call   10a0 <mpz_cmp@plt>
test   %rax,%rax
mov    0x24(%rsp),%r14d
jne    1298 <ecn_mul+0xf8>
mov    %r14d,%edi
mov    %ebx,%esi
call   10a0 <mpz_cmp@plt>
test   %rax,%rax
je     13af <ecn_mul+0x20f>
mov    0x14(%rsp),%ebp
mov    %ebp,%edi
mov    %r14d,%esi
mov    %ebx,%edx
call   1050 <mpz_sub@plt>
mov    0x18(%rsp),%ebx
mov    %ebx,%edi
mov    %r15d,%esi
mov    %r12d,%edx
call   1050 <mpz_sub@plt>
mov    %ebx,%edi
mov    %ebx,%esi
mov    %r13d,%edx
call   1060 <mpz_invert@plt>
mov    %r12,%r13
mov    0x1c(%rsp),%r12d
mov    %r12d,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1080 <mpz_mul@plt>
mov    %ebp,%edi
mov    %r12d,%esi
mov    %r12d,%edx
call   1080 <mpz_mul@plt>
mov    %ebp,%edi
mov    %ebp,%esi
mov    %r15d,%edx
call   1050 <mpz_sub@plt>
mov    %ebp,%edi
mov    %ebp,%esi
mov    %r13d,%edx
call   1050 <mpz_sub@plt>
mov    %ebx,%edi
mov    %r15d,%esi
mov    %ebp,%edx
call   1050 <mpz_sub@plt>
mov    %ebx,%edi
mov    %r12d,%esi
mov    %ebx,%edx
call   1080 <mpz_mul@plt>
mov    %ebx,%edi
mov    %ebx,%esi
mov    %r14d,%edx
call   1050 <mpz_sub@plt>
mov    0xc(%rsp),%edi
mov    %ebp,%esi
mov    0x20(%rsp),%ebp
mov    %ebp,%edx
call   10c0 <mpz_mod@plt>
mov    0x10(%rsp),%edi
mov    %ebx,%esi
mov    %ebp,%edx
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10c0 <mpz_mod@plt>
mov    %r14d,%edi
mov    %r12d,%esi
call   1040 <mpz_set@plt>
mov    %r13d,%edi
mov    %r15d,%esi
jmp    1372 <ecn_mul+0x1d2>
mov    0xc(%rsp),%edi
mov    %ebp,%esi
call   1040 <mpz_set@plt>
mov    0x10(%rsp),%edi
mov    %ebx,%esi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <mpz_set@plt>
mov    0xc(%rsp),%edi
mov    $0xffffffff,%esi
call   1030 <mpz_set_si@plt>
mov    0x10(%rsp),%edi
mov    $0xffffffff,%esi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <mpz_set_si@plt>
mov    0x14(%rsp),%edi
mov    0x18(%rsp),%esi
mov    0x1c(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    0x10(%rsp),%r8d
mov    %r13d,%r9d
push   %r12
push   %r15
push   0x38(%rsp)
push   0x48(%rsp)
call   1090 <ecn_square@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ecn_mul(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11) {
%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* %13
store i32 %1, i32* %14
store i32 %2, i32* %15
store i32 %3, i32* %16
store i32 %4, i32* %17
store i32 %5, i32* %18
store i32 %6, i32* %19
store i32 %7, i32* %20
store i32 %8, i32* %21
store i32 %9, i32* %22
store i32 %10, i32* %23
store i32 %11, i32* %24
%25 = load i32, i32* %21
%26 = call i64 @mpz_cmp_si(i32 %25, i32 -1)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %12
%29 = load i32, i32* %16
%30 = load i32, i32* %23
%31 = call i32 @mpz_set(i32 %29, i32 %30)
%32 = load i32, i32* %17
%33 = load i32, i32* %24
%34 = call i32 @mpz_set(i32 %32, i32 %33)
br label %136
35: ; preds = %12
%36 = load i32, i32* %23
%37 = call i64 @mpz_cmp_si(i32 %36, i32 -1)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %46
39: ; preds = %35
%40 = load i32, i32* %16
%41 = load i32, i32* %21
%42 = call i32 @mpz_set(i32 %40, i32 %41)
%43 = load i32, i32* %17
%44 = load i32, i32* %22
%45 = call i32 @mpz_set(i32 %43, i32 %44)
br label %136
46: ; preds = %35
%47 = load i32, i32* %13
%48 = load i32, i32* %22
%49 = load i32, i32* %24
%50 = call i32 @mpz_add(i32 %47, i32 %48, i32 %49)
%51 = load i32, i32* %21
%52 = load i32, i32* %23
%53 = call i64 @mpz_cmp(i32 %51, i32 %52)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %65
55: ; preds = %46
%56 = load i32, i32* %13
%57 = load i32, i32* %18
%58 = call i64 @mpz_cmp(i32 %56, i32 %57)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %65
60: ; preds = %55
%61 = load i32, i32* %16
%62 = call i32 @mpz_set_si(i32 %61, i32 -1)
%63 = load i32, i32* %17
%64 = call i32 @mpz_set_si(i32 %63, i32 -1)
br label %136
65: ; preds = %55, %46
%66 = load i32, i32* %21
%67 = load i32, i32* %23
%68 = call i64 @mpz_cmp(i32 %66, i32 %67)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %87
70: ; preds = %65
%71 = load i32, i32* %22
%72 = load i32, i32* %24
%73 = call i64 @mpz_cmp(i32 %71, i32 %72)
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %87
75: ; preds = %70
%76 = load i32, i32* %13
%77 = load i32, i32* %14
%78 = load i32, i32* %15
%79 = load i32, i32* %16
%80 = load i32, i32* %17
%81 = load i32, i32* %18
%82 = load i32, i32* %19
%83 = load i32, i32* %20
%84 = load i32, i32* %21
%85 = load i32, i32* %23
%86 = call i32 @ecn_square(i32 %76, i32 %77, i32 %78, i32 %79, i32 %80, i32 %81, i32 %82, i32 %83, i32 %84, i32 %85)
br label %136
87: ; preds = %70, %65
%88 = load i32, i32* %13
%89 = load i32, i32* %22
%90 = load i32, i32* %24
%91 = call i32 @mpz_sub(i32 %88, i32 %89, i32 %90)
%92 = load i32, i32* %14
%93 = load i32, i32* %21
%94 = load i32, i32* %23
%95 = call i32 @mpz_sub(i32 %92, i32 %93, i32 %94)
%96 = load i32, i32* %14
%97 = load i32, i32* %14
%98 = load i32, i32* %18
%99 = call i32 @mpz_invert(i32 %96, i32 %97, i32 %98)
%100 = load i32, i32* %15
%101 = load i32, i32* %13
%102 = load i32, i32* %14
%103 = call i32 @mpz_mul(i32 %100, i32 %101, i32 %102)
%104 = load i32, i32* %13
%105 = load i32, i32* %15
%106 = load i32, i32* %15
%107 = call i32 @mpz_mul(i32 %104, i32 %105, i32 %106)
%108 = load i32, i32* %13
%109 = load i32, i32* %13
%110 = load i32, i32* %21
%111 = call i32 @mpz_sub(i32 %108, i32 %109, i32 %110)
%112 = load i32, i32* %13
%113 = load i32, i32* %13
%114 = load i32, i32* %23
%115 = call i32 @mpz_sub(i32 %112, i32 %113, i32 %114)
%116 = load i32, i32* %14
%117 = load i32, i32* %21
%118 = load i32, i32* %13
%119 = call i32 @mpz_sub(i32 %116, i32 %117, i32 %118)
%120 = load i32, i32* %14
%121 = load i32, i32* %15
%122 = load i32, i32* %14
%123 = call i32 @mpz_mul(i32 %120, i32 %121, i32 %122)
%124 = load i32, i32* %14
%125 = load i32, i32* %14
%126 = load i32, i32* %22
%127 = call i32 @mpz_sub(i32 %124, i32 %125, i32 %126)
%128 = load i32, i32* %16
%129 = load i32, i32* %13
%130 = load i32, i32* %18
%131 = call i32 @mpz_mod(i32 %128, i32 %129, i32 %130)
%132 = load i32, i32* %17
%133 = load i32, i32* %14
%134 = load i32, i32* %18
%135 = call i32 @mpz_mod(i32 %132, i32 %133, i32 %134)
br label %136
136: ; preds = %87, %75, %60, %39, %28
ret void
}

LLVM IR (-O2):
define void @ecn_mul(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11) {
%13 = tail call i64 @mpz_cmp_si(i32 %8, i32 -1)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = tail call i32 @mpz_set(i32 %3, i32 %10)
%17 = tail call i32 @mpz_set(i32 %4, i32 %11)
br label %55
18: ; preds = %12
%19 = tail call i64 @mpz_cmp_si(i32 %10, i32 -1)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = tail call i32 @mpz_set(i32 %3, i32 %8)
%23 = tail call i32 @mpz_set(i32 %4, i32 %9)
br label %55
24: ; preds = %18
%25 = tail call i32 @mpz_add(i32 %0, i32 %9, i32 %11)
%26 = tail call i64 @mpz_cmp(i32 %8, i32 %10)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %24
%29 = tail call i64 @mpz_cmp(i32 %0, i32 %5)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = tail call i32 @mpz_set_si(i32 %3, i32 -1)
%33 = tail call i32 @mpz_set_si(i32 %4, i32 -1)
br label %55
34: ; preds = %28, %24
%35 = tail call i64 @mpz_cmp(i32 %8, i32 %10)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = tail call i64 @mpz_cmp(i32 %9, i32 %11)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = tail call i32 @ecn_square(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %10)
br label %55
42: ; preds = %37, %34
%43 = tail call i32 @mpz_sub(i32 %0, i32 %9, i32 %11)
%44 = tail call i32 @mpz_sub(i32 %1, i32 %8, i32 %10)
%45 = tail call i32 @mpz_invert(i32 %1, i32 %1, i32 %5)
%46 = tail call i32 @mpz_mul(i32 %2, i32 %0, i32 %1)
%47 = tail call i32 @mpz_mul(i32 %0, i32 %2, i32 %2)
%48 = tail call i32 @mpz_sub(i32 %0, i32 %0, i32 %8)
%49 = tail call i32 @mpz_sub(i32 %0, i32 %0, i32 %10)
%50 = tail call i32 @mpz_sub(i32 %1, i32 %8, i32 %0)
%51 = tail call i32 @mpz_mul(i32 %1, i32 %2, i32 %1)
%52 = tail call i32 @mpz_sub(i32 %1, i32 %1, i32 %9)
%53 = tail call i32 @mpz_mod(i32 %3, i32 %0, i32 %5)
%54 = tail call i32 @mpz_mod(i32 %4, i32 %1, i32 %5)
br label %55
55: ; preds = %42, %40, %31, %21, %15
ret void
}