#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*/ mpz_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
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*/);
void CRTTwo(mpz_t res, mpz_t s1, mpz_t p, mpz_t s2, mpz_t q, mpz_t n) {
  mpz_t p_inv, q_inv, tmp;
  mpz_init(p_inv);
  mpz_init(q_inv);
  mpz_init(tmp);
  mpz_invert(p_inv, p, q);
  mpz_invert(q_inv, q, p);
  mpz_set(res, s1);
  mpz_mul(res, res, q);
  mpz_mul(res, res, q_inv);
  mpz_set(tmp, s2);
  mpz_mul(tmp, tmp, p);
  mpz_mul(tmp, tmp, p_inv);
  mpz_add(res, res, tmp);
  mpz_mod(res, res, n);
  mpz_clear(tmp);
  mpz_clear(p_inv);
  mpz_clear(q_inv);
}


x86 assembly (clang, -O0):
<CRTTwo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x20(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x24(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x1c(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <mpz_invert@plt>
mov    -0x20(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <mpz_invert@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <mpz_set@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1070 <mpz_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1070 <mpz_mul@plt>
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <mpz_set@plt>
mov    -0x24(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1070 <mpz_mul@plt>
mov    -0x24(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1070 <mpz_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1060 <mpz_add@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1080 <mpz_mod@plt>
mov    -0x24(%rbp),%edi
call   1090 <mpz_clear@plt>
mov    -0x1c(%rbp),%edi
call   1090 <mpz_clear@plt>
mov    -0x20(%rbp),%edi
call   1090 <mpz_clear@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CRTTwo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%ebx
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%r13d
mov    %edi,%ebp
call   1050 <mpz_init@plt>
call   1050 <mpz_init@plt>
call   1050 <mpz_init@plt>
mov    %r12d,%esi
mov    %ebx,%edx
call   1040 <mpz_invert@plt>
mov    %ebx,%esi
mov    %r12d,%edx
call   1040 <mpz_invert@plt>
mov    %ebp,%edi
mov    %r13d,%esi
call   1030 <mpz_set@plt>
mov    %ebp,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1070 <mpz_mul@plt>
mov    %ebp,%edi
mov    %ebp,%esi
call   1070 <mpz_mul@plt>
mov    %r15d,%esi
call   1030 <mpz_set@plt>
mov    %r12d,%edx
call   1070 <mpz_mul@plt>
call   1070 <mpz_mul@plt>
mov    %ebp,%edi
mov    %ebp,%esi
call   1060 <mpz_add@plt>
mov    %ebp,%edi
mov    %ebp,%esi
mov    %r14d,%edx
call   1080 <mpz_mod@plt>
call   1090 <mpz_clear@plt>
call   1090 <mpz_clear@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <mpz_clear@plt>

LLVM IR (-O0):
define void @CRTTwo(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 = load i32, i32* %13
%17 = call i32 @mpz_init(i32 %16)
%18 = load i32, i32* %14
%19 = call i32 @mpz_init(i32 %18)
%20 = load i32, i32* %15
%21 = call i32 @mpz_init(i32 %20)
%22 = load i32, i32* %13
%23 = load i32, i32* %9
%24 = load i32, i32* %11
%25 = call i32 @mpz_invert(i32 %22, i32 %23, i32 %24)
%26 = load i32, i32* %14
%27 = load i32, i32* %11
%28 = load i32, i32* %9
%29 = call i32 @mpz_invert(i32 %26, i32 %27, i32 %28)
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = call i32 @mpz_set(i32 %30, i32 %31)
%33 = load i32, i32* %7
%34 = load i32, i32* %7
%35 = load i32, i32* %11
%36 = call i32 @mpz_mul(i32 %33, i32 %34, i32 %35)
%37 = load i32, i32* %7
%38 = load i32, i32* %7
%39 = load i32, i32* %14
%40 = call i32 @mpz_mul(i32 %37, i32 %38, i32 %39)
%41 = load i32, i32* %15
%42 = load i32, i32* %10
%43 = call i32 @mpz_set(i32 %41, i32 %42)
%44 = load i32, i32* %15
%45 = load i32, i32* %15
%46 = load i32, i32* %9
%47 = call i32 @mpz_mul(i32 %44, i32 %45, i32 %46)
%48 = load i32, i32* %15
%49 = load i32, i32* %15
%50 = load i32, i32* %13
%51 = call i32 @mpz_mul(i32 %48, i32 %49, i32 %50)
%52 = load i32, i32* %7
%53 = load i32, i32* %7
%54 = load i32, i32* %15
%55 = call i32 @mpz_add(i32 %52, i32 %53, i32 %54)
%56 = load i32, i32* %7
%57 = load i32, i32* %7
%58 = load i32, i32* %12
%59 = call i32 @mpz_mod(i32 %56, i32 %57, i32 %58)
%60 = load i32, i32* %15
%61 = call i32 @mpz_clear(i32 %60)
%62 = load i32, i32* %13
%63 = call i32 @mpz_clear(i32 %62)
%64 = load i32, i32* %14
%65 = call i32 @mpz_clear(i32 %64)
ret void
}

LLVM IR (-O2):
define void @CRTTwo(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = tail call i32 @mpz_init(i32 undef)
%8 = tail call i32 @mpz_init(i32 undef)
%9 = tail call i32 @mpz_init(i32 undef)
%10 = tail call i32 @mpz_invert(i32 undef, i32 %2, i32 %4)
%11 = tail call i32 @mpz_invert(i32 undef, i32 %4, i32 %2)
%12 = tail call i32 @mpz_set(i32 %0, i32 %1)
%13 = tail call i32 @mpz_mul(i32 %0, i32 %0, i32 %4)
%14 = tail call i32 @mpz_mul(i32 %0, i32 %0, i32 undef)
%15 = tail call i32 @mpz_set(i32 undef, i32 %3)
%16 = tail call i32 @mpz_mul(i32 undef, i32 undef, i32 %2)
%17 = tail call i32 @mpz_mul(i32 undef, i32 undef, i32 undef)
%18 = tail call i32 @mpz_add(i32 %0, i32 %0, i32 undef)
%19 = tail call i32 @mpz_mod(i32 %0, i32 %0, i32 %5)
%20 = tail call i32 @mpz_clear(i32 undef)
%21 = tail call i32 @mpz_clear(i32 undef)
%22 = tail call i32 @mpz_clear(i32 undef)
ret void
}