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

/* Variables and functions */
scalar_t__ calloc(int, int);
int displayGeneratorOptions();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int generatorOptions(char **streamFile) {
  char file[200];
  int option = 10 + 1;
  FILE *fp;
  while ((option < 0) || (option > 10)) {
    option = displayGeneratorOptions();
    switch (option) {
    case 0:
      printf("\t\tUser Prescribed Input File: ");
      scanf("%s", file);
      *streamFile = (char *)calloc(200, sizeof(char));
      sprintf(*streamFile, "%s", file);
      printf("\n");
      if ((fp = fopen(*streamFile, "r")) == NULL) {
        printf("File Error:  file %s could not be opened.\n", *streamFile);
        exit(-1);
      } else
        fclose(fp);
      break;
    case 1:
      *streamFile = "Linear-Congruential";
      break;
    case 2:
      *streamFile = "Quadratic-Congruential-1";
      break;
    case 3:
      *streamFile = "Quadratic-Congruential-2";
      break;
    case 4:
      *streamFile = "Cubic-Congruential";
      break;
    case 5:
      *streamFile = "XOR";
      break;
    case 6:
      *streamFile = "Modular-Exponentiation";
      break;
    case 7:
      *streamFile = "Blum-Blum-Shub";
      break;
    case 8:
      *streamFile = "Micali-Schnorr";
      break;
    case 9:
      *streamFile = "G using SHA-1";
      break;
    default:
      printf("Error:  Out of range - Try again!\n");
      break;
    }
  }
  return option;
}


