#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 */

/* Variables and functions */
int /*<<< orphan*/ isPrimeNumber(unsigned long);
int /*<<< orphan*/ printf(char *, unsigned long, unsigned long);
unsigned long strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  unsigned long int argument = strtoul(argv[1], NULL, 10), n = argument;
  while (!isPrimeNumber(++n))
    ;
  printf("Prime number greater than %lu is %lu\n", argument, n);
  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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    %rdi,-0x20(%rbp)
call   1030 <isPrimeNumber@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118e <main+0x5e>
jmp    1193 <main+0x63>
jmp    1168 <main+0x38>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %rax,%r14
mov    %rax,%rbx
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %rbx,%rdi
call   1030 <isPrimeNumber@plt>
test   %eax,%eax
je     1150 <main+0x20>
lea    0xe99(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Prime number greater than %lu is %lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i64 @strtoul(i8* %10, i32* null, i32 10)
store i64 %11, i64* %6
%12 = load i64, i64* %6
store i64 %12, i64* %7
br label %13
13: ; preds = %19, %2
%14 = load i64, i64* %7
%15 = add i64 %14, 1
store i64 %15, i64* %7
%16 = call i32 @isPrimeNumber(i64 %15)
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
br i1 %18, label %19, label %20
19: ; preds = %13
br label %13
20: ; preds = %13
%21 = load i64, i64* %6
%22 = load i64, i64* %7
%23 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i64 %21, i64 %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"Prime number greater than %lu is %lu\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i64 @strtoul(i8* nocapture %4, i32* null, i32 10)
br label %6
6: ; preds = %6, %2
%7 = phi i64 [ %5, %2 ], [ %8, %6 ]
%8 = add i64 %7, 1
%9 = tail call i32 @isPrimeNumber(i64 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %6, label %11
11: ; preds = %6
%12 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i64 %5, i64 %8)
ret i32 0
}