#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*/ FindNearbyPrime(int /*<<< orphan*/);
char *mpz_get_str(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init_set_str(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("Usage: %s <starting number>\n", argv[0]);
    printf("For example %s 9087213\n", argv[0]);
    return 1;
  }
  mpz_t prime;
  mpz_init_set_str(prime, argv[1], 10);
  FindNearbyPrime(prime);
  printf("\nPrime:\n%s\n", mpz_get_str(NULL, 10, prime));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1192 <main+0x52>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d6 <main+0x96>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0xa,%edx
call   1040 <mpz_init_set_str@plt>
mov    -0x14(%rbp),%edi
call   1060 <FindNearbyPrime@plt>
mov    -0x14(%rbp),%edx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xa,%esi
call   1050 <mpz_get_str@plt>
mov    %rax,%rsi
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     116e <main+0x2e>
mov    (%rbx),%rsi
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
mov    (%rbx),%rsi
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%ebx
jmp    119e <main+0x5e>
mov    0x8(%rbx),%rsi
mov    $0xa,%edx
call   1040 <mpz_init_set_str@plt>
call   1060 <FindNearbyPrime@plt>
xor    %ebx,%ebx
xor    %edi,%edi
mov    $0xa,%esi
call   1050 <mpz_get_str@plt>
lea    0xe9f(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Usage: %s <starting number>\0A\00"
@.str.1 = [24 x i8] c"For example %s 9087213\0A\00"
@.str.2 = [12 x i8] c"\0APrime:\0A%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %18
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %16)
store i32 1, i32* %3
br label %29
18: ; preds = %2
%19 = load i32, i32* %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @mpz_init_set_str(i32 %19, i8* %22, i32 10)
%24 = load i32, i32* %6
%25 = call i32 @FindNearbyPrime(i32 %24)
%26 = load i32, i32* %6
%27 = call i8* @mpz_get_str(i32* null, i32 10, i32 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %27)
store i32 0, i32* %3
br label %29
29: ; preds = %18, %9
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [29 x i8] c"Usage: %s <starting number>\0A\00"
@.str.1 = [24 x i8] c"For example %s 9087213\0A\00"
@.str.2 = [12 x i8] c"\0APrime:\0A%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i8*, i8** %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %16
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @mpz_init_set_str(i32 undef, i8* %11, i32 10)
%13 = tail call i32 @FindNearbyPrime(i32 undef)
%14 = tail call i8* @mpz_get_str(i32* null, i32 10, i32 undef)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %9, %4
%17 = phi i32 [ 1, %4 ], [ 0, %9 ]
ret i32 %17
}