#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_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_and(int /*<<< orphan*/, int /*<<< orphan*/ const,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_clears(int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/ *);
scalar_t__ mpz_cmp_ui(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init_set(int /*<<< orphan*/, int /*<<< orphan*/ const);
int isMersenne(const mpz_t num) {
  mpz_t mnum;
  mpz_init_set(mnum, num);
  mpz_add_ui(mnum, mnum, 1);
  mpz_t result;
  mpz_init(result);
  mpz_and(result, num, mnum);
  int rc = 0;
  if (mpz_cmp_ui(result, 0) == 0)
    rc = 1;
  mpz_clears(mnum, result, NULL);
  return rc;
}


x86 assembly (clang, -O0):
<isMersenne>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1070 <mpz_init_set@plt>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x1,%edx
call   1030 <mpz_add_ui@plt>
mov    -0xc(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0xc(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1080 <mpz_and@plt>
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1060 <mpz_cmp_ui@plt>
cmp    $0x0,%rax
jne    11be <isMersenne+0x5e>
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <mpz_clears@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isMersenne>:
push   %rbx
mov    %edi,%ebx
mov    %edi,%esi
call   1070 <mpz_init_set@plt>
mov    $0x1,%edx
call   1030 <mpz_add_ui@plt>
call   1050 <mpz_init@plt>
mov    %ebx,%esi
call   1080 <mpz_and@plt>
xor    %esi,%esi
call   1060 <mpz_cmp_ui@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
xor    %edx,%edx
call   1040 <mpz_clears@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @isMersenne(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = call i32 @mpz_init_set(i32 %6, i32 %7)
%9 = load i32, i32* %3
%10 = load i32, i32* %3
%11 = call i32 @mpz_add_ui(i32 %9, i32 %10, i32 1)
%12 = load i32, i32* %4
%13 = call i32 @mpz_init(i32 %12)
%14 = load i32, i32* %4
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = call i32 @mpz_and(i32 %14, i32 %15, i32 %16)
store i32 0, i32* %5
%18 = load i32, i32* %4
%19 = call i64 @mpz_cmp_ui(i32 %18, i32 0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %1
store i32 1, i32* %5
br label %22
22: ; preds = %21, %1
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = call i32 @mpz_clears(i32 %23, i32 %24, i32* null)
%26 = load i32, i32* %5
ret i32 %26
}

LLVM IR (-O2):
define i32 @isMersenne(i32 %0) {
%2 = tail call i32 @mpz_init_set(i32 undef, i32 %0)
%3 = tail call i32 @mpz_add_ui(i32 undef, i32 undef, i32 1)
%4 = tail call i32 @mpz_init(i32 undef)
%5 = tail call i32 @mpz_and(i32 undef, i32 %0, i32 undef)
%6 = tail call i64 @mpz_cmp_ui(i32 undef, i32 0)
%7 = icmp eq i64 %6, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @mpz_clears(i32 undef, i32 undef, i32* null)
ret i32 %8
}