#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 */
char EOF;
int EXIT_SUCCESS;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char getchar();
int getpid();
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ usleep(int);
int main(void) {
  int k;
  int i;
  char j = ' ', c;
  char perg[101][500] = {0};
  FILE *com;
  com = fopen("commands.txt", "rt");
  for (i = 0; i <= 99; i++)
    fgets(perg[i], 500, com);
  fclose(com);
  srand(time(NULL));
  while (1) {
    j = ' ';
    k = ((rand() + getpid()) % 100);
    printf("%s'n' to continue or 'q' to quit\n", perg[k]);
    scanf("%c", &j);
    while ((c = getchar()) != '\n' && c != EOF)
      ;
    while (j != 'n') {
      if (j == 'q')
        return EXIT_SUCCESS;
      else {
        printf("Invalid character, type again.\n");
        scanf("%c", &j);
        while ((c = getchar()) != '\n' && c != EOF)
          ;
      }
      usleep(16667);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc570,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x20,-0xd(%rbp)
lea    -0xc560(%rbp),%rdi
xor    %esi,%esi
mov    $0xc544,%edx
call   1060 <memset@plt>
lea    0xe10(%rip),%rdi
lea    0xe16(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0xc568(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x63,-0xc(%rbp)
jg     1248 <main+0x88>
movslq -0xc(%rbp),%rax
lea    -0xc560(%rbp),%rdi
imul   $0x1f4,%rax,%rax
add    %rax,%rdi
mov    -0xc568(%rbp),%rdx
mov    $0x1f4,%esi
call   1080 <fgets@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    120a <main+0x4a>
mov    -0xc568(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
movb   $0x20,-0xd(%rbp)
mov    $0x0,%al
call   10d0 <rand@plt>
mov    %eax,-0xc56c(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%ecx
mov    -0xc56c(%rbp),%eax
add    %ecx,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
movslq -0x8(%rbp),%rax
lea    -0xc560(%rbp),%rsi
imul   $0x1f4,%rax,%rax
add    %rax,%rsi
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd77(%rip),%rdi
lea    -0xd(%rbp),%rsi
call   10b0 <scanf@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
mov    %al,-0xe(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xc56d(%rbp)
je     12fb <main+0x13b>
movsbl -0xe(%rbp),%eax
mov    0x2cfb(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0xc56d(%rbp)
mov    -0xc56d(%rbp),%al
test   $0x1,%al
jne    130e <main+0x14e>
jmp    1313 <main+0x153>
jmp    12c4 <main+0x104>
jmp    1318 <main+0x158>
movsbl -0xd(%rbp),%eax
cmp    $0x6e,%eax
je     13c5 <main+0x205>
movsbl -0xd(%rbp),%eax
cmp    $0x71,%eax
jne    1344 <main+0x184>
mov    0x2c9f(%rip),%rax
mov    (%rax),%eax
add    $0xc570,%rsp
pop    %rbp
ret
lea    0xcea(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xcd9(%rip),%rdi
lea    -0xd(%rbp),%rsi
call   10b0 <scanf@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
mov    %al,-0xe(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xc56e(%rbp)
je     1399 <main+0x1d9>
movsbl -0xe(%rbp),%eax
mov    0x2c5d(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0xc56e(%rbp)
mov    -0xc56e(%rbp),%al
test   $0x1,%al
jne    13ac <main+0x1ec>
jmp    13b1 <main+0x1f1>
jmp    1362 <main+0x1a2>
jmp    13b6 <main+0x1f6>
mov    $0x411b,%edi
call   10e0 <usleep@plt>
jmp    1318 <main+0x158>
jmp    1264 <main+0xa4>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc558,%rsp
lea    0x10(%rsp),%rdi
xor    %ebp,%ebp
mov    $0xc544,%edx
xor    %esi,%esi
call   1070 <memset@plt>
lea    0xe05(%rip),%rdi
lea    0xe0b(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%rbx
nopw   0x0(%rax,%rax,1)
lea    (%rsp,%rbp,1),%rdi
add    $0x10,%rdi
mov    $0x1f4,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
add    $0x1f4,%rbp
cmp    $0xc350,%rbp
jne    1210 <main+0x40>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %edi,%edi
call   10b0 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
lea    0xdbe(%rip),%r14
lea    0xdd9(%rip),%r15
lea    0xf(%rsp),%rbx
mov    0x2d83(%rip),%rbp
lea    0xdc9(%rip),%r12
movb   $0x20,0xf(%rsp)
xor    %eax,%eax
call   10e0 <rand@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   1040 <getpid@plt>
add    %r13d,%eax
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
cltq
imul   $0x1f4,%rax,%rax
lea    (%rsp,%rax,1),%rsi
add    $0x10,%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   10c0 <scanf@plt>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <getchar@plt>
cmp    $0xa,%al
je     12fa <main+0x12a>
cmp    0x0(%rbp),%al
jne    12d0 <main+0x100>
jmp    12fa <main+0x12a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x411b,%edi
call   10f0 <usleep@plt>
mov    0xf(%rsp),%al
cmp    $0x6e,%al
je     126c <main+0x9c>
cmp    $0x71,%al
je     1332 <main+0x162>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   10c0 <scanf@plt>
nopl   (%rax)
xor    %eax,%eax
call   10a0 <getchar@plt>
cmp    $0xa,%al
je     12f0 <main+0x120>
cmp    0x0(%rbp),%al
jne    1320 <main+0x150>
jmp    12f0 <main+0x120>
mov    0x2c9f(%rip),%rax
mov    (%rax),%eax
add    $0xc558,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"commands.txt\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [34 x i8] c"%s'n' to continue or 'q' to quit\0A\00"
@.str.3 = [3 x i8] c"%c\00"
@EOF = global i8 0
@EXIT_SUCCESS = global i32 0
@.str.4 = [32 x i8] c"Invalid character, type again.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
%6 = alloca [101 x [500 x i8]]
%7 = alloca i32*
store i32 0, i32* %1
store i8 32, i8* %4
%8 = bitcast [101 x [500 x i8]]* %6 to i8*
%9 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %7
store i32 0, i32* %3
br label %10
10: ; preds = %20, %0
%11 = load i32, i32* %3
%12 = icmp sle i32 %11, 99
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [101 x [500 x i8]], [101 x [500 x i8]]* %6, i64 0, i64 %15
%17 = getelementptr inbounds [500 x i8], [500 x i8]* %16, i64 0, i64 0
%18 = load i32*, i32** %7
%19 = call i32 @fgets(i8* %17, i32 500, i32* %18)
br label %20
20: ; preds = %13
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %10
23: ; preds = %10
%24 = load i32*, i32** %7
%25 = call i32 @fclose(i32* %24)
%26 = call i32 @time(i32* null)
%27 = call i32 @srand(i32 %26)
br label %28
28: ; preds = %23, %82
store i8 32, i8* %4
%29 = call i32 (...) @rand()
%30 = call i32 (...) @getpid()
%31 = add nsw i32 %29, %30
%32 = srem i32 %31, 100
store i32 %32, i32* %2
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [101 x [500 x i8]], [101 x [500 x i8]]* %6, i64 0, i64 %34
%36 = getelementptr inbounds [500 x i8], [500 x i8]* %35, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %39
39: ; preds = %51, %28
%40 = call signext i8 (...) @getchar()
store i8 %40, i8* %5
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 10
br i1 %42, label %43, label %49
43: ; preds = %39
%44 = load i8, i8* %5
%45 = sext i8 %44 to i32
%46 = load i8, i8* @EOF
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %45, %47
br label %49
49: ; preds = %43, %39
%50 = phi i1 [ false, %39 ], [ %48, %43 ]
br i1 %50, label %51, label %52
51: ; preds = %49
br label %39
52: ; preds = %49
br label %53
53: ; preds = %80, %52
%54 = load i8, i8* %4
%55 = sext i8 %54 to i32
%56 = icmp ne i32 %55, 110
br i1 %56, label %57, label %82
57: ; preds = %53
%58 = load i8, i8* %4
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 113
br i1 %60, label %61, label %63
61: ; preds = %57
%62 = load i32, i32* @EXIT_SUCCESS
ret i32 %62
63: ; preds = %57
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%65 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %66
66: ; preds = %78, %63
%67 = call signext i8 (...) @getchar()
store i8 %67, i8* %5
%68 = sext i8 %67 to i32
%69 = icmp ne i32 %68, 10
br i1 %69, label %70, label %76
70: ; preds = %66
%71 = load i8, i8* %5
%72 = sext i8 %71 to i32
%73 = load i8, i8* @EOF
%74 = sext i8 %73 to i32
%75 = icmp ne i32 %72, %74
br label %76
76: ; preds = %70, %66
%77 = phi i1 [ false, %66 ], [ %75, %70 ]
br i1 %77, label %78, label %79
78: ; preds = %76
br label %66
79: ; preds = %76
br label %80
80: ; preds = %79
%81 = call i32 @usleep(i32 16667)
br label %53
82: ; preds = %53
br label %28
}

LLVM IR (-O2):
@.str = [13 x i8] c"commands.txt\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [34 x i8] c"%s'n' to continue or 'q' to quit\0A\00"
@.str.3 = [3 x i8] c"%c\00"
@EOF = global i8 0
@EXIT_SUCCESS = global i32 0
@str = [31 x i8] c"Invalid character, type again.\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca [101 x [500 x i8]]
%3 = getelementptr inbounds [101 x [500 x i8]], [101 x [500 x i8]]* %2, i64 0, i64 0, i64 0
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %0, %5
%6 = phi i64 [ 0, %0 ], [ %9, %5 ]
%7 = getelementptr inbounds [101 x [500 x i8]], [101 x [500 x i8]]* %2, i64 0, i64 %6, i64 0
%8 = call i32 @fgets(i8* %7, i32 500, i32* %4)
%9 = add nuw nsw i64 %6, 1
%10 = icmp eq i64 %9, 100
br i1 %10, label %11, label %5
11: ; preds = %5
%12 = call i32 @fclose(i32* %4)
%13 = call i32 @time(i32* null)
%14 = call i32 @srand(i32 %13)
br label %15
15: ; preds = %30, %11
store i8 32, i8* %1
%16 = call i32 (...) @rand()
%17 = call i32 (...) @getpid()
%18 = add nsw i32 %17, %16
%19 = srem i32 %18, 100
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [101 x [500 x i8]], [101 x [500 x i8]]* %2, i64 0, i64 %20, i64 0
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %1)
br label %24
24: ; preds = %24, %15
%25 = call signext i8 (...) @getchar()
%26 = icmp ne i8 %25, 10
%27 = load i8, i8* @EOF
%28 = icmp ne i8 %25, %27
%29 = select i1 %26, i1 %28, i1 false
br i1 %29, label %24, label %30
30: ; preds = %24, %43
%31 = load i8, i8* %1
switch i8 %31, label %34 [
i8 110, label %15
i8 113, label %32
]
32: ; preds = %30
%33 = load i32, i32* @EXIT_SUCCESS
ret i32 %33
34: ; preds = %30
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %1)
br label %37
37: ; preds = %37, %34
%38 = call signext i8 (...) @getchar()
%39 = icmp ne i8 %38, 10
%40 = load i8, i8* @EOF
%41 = icmp ne i8 %38, %40
%42 = select i1 %39, i1 %41, i1 false
br i1 %42, label %37, label %43
43: ; preds = %37
%44 = call i32 @usleep(i32 16667)
br label %30
}