#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*/ uint64_t;
typedef int /*<<< orphan*/ uint32_t;
typedef int /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
scalar_t__ mpz_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mul_uint64(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_uint128(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ mpz_set_uint64(int /*<<< orphan*/, int /*<<< orphan*/);
bool good_mul(uint32_t a[4], uint64_t x, uint64_t y) {
  mpz_t p, q;
  bool eq;
  mpz_init(p);
  mpz_init(q);
  mpz_set_uint64(p, x);
  mpz_mul_uint64(p, y);
  mpz_set_uint128(q, a);
  eq = (mpz_cmp(p, q) == 0);
  mpz_clear(q);
  mpz_clear(p);
  return eq;
}


x86 assembly (clang, -O0):
<good_mul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <mpz_init@plt>
mov    -0x18(%rbp),%edi
call   1060 <mpz_init@plt>
mov    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <mpz_set_uint64@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <mpz_mul_uint64@plt>
mov    -0x18(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <mpz_set_uint128@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1070 <mpz_cmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
call   1080 <mpz_clear@plt>
mov    -0x14(%rbp),%edi
call   1080 <mpz_clear@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<good_mul>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r14
call   1060 <mpz_init@plt>
call   1060 <mpz_init@plt>
mov    %ebp,%esi
call   1050 <mpz_set_uint64@plt>
mov    %ebx,%esi
call   1040 <mpz_mul_uint64@plt>
mov    %r14,%rsi
call   1030 <mpz_set_uint128@plt>
call   1070 <mpz_cmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
call   1080 <mpz_clear@plt>
call   1080 <mpz_clear@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @good_mul(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %7
%11 = call i32 @mpz_init(i32 %10)
%12 = load i32, i32* %8
%13 = call i32 @mpz_init(i32 %12)
%14 = load i32, i32* %7
%15 = load i32, i32* %5
%16 = call i32 @mpz_set_uint64(i32 %14, i32 %15)
%17 = load i32, i32* %7
%18 = load i32, i32* %6
%19 = call i32 @mpz_mul_uint64(i32 %17, i32 %18)
%20 = load i32, i32* %8
%21 = load i32*, i32** %4
%22 = call i32 @mpz_set_uint128(i32 %20, i32* %21)
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = call i64 @mpz_cmp(i32 %23, i32 %24)
%26 = icmp eq i64 %25, 0
%27 = zext i1 %26 to i32
store i32 %27, i32* %9
%28 = load i32, i32* %8
%29 = call i32 @mpz_clear(i32 %28)
%30 = load i32, i32* %7
%31 = call i32 @mpz_clear(i32 %30)
%32 = load i32, i32* %9
ret i32 %32
}

LLVM IR (-O2):
define i32 @good_mul(i32* %0, i32 %1, i32 %2) {
%4 = tail call i32 @mpz_init(i32 undef)
%5 = tail call i32 @mpz_init(i32 undef)
%6 = tail call i32 @mpz_set_uint64(i32 undef, i32 %1)
%7 = tail call i32 @mpz_mul_uint64(i32 undef, i32 %2)
%8 = tail call i32 @mpz_set_uint128(i32 undef, i32* %0)
%9 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = tail call i32 @mpz_clear(i32 undef)
%13 = tail call i32 @mpz_clear(i32 undef)
ret i32 %11
}