#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_out_str(int /*<<< orphan*/, int, int /*<<< orphan*/);
scalar_t__ mpz_probab_prime_p(int /*<<< orphan*/, int);
size_t mpz_sizeinbase(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
scalar_t__ trial_div(int /*<<< orphan*/);
void number_checks(mpz_t n, size_t bits, size_t offset) {
  if (mpz_sizeinbase(n, 2) > (bits - 2)) {
    if (mpz_probab_prime_p(n, 20) > 0) {
      printf("Prime of %zd bits found at offset 0x%zx : ", mpz_sizeinbase(n, 2),
             offset);
      mpz_out_str(stdout, 16, n);
      printf("\n");
    } else {
      if (trial_div(n) == 0) {
        return;
      }
      printf("Potential modulus of %zd bits found at offset 0x%zx : ",
             mpz_sizeinbase(n, 2), offset);
      mpz_out_str(stdout, 16, n);
      printf("\n");
    }
  }
  return;
}


x86 assembly (clang, -O0):
<number_checks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1060 <mpz_sizeinbase@plt>
mov    -0x10(%rbp),%rcx
sub    $0x2,%rcx
cmp    %rcx,%rax
jbe    1245 <number_checks+0xf5>
mov    -0x4(%rbp),%edi
mov    $0x14,%esi
call   1030 <mpz_probab_prime_p@plt>
cmp    $0x0,%rax
jle    11e3 <number_checks+0x93>
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1060 <mpz_sizeinbase@plt>
mov    %rax,%rsi
mov    -0x18(%rbp),%rdx
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
mov    $0x10,%esi
call   1070 <mpz_out_str@plt>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1240 <number_checks+0xf0>
mov    -0x4(%rbp),%edi
call   1050 <trial_div@plt>
cmp    $0x0,%rax
jne    11fa <number_checks+0xaa>
jmp    124a <number_checks+0xfa>
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1060 <mpz_sizeinbase@plt>
mov    %rax,%rsi
mov    -0x18(%rbp),%rdx
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
mov    $0x10,%esi
call   1070 <mpz_out_str@plt>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1245 <number_checks+0xf5>
jmp    124a <number_checks+0xfa>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number_checks>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x2,%esi
call   1070 <mpz_sizeinbase@plt>
add    $0xfffffffffffffffe,%rbx
cmp    %rbx,%rax
jbe    11f4 <number_checks+0x94>
mov    %ebp,%edi
mov    $0x14,%esi
call   1030 <mpz_probab_prime_p@plt>
test   %rax,%rax
jle    119c <number_checks+0x3c>
lea    0xe66(%rip),%r15
jmp    11af <number_checks+0x4f>
mov    %ebp,%edi
call   1060 <trial_div@plt>
test   %rax,%rax
je     11f4 <number_checks+0x94>
lea    0xe7c(%rip),%r15
mov    %ebp,%edi
mov    $0x2,%esi
call   1070 <mpz_sizeinbase@plt>
mov    %r15,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
mov    $0x10,%esi
mov    %ebp,%edx
call   1080 <mpz_out_str@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Prime of %zd bits found at offset 0x%zx : \00"
@stdout = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [55 x i8] c"Potential modulus of %zd bits found at offset 0x%zx : \00"
define void @number_checks(i32 %0, i64 %1, i64 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
store i32 %0, i32* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%7 = load i32, i32* %4
%8 = call i64 @mpz_sizeinbase(i32 %7, i32 2)
%9 = load i64, i64* %5
%10 = sub i64 %9, 2
%11 = icmp ugt i64 %8, %10
br i1 %11, label %12, label %40
12: ; preds = %3
%13 = load i32, i32* %4
%14 = call i64 @mpz_probab_prime_p(i32 %13, i32 20)
%15 = icmp sgt i64 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = load i32, i32* %4
%18 = call i64 @mpz_sizeinbase(i32 %17, i32 2)
%19 = load i64, i64* %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i64 %18, i64 %19)
%21 = load i32, i32* @stdout
%22 = load i32, i32* %4
%23 = call i32 @mpz_out_str(i32 %21, i32 16, i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %39
25: ; preds = %12
%26 = load i32, i32* %4
%27 = call i64 @trial_div(i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
br label %41
30: ; preds = %25
%31 = load i32, i32* %4
%32 = call i64 @mpz_sizeinbase(i32 %31, i32 2)
%33 = load i64, i64* %6
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i64 %32, i64 %33)
%35 = load i32, i32* @stdout
%36 = load i32, i32* %4
%37 = call i32 @mpz_out_str(i32 %35, i32 16, i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %30, %16
br label %40
40: ; preds = %39, %3
br label %41
41: ; preds = %40, %29
ret void
}

LLVM IR (-O2):
@.str = [43 x i8] c"Prime of %zd bits found at offset 0x%zx : \00"
@stdout = global i32 0
@.str.2 = [55 x i8] c"Potential modulus of %zd bits found at offset 0x%zx : \00"
define void @number_checks(i32 %0, i64 %1, i64 %2) {
%4 = tail call i64 @mpz_sizeinbase(i32 %0, i32 2)
%5 = add i64 %1, -2
%6 = icmp ugt i64 %4, %5
br i1 %6, label %7, label %20
7: ; preds = %3
%8 = tail call i64 @mpz_probab_prime_p(i32 %0, i32 20)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i64 @trial_div(i32 %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %10, %7
%14 = phi i8* [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), %7 ], [ getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), %10 ]
%15 = tail call i64 @mpz_sizeinbase(i32 %0, i32 2)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %14, i64 %15, i64 %2)
%17 = load i32, i32* @stdout
%18 = tail call i32 @mpz_out_str(i32 %17, i32 16, i32 %0)
%19 = tail call i32 @putchar(i32 10)
br label %20
20: ; preds = %13, %3, %10
ret void
}