#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*/ array_to_file(unsigned char *, long long);
int atoi(char *);
int /*<<< orphan*/ primestofile(unsigned char *, long long);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ printprimes(unsigned char *, long long);
int scanf(char *, ...);
unsigned char *sieve_of_eratosthenes(long long);
int main(int argc, char **argv) {
  if ((argc == 2) && (atoi(argv[1]) > 2)) {
    long long number = (long long)atoi(argv[1]);
    unsigned char *condition_array;
    condition_array = sieve_of_eratosthenes(number);
    primestofile(condition_array, number);
  } else {
    if (argc == 2) {
      printf("interactive mode\nn=");
      long long number;
      int choice;
      int res = scanf("%lld", &number);
      unsigned char *condition_array;
      condition_array = sieve_of_eratosthenes(number);
      printf("1 -> print primes to a file\n2 -> print array to file\n3 -> "
             "display primes\n ?=");
      res = scanf("%d", &choice);
      switch (choice) {
      case 1:
        primestofile(condition_array, number);
        break;
      case 2:
        array_to_file(condition_array, number);
        break;
      case 3:
        printprimes(condition_array, number);
        break;
      default:
        primestofile(condition_array, number);
      }
    } else {
      printf("Use: sievee [number]\nwith number > 2\n");
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11d8 <main+0x68>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
cmp    $0x2,%eax
jle    11d8 <main+0x68>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <sieve_of_eratosthenes@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <primestofile@plt>
jmp    12c4 <main+0x154>
cmpl   $0x2,-0x8(%rbp)
jne    12b3 <main+0x143>
lea    0xe17(%rip),%rdi
call   1040 <printf@plt>
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x3d(%rbp)
lea    -0x28(%rbp),%rsi
call   1060 <scanf@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <sieve_of_eratosthenes@plt>
mov    %rax,-0x38(%rbp)
lea    0xdff(%rip),%rdi
call   1040 <printf@plt>
mov    -0x3d(%rbp),%al
lea    0xe3d(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1060 <scanf@plt>
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x1,%eax
je     126b <main+0xfb>
jmp    1249 <main+0xd9>
mov    -0x3c(%rbp),%eax
sub    $0x2,%eax
je     127d <main+0x10d>
jmp    125a <main+0xea>
mov    -0x3c(%rbp),%eax
sub    $0x3,%eax
je     128f <main+0x11f>
jmp    12a1 <main+0x131>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <primestofile@plt>
jmp    12ae <main+0x13e>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1090 <array_to_file@plt>
jmp    12ae <main+0x13e>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <printprimes@plt>
jmp    12ae <main+0x13e>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <primestofile@plt>
jmp    12bf <main+0x14f>
lea    0xdaf(%rip),%rdi
call   1040 <printf@plt>
jmp    12c4 <main+0x154>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    11af <main+0x2f>
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
cmp    $0x3,%eax
jl     11c3 <main+0x43>
mov    %eax,%ebx
mov    %rbx,%rdi
call   1060 <sieve_of_eratosthenes@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <primestofile@plt>
jmp    11bb <main+0x3b>
lea    0xeb3(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe36(%rip),%rdi
call   1050 <printf@plt>
lea    0xe3e(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    (%rsp),%rdi
call   1060 <sieve_of_eratosthenes@plt>
mov    %rax,%rbx
lea    0xe26(%rip),%rdi
call   1050 <printf@plt>
lea    0xe67(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
je     122a <main+0xaa>
cmp    $0x2,%eax
je     1238 <main+0xb8>
cmp    $0x1,%eax
mov    (%rsp),%rsi
mov    %rbx,%rdi
call   1030 <primestofile@plt>
jmp    11bb <main+0x3b>
mov    (%rsp),%rsi
mov    %rbx,%rdi
call   1090 <printprimes@plt>
jmp    11bb <main+0x3b>
mov    (%rsp),%rsi
mov    %rbx,%rdi
call   10a0 <array_to_file@plt>
jmp    11bb <main+0x3b>

LLVM IR (-O0):
@.str = [20 x i8] c"interactive mode\0An=\00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [77 x i8] c"1 -> print primes to a file\0A2 -> print array to file\0A3 -> display primes\0A ?=\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [38 x i8] c"Use: sievee [number]\0Awith number > 2\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %31
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
%19 = icmp sgt i32 %18, 2
br i1 %19, label %20, label %31
20: ; preds = %14
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
%25 = sext i32 %24 to i64
store i64 %25, i64* %6
%26 = load i64, i64* %6
%27 = call i8* @sieve_of_eratosthenes(i64 %26)
store i8* %27, i8** %7
%28 = load i8*, i8** %7
%29 = load i64, i64* %6
%30 = call i32 @primestofile(i8* %28, i64 %29)
br label %62
31: ; preds = %14, %2
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 2
br i1 %33, label %34, label %59
34: ; preds = %31
%35 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %8)
store i32 %36, i32* %10
%37 = load i64, i64* %8
%38 = call i8* @sieve_of_eratosthenes(i64 %37)
store i8* %38, i8** %11
%39 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %9)
store i32 %40, i32* %10
%41 = load i32, i32* %9
switch i32 %41, label %54 [
i32 1, label %42
i32 2, label %46
i32 3, label %50
]
42: ; preds = %34
%43 = load i8*, i8** %11
%44 = load i64, i64* %8
%45 = call i32 @primestofile(i8* %43, i64 %44)
br label %58
46: ; preds = %34
%47 = load i8*, i8** %11
%48 = load i64, i64* %8
%49 = call i32 @array_to_file(i8* %47, i64 %48)
br label %58
50: ; preds = %34
%51 = load i8*, i8** %11
%52 = load i64, i64* %8
%53 = call i32 @printprimes(i8* %51, i64 %52)
br label %58
54: ; preds = %34
%55 = load i8*, i8** %11
%56 = load i64, i64* %8
%57 = call i32 @primestofile(i8* %55, i64 %56)
br label %58
58: ; preds = %54, %50, %46, %42
br label %61
59: ; preds = %31
%60 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
br label %61
61: ; preds = %59, %58
br label %62
62: ; preds = %61, %20
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"interactive mode\0An=\00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [77 x i8] c"1 -> print primes to a file\0A2 -> print array to file\0A3 -> display primes\0A ?=\00"
@.str.3 = [3 x i8] c"%d\00"
@str = [37 x i8] c"Use: sievee [number]\0Awith number > 2\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca i32
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %38
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = icmp sgt i32 %9, 2
br i1 %10, label %11, label %15
11: ; preds = %6
%12 = zext i32 %9 to i64
%13 = tail call i8* @sieve_of_eratosthenes(i64 %12)
%14 = tail call i32 @primestofile(i8* %13, i64 %12)
br label %40
15: ; preds = %6
%16 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%17 = bitcast i64* %3 to i8*
%18 = bitcast i32* %4 to i8*
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %3)
%20 = load i64, i64* %3
%21 = call i8* @sieve_of_eratosthenes(i64 %20)
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%24 = load i32, i32* %4
switch i32 %24, label %34 [
i32 1, label %25
i32 2, label %28
i32 3, label %31
]
25: ; preds = %15
%26 = load i64, i64* %3
%27 = call i32 @primestofile(i8* %21, i64 %26)
br label %37
28: ; preds = %15
%29 = load i64, i64* %3
%30 = call i32 @array_to_file(i8* %21, i64 %29)
br label %37
31: ; preds = %15
%32 = load i64, i64* %3
%33 = call i32 @printprimes(i8* %21, i64 %32)
br label %37
34: ; preds = %15
%35 = load i64, i64* %3
%36 = call i32 @primestofile(i8* %21, i64 %35)
br label %37
37: ; preds = %34, %31, %28, %25
br label %40
38: ; preds = %2
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %40
40: ; preds = %37, %38, %11
ret i32 0
}