#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*/ assert(int);
int /*<<< orphan*/ mpz_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
scalar_t__ mpz_cmp_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_gcd(int /*<<< orphan*/, int /*<<< orphan*/,
                           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*/);
void mpz_2crt(mpz_t rop, mpz_t con1_a, mpz_t con1_m, mpz_t con2_a,
              mpz_t con2_m) {
  mpz_t t;
  mpz_init(t);
  mpz_gcd(t, con1_m, con2_m);
  assert(mpz_cmp_ui(t, 1) == 0);
  mpz_invert(rop, con2_m, con1_m);
  mpz_mul(rop, rop, con2_m);
  mpz_mul(rop, rop, con1_a);
  mpz_invert(t, con1_m, con2_m);
  mpz_mul(t, t, con1_m);
  mpz_mul(t, t, con2_a);
  mpz_add(rop, rop, t);
  mpz_mul(t, con1_m, con2_m);
  mpz_mod(rop, rop, t);
  mpz_clear(t);
}


x86 assembly (clang, -O0):
<mpz_2crt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <mpz_init@plt>
mov    -0x18(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   10b0 <mpz_gcd@plt>
mov    -0x18(%rbp),%edi
mov    $0x1,%esi
call   1080 <mpz_cmp_ui@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <mpz_invert@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    -0x8(%rbp),%edx
call   1070 <mpz_mul@plt>
mov    -0x18(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <mpz_invert@plt>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1070 <mpz_mul@plt>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1070 <mpz_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1060 <mpz_add@plt>
mov    -0x18(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1070 <mpz_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1090 <mpz_mod@plt>
mov    -0x18(%rbp),%edi
call   10a0 <mpz_clear@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpz_2crt>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %esi,%r12d
mov    %edi,%ebx
call   1040 <mpz_init@plt>
mov    %ebp,%esi
mov    %r14d,%edx
call   10b0 <mpz_gcd@plt>
mov    $0x1,%esi
call   1080 <mpz_cmp_ui@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
mov    %ebx,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1030 <mpz_invert@plt>
mov    %ebx,%edi
mov    %ebx,%esi
mov    %r14d,%edx
call   1070 <mpz_mul@plt>
mov    %ebx,%edi
mov    %ebx,%esi
mov    %r12d,%edx
call   1070 <mpz_mul@plt>
mov    %ebp,%esi
mov    %r14d,%edx
call   1030 <mpz_invert@plt>
mov    %ebp,%edx
call   1070 <mpz_mul@plt>
mov    %r15d,%edx
call   1070 <mpz_mul@plt>
mov    %ebx,%edi
mov    %ebx,%esi
call   1060 <mpz_add@plt>
mov    %ebp,%esi
mov    %r14d,%edx
call   1070 <mpz_mul@plt>
mov    %ebx,%edi
mov    %ebx,%esi
call   1090 <mpz_mod@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <mpz_clear@plt>

LLVM IR (-O0):
define void @mpz_2crt(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i32, i32* %11
%13 = call i32 @mpz_init(i32 %12)
%14 = load i32, i32* %11
%15 = load i32, i32* %8
%16 = load i32, i32* %10
%17 = call i32 @mpz_gcd(i32 %14, i32 %15, i32 %16)
%18 = load i32, i32* %11
%19 = call i64 @mpz_cmp_ui(i32 %18, i32 1)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i32, i32* %6
%24 = load i32, i32* %10
%25 = load i32, i32* %8
%26 = call i32 @mpz_invert(i32 %23, i32 %24, i32 %25)
%27 = load i32, i32* %6
%28 = load i32, i32* %6
%29 = load i32, i32* %10
%30 = call i32 @mpz_mul(i32 %27, i32 %28, i32 %29)
%31 = load i32, i32* %6
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = call i32 @mpz_mul(i32 %31, i32 %32, i32 %33)
%35 = load i32, i32* %11
%36 = load i32, i32* %8
%37 = load i32, i32* %10
%38 = call i32 @mpz_invert(i32 %35, i32 %36, i32 %37)
%39 = load i32, i32* %11
%40 = load i32, i32* %11
%41 = load i32, i32* %8
%42 = call i32 @mpz_mul(i32 %39, i32 %40, i32 %41)
%43 = load i32, i32* %11
%44 = load i32, i32* %11
%45 = load i32, i32* %9
%46 = call i32 @mpz_mul(i32 %43, i32 %44, i32 %45)
%47 = load i32, i32* %6
%48 = load i32, i32* %6
%49 = load i32, i32* %11
%50 = call i32 @mpz_add(i32 %47, i32 %48, i32 %49)
%51 = load i32, i32* %11
%52 = load i32, i32* %8
%53 = load i32, i32* %10
%54 = call i32 @mpz_mul(i32 %51, i32 %52, i32 %53)
%55 = load i32, i32* %6
%56 = load i32, i32* %6
%57 = load i32, i32* %11
%58 = call i32 @mpz_mod(i32 %55, i32 %56, i32 %57)
%59 = load i32, i32* %11
%60 = call i32 @mpz_clear(i32 %59)
ret void
}

LLVM IR (-O2):
define void @mpz_2crt(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 @mpz_init(i32 undef)
%7 = tail call i32 @mpz_gcd(i32 undef, i32 %2, i32 %4)
%8 = tail call i64 @mpz_cmp_ui(i32 undef, i32 1)
%9 = icmp eq i64 %8, 0
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = tail call i32 @mpz_invert(i32 %0, i32 %4, i32 %2)
%13 = tail call i32 @mpz_mul(i32 %0, i32 %0, i32 %4)
%14 = tail call i32 @mpz_mul(i32 %0, i32 %0, i32 %1)
%15 = tail call i32 @mpz_invert(i32 undef, i32 %2, i32 %4)
%16 = tail call i32 @mpz_mul(i32 undef, i32 undef, i32 %2)
%17 = tail call i32 @mpz_mul(i32 undef, i32 undef, i32 %3)
%18 = tail call i32 @mpz_add(i32 %0, i32 %0, i32 undef)
%19 = tail call i32 @mpz_mul(i32 undef, i32 %2, i32 %4)
%20 = tail call i32 @mpz_mod(i32 %0, i32 %0, i32 undef)
%21 = tail call i32 @mpz_clear(i32 undef)
ret void
}