#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 scalar_t__ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
scalar_t__ getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int ask_to_quit() {
  char *line = 0;
  size_t n = 0;
  ssize_t ret;
  printf("Would you like to quit? ");
  ret = getline(&line, &n, stdin);
  if (ret > 0) {
    if (line[0] == 'y' || line[0] == 'Y') {
      ret = 0;
    }
    free(line);
  }
  return ret;
}


x86 assembly (clang, -O0):
<ask_to_quit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <getline@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jle    11aa <ask_to_quit+0x7a>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x79,%eax
je     1199 <ask_to_quit+0x69>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x59,%eax
jne    11a1 <ask_to_quit+0x71>
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ask_to_quit>:
push   %rbx
sub    $0x10,%rsp
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
call   1050 <getline@plt>
mov    %rax,%rbx
test   %rax,%rax
jle    1183 <ask_to_quit+0x53>
mov    (%rsp),%rdi
mov    (%rdi),%al
or     $0x20,%al
cmp    $0x79,%al
jne    117e <ask_to_quit+0x4e>
xor    %ebx,%ebx
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Would you like to quit? \00"
@stdin = global i32 0
define i32 @ask_to_quit() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca i64
store i8* null, i8** %1
store i64 0, i64* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = call i64 @getline(i8** %1, i64* %2, i32 %5)
store i64 %6, i64* %3
%7 = load i64, i64* %3
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %0
%10 = load i8*, i8** %1
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 121
br i1 %14, label %21, label %15
15: ; preds = %9
%16 = load i8*, i8** %1
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 89
br i1 %20, label %21, label %22
21: ; preds = %15, %9
store i64 0, i64* %3
br label %22
22: ; preds = %21, %15
%23 = load i8*, i8** %1
%24 = call i32 @free(i8* %23)
br label %25
25: ; preds = %22, %0
%26 = load i64, i64* %3
%27 = trunc i64 %26 to i32
ret i32 %27
}

LLVM IR (-O2):
@.str = [25 x i8] c"Would you like to quit? \00"
@stdin = global i32 0
define i32 @ask_to_quit() {
%1 = alloca i8*
%2 = alloca i64
%3 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%4 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i64 @getline(i8** %1, i64* %2, i32 %6)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %0
%10 = load i8*, i8** %1
%11 = load i8, i8* %10
switch i8 %11, label %13 [
i8 121, label %12
i8 89, label %12
]
12: ; preds = %9, %9
br label %13
13: ; preds = %9, %12
%14 = phi i64 [ 0, %12 ], [ %7, %9 ]
%15 = call i32 @free(i8* %10)
br label %16
16: ; preds = %13, %0
%17 = phi i64 [ %14, %13 ], [ %7, %0 ]
%18 = trunc i64 %17 to i32
ret i32 %18
}