#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 atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int getNum();
scalar_t__ isdigit(char);
int /*<<< orphan*/ sendMessage(char *, int);
char *strchr(char *, char);
int strlen(char *);
int main() {
  char quote[200];
  int num = getNum();
  if (num == 40)
    num = 57;
  if (num == 50)
    num = 58;
  FILE *fp;
  fp = fopen("quotes.txt", "r");
  int currNum = 0;
  char temp[20];
  while (currNum != num) {
    fscanf(fp, "%s", temp);
    if (isdigit(temp[0]) != 0) {
      currNum = atoi(temp);
    }
  }
  fgets(quote, 180, fp);
  fclose(fp);
  int i, len = strlen(quote);
  for (i = 1; i <= len; ++i) {
    quote[i - 1] = quote[i];
  }
  char *pos;
  if ((pos = strchr(quote, '\n')) != NULL)
    *pos = '\0';
  sendMessage(quote, num);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   10c0 <getNum@plt>
mov    %eax,-0xd4(%rbp)
cmpl   $0x28,-0xd4(%rbp)
jne    11d6 <main+0x36>
movl   $0x39,-0xd4(%rbp)
cmpl   $0x32,-0xd4(%rbp)
jne    11ed <main+0x4d>
movl   $0x3a,-0xd4(%rbp)
lea    0xe0c(%rip),%rdi
lea    0xe10(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0xe0(%rbp)
movl   $0x0,-0xe4(%rbp)
mov    -0xe4(%rbp),%eax
cmp    -0xd4(%rbp),%eax
je     126a <main+0xca>
mov    -0xe0(%rbp),%rdi
lea    -0x100(%rbp),%rdx
lea    0xdd5(%rip),%rsi
call   1070 <fscanf@plt>
movsbl -0x100(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1265 <main+0xc5>
lea    -0x100(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0xe4(%rbp)
jmp    1211 <main+0x71>
lea    -0xd0(%rbp),%rdi
mov    -0xe0(%rbp),%rdx
mov    $0xb4,%esi
call   1080 <fgets@plt>
mov    -0xe0(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0xd0(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x108(%rbp)
movl   $0x1,-0x104(%rbp)
mov    -0x104(%rbp),%eax
cmp    -0x108(%rbp),%eax
jg     12f0 <main+0x150>
movslq -0x104(%rbp),%rax
mov    -0xd0(%rbp,%rax,1),%cl
mov    -0x104(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %cl,-0xd0(%rbp,%rax,1)
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    12aa <main+0x10a>
lea    -0xd0(%rbp),%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
mov    %rax,-0x110(%rbp)
cmp    $0x0,%rax
je     131c <main+0x17c>
mov    -0x110(%rbp),%rax
movb   $0x0,(%rax)
lea    -0xd0(%rbp),%rdi
mov    -0xd4(%rbp),%esi
call   1090 <sendMessage@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xf0,%rsp
xor    %ebp,%ebp
xor    %eax,%eax
call   10d0 <getNum@plt>
cmp    $0x28,%eax
mov    $0x39,%ecx
cmovne %eax,%ecx
cmp    $0x32,%ecx
mov    $0x3a,%r14d
cmovne %ecx,%r14d
lea    0xe19(%rip),%rdi
lea    0xe1d(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
test   %r14d,%r14d
je     123d <main+0x8d>
lea    0xe0b(%rip),%r15
mov    %rsp,%r12
jmp    1215 <main+0x65>
nopw   0x0(%rax,%rax,1)
cmp    %r14d,%ebp
je     123d <main+0x8d>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1070 <fscanf@plt>
movsbl (%rsp),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1210 <main+0x60>
mov    %r12,%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebp
jmp    1210 <main+0x60>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0xb4,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1277 <main+0xc7>
lea    0x21(%rsp),%rsi
mov    %eax,%edx
lea    0x20(%rsp),%rdi
call   10a0 <memmove@plt>
lea    0x20(%rsp),%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     128e <main+0xde>
movb   $0x0,(%rax)
lea    0x20(%rsp),%rdi
mov    %r14d,%esi
call   1090 <sendMessage@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"quotes.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [200 x i8]
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [20 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 0, i32* %1
%10 = call i32 (...) @getNum()
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 40
br i1 %12, label %13, label %14
13: ; preds = %0
store i32 57, i32* %3
br label %14
14: ; preds = %13, %0
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 50
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 58, i32* %3
br label %18
18: ; preds = %17, %14
%19 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %4
store i32 0, i32* %5
br label %20
20: ; preds = %35, %18
%21 = load i32, i32* %5
%22 = load i32, i32* %3
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %36
24: ; preds = %20
%25 = load i32*, i32** %4
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%27 = call i32 @fscanf(i32* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%29 = load i8, i8* %28
%30 = call i64 @isdigit(i8 signext %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %24
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%34 = call i32 @atoi(i8* %33)
store i32 %34, i32* %5
br label %35
35: ; preds = %32, %24
br label %20
36: ; preds = %20
%37 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%38 = load i32*, i32** %4
%39 = call i32 @fgets(i8* %37, i32 180, i32* %38)
%40 = load i32*, i32** %4
%41 = call i32 @fclose(i32* %40)
%42 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%43 = call i32 @strlen(i8* %42)
store i32 %43, i32* %8
store i32 1, i32* %7
br label %44
44: ; preds = %57, %36
%45 = load i32, i32* %7
%46 = load i32, i32* %8
%47 = icmp sle i32 %45, %46
br i1 %47, label %48, label %60
48: ; preds = %44
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = load i32, i32* %7
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %55
store i8 %52, i8* %56
br label %57
57: ; preds = %48
%58 = load i32, i32* %7
%59 = add nsw i32 %58, 1
store i32 %59, i32* %7
br label %44
60: ; preds = %44
%61 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%62 = call i8* @strchr(i8* %61, i8 signext 10)
store i8* %62, i8** %9
%63 = icmp ne i8* %62, null
br i1 %63, label %64, label %66
64: ; preds = %60
%65 = load i8*, i8** %9
store i8 0, i8* %65
br label %66
66: ; preds = %64, %60
%67 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%68 = load i32, i32* %3
%69 = call i32 @sendMessage(i8* %67, i32 %68)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"quotes.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [200 x i8]
%2 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%5 = tail call i32 (...) @getNum()
%6 = icmp eq i32 %5, 40
%7 = select i1 %6, i32 57, i32 %5
%8 = icmp eq i32 %7, 50
%9 = select i1 %8, i32 58, i32 %7
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%12 = icmp eq i32 %9, 0
br i1 %12, label %24, label %13
13: ; preds = %0, %21
%14 = phi i32 [ %22, %21 ], [ 0, %0 ]
%15 = call i32 @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%16 = load i8, i8* %11
%17 = call i64 @isdigit(i8 signext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %13
%20 = call i32 @atoi(i8* %11)
br label %21
21: ; preds = %19, %13
%22 = phi i32 [ %20, %19 ], [ %14, %13 ]
%23 = icmp eq i32 %22, %9
br i1 %23, label %24, label %13
24: ; preds = %21, %0
%25 = call i32 @fgets(i8* %4, i32 180, i32* %10)
%26 = call i32 @fclose(i32* %10)
%27 = call i32 @strlen(i8* %4)
%28 = icmp slt i32 %27, 1
br i1 %28, label %32, label %29
29: ; preds = %24
%30 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 1
%31 = zext i32 %27 to i64
br label %32
32: ; preds = %29, %24
%33 = call i8* @strchr(i8* %4, i8 signext 10)
%34 = icmp eq i8* %33, null
br i1 %34, label %36, label %35
35: ; preds = %32
store i8 0, i8* %33
br label %36
36: ; preds = %35, %32
%37 = call i32 @sendMessage(i8* %4, i32 %9)
ret i32 0
}