x86 assembly (clang, -O0):
<generatorOptions>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xb,-0xd4(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0xd4(%rbp)
mov    %al,-0xe1(%rbp)
jl     11be <generatorOptions+0x3e>
cmpl   $0xa,-0xd4(%rbp)
setg   %al
mov    %al,-0xe1(%rbp)
mov    -0xe1(%rbp),%al
test   $0x1,%al
jne    11d1 <generatorOptions+0x51>
jmp    1380 <generatorOptions+0x200>
xor    %eax,%eax
call   1030 <displayGeneratorOptions@plt>
mov    %eax,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
mov    %rax,-0xf0(%rbp)
sub    $0x9,%rax
ja     136d <generatorOptions+0x1ed>
mov    -0xf0(%rbp),%rax
lea    0xdfd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xd0(%rbp),%rsi
lea    0xe1f(%rip),%rdi
call   1070 <scanf@plt>
mov    $0xc8,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    -0xd0(%rbp),%rdx
lea    0xdec(%rip),%rsi
call   1090 <sprintf@plt>
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    0xe89(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0xe0(%rbp)
cmp    $0x0,%rax
jne    12b1 <generatorOptions+0x131>
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0xe0(%rbp),%rdi
call   1040 <fclose@plt>
jmp    137b <generatorOptions+0x1fb>
mov    -0x8(%rbp),%rax
lea    0xda8(%rip),%rcx
mov    %rcx,(%rax)
jmp    137b <generatorOptions+0x1fb>
mov    -0x8(%rbp),%rax
lea    0xda9(%rip),%rcx
mov    %rcx,(%rax)
jmp    137b <generatorOptions+0x1fb>
mov    -0x8(%rbp),%rax
lea    0xdaf(%rip),%rcx
mov    %rcx,(%rax)
jmp    137b <generatorOptions+0x1fb>
mov    -0x8(%rbp),%rax
lea    0xdb5(%rip),%rcx
mov    %rcx,(%rax)
jmp    137b <generatorOptions+0x1fb>
mov    -0x8(%rbp),%rax
lea    0xdb5(%rip),%rcx
mov    %rcx,(%rax)
jmp    137b <generatorOptions+0x1fb>
mov    -0x8(%rbp),%rax
lea    0xda6(%rip),%rcx
mov    %rcx,(%rax)
jmp    137b <generatorOptions+0x1fb>
mov    -0x8(%rbp),%rax
lea    0xdaa(%rip),%rcx
mov    %rcx,(%rax)
jmp    137b <generatorOptions+0x1fb>
mov    -0x8(%rbp),%rax
lea    0xda6(%rip),%rcx
mov    %rcx,(%rax)
jmp    137b <generatorOptions+0x1fb>
mov    -0x8(%rbp),%rax
lea    0xda2(%rip),%rcx
mov    %rcx,(%rax)
jmp    137b <generatorOptions+0x1fb>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1199 <generatorOptions+0x19>
mov    -0xd4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generatorOptions>:
push   %r15
push   %r14
push   %rbx
sub    $0xd0,%rsp
mov    %rdi,%r14
lea    0xf5f(%rip),%r15
xor    %eax,%eax
call   1050 <displayGeneratorOptions@plt>
mov    %eax,%ebx
cmp    $0x9,%eax
jbe    11d6 <generatorOptions+0x36>
mov    %r15,%rdi
call   1060 <puts@plt>
cmp    $0xa,%ebx
ja     11b6 <generatorOptions+0x16>
jmp    129f <generatorOptions+0xff>
mov    %ebx,%eax
lea    0xe21(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe4a(%rip),%rdi
mov    %rsp,%r15
mov    %r15,%rsi
call   10a0 <scanf@plt>
mov    $0xc8,%edi
mov    $0x1,%esi
call   1090 <calloc@plt>
mov    %rax,(%r14)
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%r14),%rdi
lea    0xecc(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12ae <generatorOptions+0x10e>
mov    %rax,%rdi
call   1070 <fclose@plt>
jmp    129f <generatorOptions+0xff>
lea    0xe35(%rip),%rax
jmp    129c <generatorOptions+0xfc>
lea    0xe45(%rip),%rax
jmp    129c <generatorOptions+0xfc>
lea    0xe55(%rip),%rax
jmp    129c <generatorOptions+0xfc>
lea    0xe7a(%rip),%rax
jmp    129c <generatorOptions+0xfc>
lea    0xe8f(%rip),%rax
jmp    129c <generatorOptions+0xfc>
lea    0xdf4(%rip),%rax
jmp    129c <generatorOptions+0xfc>
lea    0xe44(%rip),%rax
jmp    129c <generatorOptions+0xfc>
lea    0xe3f(%rip),%rax
jmp    129c <generatorOptions+0xfc>
lea    0xe5c(%rip),%rax
mov    %rax,(%r14)
mov    %ebx,%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    (%r14),%rsi
lea    0xd92(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"\09\09User Prescribed Input File: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [43 x i8] c"File Error: file %s could not be opened.\0A\00"
@.str.5 = [20 x i8] c"Linear-Congruential\00"
@.str.6 = [25 x i8] c"Quadratic-Congruential-1\00"
@.str.7 = [25 x i8] c"Quadratic-Congruential-2\00"
@.str.8 = [19 x i8] c"Cubic-Congruential\00"
@.str.9 = [4 x i8] c"XOR\00"
@.str.10 = [23 x i8] c"Modular-Exponentiation\00"
@.str.11 = [15 x i8] c"Blum-Blum-Shub\00"
@.str.12 = [15 x i8] c"Micali-Schnorr\00"
@.str.13 = [14 x i8] c"G using SHA-1\00"
@.str.14 = [35 x i8] c"Error: Out of range - Try again!\0A\00"
define i32 @generatorOptions(i8** %0) {
%2 = alloca i8**
%3 = alloca [200 x i8]
%4 = alloca i32
%5 = alloca i32*
store i8** %0, i8*** %2
store i32 11, i32* %4
br label %6
6: ; preds = %62, %1
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 10
br label %12
12: ; preds = %9, %6
%13 = phi i1 [ true, %6 ], [ %11, %9 ]
br i1 %13, label %14, label %63
14: ; preds = %12
%15 = call i32 (...) @displayGeneratorOptions()
store i32 %15, i32* %4
%16 = load i32, i32* %4
switch i32 %16, label %60 [
i32 0, label %17
i32 1, label %42
i32 2, label %44
i32 3, label %46
i32 4, label %48
i32 5, label %50
i32 6, label %52
i32 7, label %54
i32 8, label %56
i32 9, label %58
]
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%19 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = call i64 @calloc(i32 200, i32 1)
%22 = inttoptr i64 %21 to i8*
%23 = load i8**, i8*** %2
store i8* %22, i8** %23
%24 = load i8**, i8*** %2
%25 = load i8*, i8** %24
%26 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%27 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%29 = load i8**, i8*** %2
%30 = load i8*, i8** %29
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %31, i32** %5
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %38
33: ; preds = %17
%34 = load i8**, i8*** %2
%35 = load i8*, i8** %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %35)
%37 = call i32 @exit(i32 -1)
unreachable
38: ; preds = %17
%39 = load i32*, i32** %5
%40 = call i32 @fclose(i32* %39)
br label %41
41: ; preds = %38
br label %62
42: ; preds = %14
%43 = load i8**, i8*** %2
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8** %43
br label %62
44: ; preds = %14
%45 = load i8**, i8*** %2
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8** %45
br label %62
46: ; preds = %14
%47 = load i8**, i8*** %2
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8** %47
br label %62
48: ; preds = %14
%49 = load i8**, i8*** %2
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8** %49
br label %62
50: ; preds = %14
%51 = load i8**, i8*** %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8** %51
br label %62
52: ; preds = %14
%53 = load i8**, i8*** %2
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8** %53
br label %62
54: ; preds = %14
%55 = load i8**, i8*** %2
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), i8** %55
br label %62
56: ; preds = %14
%57 = load i8**, i8*** %2
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i8** %57
br label %62
58: ; preds = %14
%59 = load i8**, i8*** %2
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i8** %59
br label %62
60: ; preds = %14
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.14, i64 0, i64 0))
br label %62
62: ; preds = %60, %58, %56, %54, %52, %50, %48, %46, %44, %42, %41
br label %6
63: ; preds = %12
%64 = load i32, i32* %4
ret i32 %64
}

