#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 */
scalar_t__ getline(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strincmp(char *, char *);
int main() {
  char ans[] = "apple";
  char array[20];
  printf("Guess my favorite fruit\n");
  while (getline(array, 20) > 0)
    if (!strincmp(ans, array)) {
      printf("The answer is correct\n");
      break;
    } else {
      printf("%s not the answer\nTry it again\n", array);
    }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xebb(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xeb5(%rip),%ax
mov    %ax,-0x6(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x14,%esi
call   1050 <getline@plt>
cmp    $0x0,%rax
jle    11b9 <main+0x89>
lea    -0xa(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <strincmp@plt>
cmp    $0x0,%eax
jne    11a2 <main+0x72>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b9 <main+0x89>
lea    -0x20(%rbp),%rsi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1161 <main+0x31>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
movw   $0x65,0xc(%rsp)
movl   $0x6c707061,0x8(%rsp)
6c
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rdi
mov    $0x14,%esi
call   1060 <getline@plt>
test   %rax,%rax
jle    11cc <main+0x8c>
lea    0x8(%rsp),%r14
lea    0x10(%rsp),%rbx
lea    0xe7d(%rip),%r15
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strincmp@plt>
test   %eax,%eax
je     11c0 <main+0x80>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1060 <getline@plt>
test   %rax,%rax
jg     1190 <main+0x50>
jmp    11cc <main+0x8c>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.ans = [6 x i8] c"apple\00"
@.str = [25 x i8] c"Guess my favorite fruit\0A\00"
@.str.1 = [23 x i8] c"The answer is correct\0A\00"
@.str.2 = [32 x i8] c"%s not the answer\0ATry it again\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = alloca [20 x i8]
store i32 0, i32* %1
%4 = bitcast [6 x i8]* %2 to i8*
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %20, %0
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%8 = call i64 @getline(i8* %7, i32 20)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %6
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%13 = call i32 @strincmp(i8* %11, i8* %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %21
17: ; preds = %10
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %17
br label %6
21: ; preds = %15, %6
ret i32 0
}

LLVM IR (-O2):
@__const.main.ans = [6 x i8] c"apple\00"
@.str.2 = [32 x i8] c"%s not the answer\0ATry it again\0A\00"
@str = [24 x i8] c"Guess my favorite fruit\00"
@str.3 = [22 x i8] c"The answer is correct\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%6 = call i64 @getline(i8* %4, i32 20)
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %0, %13
%9 = call i32 @strincmp(i8* %3, i8* %4)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.3, i64 0, i64 0))
br label %17
13: ; preds = %8
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%15 = call i64 @getline(i8* %4, i32 20)
%16 = icmp sgt i64 %15, 0
br i1 %16, label %8, label %17
17: ; preds = %13, %0, %11
ret i32 0
}