#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ goldbach_mode(unsigned long, unsigned long);
int /*<<< orphan*/ primes_mode(unsigned long, unsigned long);
int /*<<< orphan*/ srand48(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
unsigned long strtoul(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int goldbach = 0;
  unsigned long start, stop;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s [-g] min max\n", argv[0]);
    return 1;
  }
  if (!strcmp(argv[1], "-g")) {
    goldbach = 1;
    if (argc < 4) {
      fputs("Invalid arguments.\n", stderr);
      return 1;
    }
    start = strtoul(argv[2], NULL, 0);
    stop = strtoul(argv[3], NULL, 0);
  } else {
    if (argc < 3) {
      fputs("Invalid arguments.\n", stderr);
      return 1;
    }
    start = strtoul(argv[1], NULL, 0);
    stop = strtoul(argv[2], NULL, 0);
  }
  if (start >= stop) {
    fputs("Invalid range.\n", stderr);
    return 1;
  }
  srand48(time(NULL));
  if (goldbach) {
    goldbach_mode(start, stop);
  } else {
    primes_mode(start, stop);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11cf <main+0x4f>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe42(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1319 <main+0x199>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1251 <main+0xd1>
movl   $0x1,-0x14(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    121e <main+0x9e>
mov    0x2ddc(%rip),%rax
mov    (%rax),%esi
lea    0xe0e(%rip),%rdi
call   1030 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    1319 <main+0x199>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <strtoul@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <strtoul@plt>
mov    %rax,-0x28(%rbp)
jmp    12aa <main+0x12a>
cmpl   $0x3,-0x8(%rbp)
jge    127c <main+0xfc>
mov    0x2d7e(%rip),%rax
mov    (%rax),%esi
lea    0xdb0(%rip),%rdi
call   1030 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    1319 <main+0x199>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <strtoul@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <strtoul@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jb     12d9 <main+0x159>
mov    0x2d21(%rip),%rax
mov    (%rax),%esi
lea    0xd67(%rip),%rdi
call   1030 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    1319 <main+0x199>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1090 <srand48@plt>
cmpl   $0x0,-0x14(%rbp)
je     1305 <main+0x185>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <goldbach_mode@plt>
jmp    1312 <main+0x192>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <primes_mode@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     11ad <main+0x2d>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe5d(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1252 <main+0xd2>
mov    %edi,%ebp
mov    0x8(%rbx),%r14
lea    0xe5e(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
mov    %eax,%r15d
test   %eax,%eax
je     11d6 <main+0x56>
mov    $0x2,%r12d
cmp    $0x2,%ebp
jbe    11db <main+0x5b>
jmp    11f7 <main+0x77>
cmp    $0x3,%ebp
ja     11ed <main+0x6d>
mov    0x2dfe(%rip),%rax
mov    (%rax),%esi
lea    0xe30(%rip),%rdi
jmp    124d <main+0xcd>
mov    0x10(%rbx),%r14
mov    $0x3,%r12d
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <strtoul@plt>
mov    %rax,%r14
mov    (%rbx,%r12,8),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <strtoul@plt>
cmp    %rax,%r14
jae    123d <main+0xbd>
mov    %rax,%rbp
xor    %ebx,%ebx
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1090 <srand48@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
test   %r15d,%r15d
je     1262 <main+0xe2>
call   1080 <primes_mode@plt>
jmp    1257 <main+0xd7>
mov    0x2d9c(%rip),%rax
mov    (%rax),%esi
lea    0xde2(%rip),%rdi
call   1030 <fputs@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
call   1050 <goldbach_mode@plt>
jmp    1257 <main+0xd7>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s [-g] min max\0A\00"
@.str.1 = [3 x i8] c"-g\00"
@.str.2 = [20 x i8] c"Invalid arguments.\0A\00"
@.str.3 = [16 x i8] c"Invalid range.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %74
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %38, label %23
23: ; preds = %17
store i32 1, i32* %6
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 4
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* @stderr
%28 = call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %27)
store i32 1, i32* %3
br label %74
29: ; preds = %23
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i64 @strtoul(i8* %32, i32* null, i32 0)
store i64 %33, i64* %7
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 3
%36 = load i8*, i8** %35
%37 = call i64 @strtoul(i8* %36, i32* null, i32 0)
store i64 %37, i64* %8
br label %53
38: ; preds = %17
%39 = load i32, i32* %4
%40 = icmp slt i32 %39, 3
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* @stderr
%43 = call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %42)
store i32 1, i32* %3
br label %74
44: ; preds = %38
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i64 @strtoul(i8* %47, i32* null, i32 0)
store i64 %48, i64* %7
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i64 @strtoul(i8* %51, i32* null, i32 0)
store i64 %52, i64* %8
br label %53
53: ; preds = %44, %29
%54 = load i64, i64* %7
%55 = load i64, i64* %8
%56 = icmp uge i64 %54, %55
br i1 %56, label %57, label %60
57: ; preds = %53
%58 = load i32, i32* @stderr
%59 = call i32 @fputs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %58)
store i32 1, i32* %3
br label %74
60: ; preds = %53
%61 = call i32 @time(i32* null)
%62 = call i32 @srand48(i32 %61)
%63 = load i32, i32* %6
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %69
65: ; preds = %60
%66 = load i64, i64* %7
%67 = load i64, i64* %8
%68 = call i32 @goldbach_mode(i64 %66, i64 %67)
br label %73
69: ; preds = %60
%70 = load i64, i64* %7
%71 = load i64, i64* %8
%72 = call i32 @primes_mode(i64 %70, i64 %71)
br label %73
73: ; preds = %69, %65
store i32 0, i32* %3
br label %74
74: ; preds = %73, %57, %41, %26, %11
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Usage: %s [-g] min max\0A\00"
@.str.1 = [3 x i8] c"-g\00"
@.str.2 = [20 x i8] c"Invalid arguments.\0A\00"
@.str.3 = [16 x i8] c"Invalid range.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %44
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = icmp ult i32 %0, 4
br i1 %14, label %15, label %18
15: ; preds = %13
%16 = load i32, i32* @stderr
%17 = tail call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %44
18: ; preds = %13
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
br label %26
21: ; preds = %8
%22 = icmp ult i32 %0, 3
br i1 %22, label %23, label %26
23: ; preds = %21
%24 = load i32, i32* @stderr
%25 = tail call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %44
26: ; preds = %21, %18
%27 = phi i8* [ %20, %18 ], [ %10, %21 ]
%28 = phi i64 [ 3, %18 ], [ 2, %21 ]
%29 = tail call i64 @strtoul(i8* nocapture %27, i32* null, i32 0)
%30 = getelementptr inbounds i8*, i8** %1, i64 %28
%31 = load i8*, i8** %30
%32 = tail call i64 @strtoul(i8* nocapture %31, i32* null, i32 0)
%33 = icmp ult i64 %29, %32
br i1 %33, label %37, label %34
34: ; preds = %26
%35 = load i32, i32* @stderr
%36 = tail call i32 @fputs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %35)
br label %44
37: ; preds = %26
%38 = tail call i32 @time(i32* null)
%39 = tail call i32 @srand48(i32 %38)
br i1 %12, label %40, label %42
40: ; preds = %37
%41 = tail call i32 @goldbach_mode(i64 %29, i64 %32)
br label %44
42: ; preds = %37
%43 = tail call i32 @primes_mode(i64 %29, i64 %32)
br label %44
44: ; preds = %40, %42, %34, %23, %15, %4
%45 = phi i32 [ 1, %4 ], [ 1, %23 ], [ 1, %34 ], [ 1, %15 ], [ 0, %42 ], [ 0, %40 ]
ret i32 %45
}