LLVM IR (-O2):
@.str = [31 x i8] c"\09\09User Prescribed Input File: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [43 x i8] c"File Error: file %s could not be opened.\0A\00"
@.str.5 = [20 x i8] c"Linear-Congruential\00"
@.str.6 = [25 x i8] c"Quadratic-Congruential-1\00"
@.str.7 = [25 x i8] c"Quadratic-Congruential-2\00"
@.str.8 = [19 x i8] c"Cubic-Congruential\00"
@.str.9 = [4 x i8] c"XOR\00"
@.str.10 = [23 x i8] c"Modular-Exponentiation\00"
@.str.11 = [15 x i8] c"Blum-Blum-Shub\00"
@.str.12 = [15 x i8] c"Micali-Schnorr\00"
@.str.13 = [14 x i8] c"G using SHA-1\00"
@str = [34 x i8] c"Error: Out of range - Try again!\00"
define i32 @generatorOptions(i8** nocapture %0) {
%2 = alloca [200 x i8]
%3 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %1, %31
%5 = call i32 (...) @displayGeneratorOptions()
switch i32 %5, label %31 [
i32 0, label %6
i32 1, label %22
i32 2, label %23
i32 3, label %24
i32 4, label %25
i32 5, label %26
i32 6, label %27
i32 7, label %28
i32 8, label %29
i32 9, label %30
]
6: ; preds = %4
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%9 = call i64 @calloc(i32 200, i32 1)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %0
%11 = call i8* @strcpy(i8* dereferenceable(1) %10, i8* %3)
%12 = call i32 @putchar(i32 10)
%13 = load i8*, i8** %0
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %20
16: ; preds = %6
%17 = load i8*, i8** %0
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %6
%21 = call i32 @fclose(i32* %14)
br label %34
22: ; preds = %4
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8** %0
br label %34
23: ; preds = %4
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8** %0
br label %34
24: ; preds = %4
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8** %0
br label %34
25: ; preds = %4
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8** %0
br label %34
26: ; preds = %4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8** %0
br label %34
27: ; preds = %4
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8** %0
br label %34
28: ; preds = %4
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), i8** %0
br label %34
29: ; preds = %4
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i8** %0
br label %34
30: ; preds = %4
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i8** %0
br label %34
31: ; preds = %4
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%33 = icmp ugt i32 %5, 10
br i1 %33, label %4, label %34
34: ; preds = %31, %20, %22, %23, %24, %25, %26, %27, %28, %29, %30
ret i32 %5
}