#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 */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
long fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ getc(int /*<<< orphan*/);
int /*<<< orphan*/ insult(long, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
long rand();
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  char eingabe = 0;
  FILE *insults = 0;
  if (insults = fopen("Insults.txt", "r")) {
  } else {
    fprintf(stderr,
            "Could not open Insult.txt!\nPlease make sure that Insult.txt is "
            "in the same folder with Vicious Mockery Generator!\n");
    return 0;
  }
  char zeichen[2];
  long anzahl = 0;
  long stop = 1;
  do {
    int i = 0;
    int durchlauf = 0;
    stop = fgets(zeichen, 2, insults);
    i = (zeichen[0] == '\n') ? 0 : 1;
    do {
      stop = fgets(zeichen, 2, insults);
      i = (zeichen[0] == '\n') ? 0 : 1;
      durchlauf++;
    } while (i == 1);
    anzahl++;
  } while (stop);
  printf("%ld Insults found.\n", anzahl);
  srand(time(NULL));
  do {
    fseek(insults, SEEK_SET, 0);
    long random = 0;
    printf("\nPress Enter to insult!\nor press q to quit.\n");
    scanf("%c", &eingabe);
    (eingabe == '\n') ?: getc(stdin);
    if (eingabe == '\n') {
      random = rand() % anzahl;
      insult(random, insults);
    } else {
      if (eingabe == 'q') {
        break;
      }
      printf("I said \"ENTER\"...\n");
    }
  } while (1);
  fclose(insults);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xe1e(%rip),%rdi
lea    0xe23(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1201 <main+0x41>
jmp    1222 <main+0x62>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
lea    0xdfd(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    13c0 <main+0x200>
movq   $0x0,-0x20(%rbp)
movq   $0x1,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
lea    -0x12(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2,%esi
call   1060 <fgets@plt>
mov    %rax,-0x28(%rbp)
movsbl -0x12(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0xa,%edx
cmove  %ecx,%eax
mov    %eax,-0x2c(%rbp)
lea    -0x12(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2,%esi
call   1060 <fgets@plt>
mov    %rax,-0x28(%rbp)
movsbl -0x12(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0xa,%edx
cmove  %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x1,-0x2c(%rbp)
je     126a <main+0xaa>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1232 <main+0x72>
mov    -0x20(%rbp),%rsi
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    -0x10(%rbp),%rdi
mov    0x2ce5(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <fseek@plt>
movq   $0x0,-0x38(%rbp)
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdb1(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   10a0 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
test   $0x1,%al
jne    1339 <main+0x179>
jmp    133e <main+0x17e>
jmp    134c <main+0x18c>
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
call   10d0 <getc@plt>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    137c <main+0x1bc>
mov    $0x0,%al
call   10e0 <rand@plt>
cqto
idivq  -0x20(%rbp)
mov    %rdx,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10b0 <insult@plt>
jmp    139c <main+0x1dc>
movsbl -0x5(%rbp),%eax
cmp    $0x71,%eax
jne    138e <main+0x1ce>
jmp    13b0 <main+0x1f0>
lea    0xd30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13a1 <main+0x1e1>
mov    $0x1,%al
test   $0x1,%al
jne    12e0 <main+0x120>
jmp    13b0 <main+0x1f0>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movb   $0x0,0x5(%rsp)
lea    0xe19(%rip),%rdi
lea    0xe1e(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1307 <main+0x137>
mov    %rax,%rbx
xor    %r14d,%r14d
lea    0x6(%rsp),%rbp
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0x2,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
mov    %rbp,%rdi
mov    $0x2,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
cmpb   $0xa,0x6(%rsp)
jne    1220 <main+0x50>
add    $0x1,%r14
test   %rax,%rax
jne    1210 <main+0x40>
lea    0xe3a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    0x2d6a(%rip),%rbp
lea    0xe2b(%rip),%r15
lea    0xe21(%rip),%r12
lea    0x5(%rsp),%r13
jmp    128f <main+0xbf>
nopl   0x0(%rax,%rax,1)
xor    %edx,%edx
div    %r14d
mov    %edx,%edi
mov    %rbx,%rsi
call   10c0 <insult@plt>
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
xor    %edx,%edx
call   10a0 <fseek@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   10b0 <scanf@plt>
cmpb   $0xa,0x5(%rsp)
je     12e0 <main+0x110>
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
call   10e0 <getc@plt>
movzbl 0x5(%rsp),%eax
cmp    $0xa,%al
je     12e0 <main+0x110>
cmp    $0x71,%al
je     12fd <main+0x12d>
lea    0xdec(%rip),%rdi
call   1030 <puts@plt>
jmp    128f <main+0xbf>
nop
xor    %eax,%eax
call   10f0 <rand@plt>
mov    %rax,%rcx
or     %r14,%rcx
shr    $0x20,%rcx
je     1280 <main+0xb0>
cqto
idiv   %r14
mov    %rdx,%rdi
jmp    1287 <main+0xb7>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    131c <main+0x14c>
mov    0x2cca(%rip),%rax
mov    (%rax),%edi
lea    0xcf7(%rip),%rsi
call   1080 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Insults.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [115 x i8] c"Could not open Insult.txt!\0APlease make sure that Insult.txt is in the same folder with Vicious Mockery Generator!\0A\00"
@.str.3 = [20 x i8] c"%ld Insults found.\0A\00"
@SEEK_SET = global i32 0
@.str.4 = [45 x i8] c"\0APress Enter to insult!\0Aor press q to quit.\0A\00"
@.str.5 = [3 x i8] c"%c\00"
@stdin = global i32 0
@.str.6 = [19 x i8] c"I said \22ENTER\22...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32*
%4 = alloca [2 x i8]
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
store i32 0, i32* %1
store i8 0, i8* %2
store i32* null, i32** %3
%10 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %3
%11 = icmp ne i32* %10, null
br i1 %11, label %12, label %13
12: ; preds = %0
br label %16
13: ; preds = %0
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %91
16: ; preds = %12
store i64 0, i64* %5
store i64 1, i64* %6
br label %17
17: ; preds = %45, %16
store i32 0, i32* %7
store i32 0, i32* %8
%18 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%19 = load i32*, i32** %3
%20 = call i64 @fgets(i8* %18, i32 2, i32* %19)
store i64 %20, i64* %6
%21 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 10
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 0, i32 1
store i32 %26, i32* %7
br label %27
27: ; preds = %39, %17
%28 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%29 = load i32*, i32** %3
%30 = call i64 @fgets(i8* %28, i32 2, i32* %29)
store i64 %30, i64* %6
%31 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 10
%35 = zext i1 %34 to i64
%36 = select i1 %34, i32 0, i32 1
store i32 %36, i32* %7
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %39
39: ; preds = %27
%40 = load i32, i32* %7
%41 = icmp eq i32 %40, 1
br i1 %41, label %27, label %42
42: ; preds = %39
%43 = load i64, i64* %5
%44 = add nsw i64 %43, 1
store i64 %44, i64* %5
br label %45
45: ; preds = %42
%46 = load i64, i64* %6
%47 = icmp ne i64 %46, 0
br i1 %47, label %17, label %48
48: ; preds = %45
%49 = load i64, i64* %5
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i64 %49)
%51 = call i32 @time(i32* null)
%52 = call i32 @srand(i32 %51)
br label %53
53: ; preds = %87, %48
%54 = load i32*, i32** %3
%55 = load i32, i32* @SEEK_SET
%56 = call i32 @fseek(i32* %54, i32 %55, i32 0)
store i64 0, i64* %9
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%58 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %2)
%59 = load i8, i8* %2
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 10
%62 = zext i1 %61 to i32
br i1 %61, label %63, label %64
63: ; preds = %53
br label %67
64: ; preds = %53
%65 = load i32, i32* @stdin
%66 = call i32 @getc(i32 %65)
br label %67
67: ; preds = %64, %63
%68 = phi i32 [ %62, %63 ], [ %66, %64 ]
%69 = load i8, i8* %2
%70 = sext i8 %69 to i32
%71 = icmp eq i32 %70, 10
br i1 %71, label %72, label %79
72: ; preds = %67
%73 = call i64 (...) @rand()
%74 = load i64, i64* %5
%75 = srem i64 %73, %74
store i64 %75, i64* %9
%76 = load i64, i64* %9
%77 = load i32*, i32** %3
%78 = call i32 @insult(i64 %76, i32* %77)
br label %86
79: ; preds = %67
%80 = load i8, i8* %2
%81 = sext i8 %80 to i32
%82 = icmp eq i32 %81, 113
br i1 %82, label %83, label %84
83: ; preds = %79
br label %88
84: ; preds = %79
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %86
86: ; preds = %84, %72
br label %87
87: ; preds = %86
br i1 true, label %53, label %88
88: ; preds = %87, %83
%89 = load i32*, i32** %3
%90 = call i32 @fclose(i32* %89)
store i32 0, i32* %1
br label %91
91: ; preds = %88, %13
%92 = load i32, i32* %1
ret i32 %92
}

LLVM IR (-O2):
@.str = [12 x i8] c"Insults.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [115 x i8] c"Could not open Insult.txt!\0APlease make sure that Insult.txt is in the same folder with Vicious Mockery Generator!\0A\00"
@.str.3 = [20 x i8] c"%ld Insults found.\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [3 x i8] c"%c\00"
@stdin = global i32 0
@str = [44 x i8] c"\0APress Enter to insult!\0Aor press q to quit.\00"
@str.7 = [18 x i8] c"I said \22ENTER\22...\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca [2 x i8]
store i8 0, i8* %1
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.2, i64 0, i64 0))
br label %44
8: ; preds = %0
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
br label %10
10: ; preds = %17, %8
%11 = phi i64 [ 0, %8 ], [ %18, %17 ]
%12 = call i64 @fgets(i8* %9, i32 2, i32* %3)
br label %13
13: ; preds = %13, %10
%14 = call i64 @fgets(i8* %9, i32 2, i32* %3)
%15 = load i8, i8* %9
%16 = icmp eq i8 %15, 10
br i1 %16, label %17, label %13
17: ; preds = %13
%18 = add nuw nsw i64 %11, 1
%19 = icmp eq i64 %14, 0
br i1 %19, label %20, label %10
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i64 %18)
%22 = call i32 @time(i32* null)
%23 = call i32 @srand(i32 %22)
br label %24
24: ; preds = %39, %20
%25 = load i32, i32* @SEEK_SET
%26 = call i32 @fseek(i32* %3, i32 %25, i32 0)
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %1)
%29 = load i8, i8* %1
%30 = icmp eq i8 %29, 10
br i1 %30, label %35, label %31
31: ; preds = %24
%32 = load i32, i32* @stdin
%33 = call i32 @getc(i32 %32)
%34 = load i8, i8* %1
switch i8 %34, label %40 [
i8 10, label %35
i8 113, label %42
]
35: ; preds = %24, %31
%36 = call i64 (...) @rand()
%37 = srem i64 %36, %18
%38 = call i32 @insult(i64 %37, i32* %3)
br label %39
39: ; preds = %35, %40
br label %24
40: ; preds = %31
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.7, i64 0, i64 0))
br label %39
42: ; preds = %31
%43 = call i32 @fclose(i32* %3)
br label %44
44: ; preds = %42, %5
ret i32 0
}