#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*/ GenerateRandomPrime(int);
int atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("Usage: %s <number of bytes in the desired prime>\n", argv[0]);
    printf("For example %s 8\n", argv[0]);
    return 1;
  }
  int num_bytes = atoi(argv[1]);
  if (num_bytes < 1 || num_bytes > 30) {
    printf("Invalid number of bytes (%i) must be between 1 and %i\n", num_bytes,
           30);
    return 1;
  }
  srand(time(0));
  GenerateRandomPrime(num_bytes);
  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    11a6 <main+0x56>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1209 <main+0xb9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jl     11ca <main+0x7a>
cmpl   $0x1e,-0x14(%rbp)
jle    11ec <main+0x9c>
mov    -0x14(%rbp),%esi
lea    0xe70(%rip),%rdi
mov    $0x1e,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1209 <main+0xb9>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    -0x14(%rbp),%edi
call   1040 <GenerateRandomPrime@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1184 <main+0x34>
mov    (%rbx),%rsi
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rbx),%rsi
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
jmp    11ca <main+0x7a>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
add    $0xffffffe1,%eax
cmp    $0xffffffe1,%eax
ja     11b3 <main+0x63>
lea    0xea6(%rip),%rdi
mov    %ebx,%esi
mov    $0x1e,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
jmp    11ca <main+0x7a>
xor    %ebp,%ebp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    %ebx,%edi
call   1040 <GenerateRandomPrime@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [50 x i8] c"Usage: %s <number of bytes in the desired prime>\0A\00"
@.str.1 = [18 x i8] c"For example %s 8\0A\00"
@.str.2 = [55 x i8] c"Invalid number of bytes (%i) must be between 1 and %i\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 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 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 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %16)
store i32 1, i32* %3
br label %36
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = icmp slt i32 %23, 1
br i1 %24, label %28, label %25
25: ; preds = %18
%26 = load i32, i32* %6
%27 = icmp sgt i32 %26, 30
br i1 %27, label %28, label %31
28: ; preds = %25, %18
%29 = load i32, i32* %6
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 30)
store i32 1, i32* %3
br label %36
31: ; preds = %25
%32 = call i32 @time(i32 0)
%33 = call i32 @srand(i32 %32)
%34 = load i32, i32* %6
%35 = call i32 @GenerateRandomPrime(i32 %34)
store i32 0, i32* %3
br label %36
36: ; preds = %31, %28, %9
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [50 x i8] c"Usage: %s <number of bytes in the desired prime>\0A\00"
@.str.1 = [18 x i8] c"For example %s 8\0A\00"
@.str.2 = [55 x i8] c"Invalid number of bytes (%i) must be between 1 and %i\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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %21
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = add i32 %12, -31
%14 = icmp ult i32 %13, -30
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 30)
br label %21
17: ; preds = %9
%18 = tail call i32 @time(i32 0)
%19 = tail call i32 @srand(i32 %18)
%20 = tail call i32 @GenerateRandomPrime(i32 %12)
br label %21
21: ; preds = %15, %17, %4
%22 = phi i32 [ 1, %4 ], [ 1, %15 ], [ 0, %17 ]
ret i32 %22
}