#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 */
int EOF;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ printf(char *);
extern void f(int signum) {
  printf("\tInterrupted! OK to quit (y/n)?");
  int c = getchar();
  if (c == EOF || c == 'y') {
    exit(EXIT_SUCCESS);
  }
  while (getchar() != '\n')
    ;
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%eax
je     1170 <f+0x40>
cmpl   $0x79,-0x8(%rbp)
jne    117e <f+0x4e>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    1183 <f+0x53>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     119b <f+0x6b>
jmp    1183 <f+0x53>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
push   %rax
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x79,%al
je     116d <f+0x3d>
movsbl %al,%eax
mov    0x2e96(%rip),%rcx
cmp    %eax,(%rcx)
je     116d <f+0x3d>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    1160 <f+0x30>
pop    %rax
ret
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"\09Interrupted! OK to quit (y/n)?\00"
@EOF = global i32 0
@EXIT_SUCCESS = global i32 0
define void @f(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%5 = call signext i8 (...) @getchar()
%6 = sext i8 %5 to i32
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
br i1 %9, label %13, label %10
10: ; preds = %1
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 121
br i1 %12, label %13, label %16
13: ; preds = %10, %1
%14 = load i32, i32* @EXIT_SUCCESS
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %10
br label %17
17: ; preds = %21, %16
%18 = call signext i8 (...) @getchar()
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 10
br i1 %20, label %21, label %22
21: ; preds = %17
br label %17
22: ; preds = %17
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"\09Interrupted! OK to quit (y/n)?\00"
@EOF = global i32 0
@EXIT_SUCCESS = global i32 0
define void @f(i32 %0) {
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%3 = tail call signext i8 (...) @getchar()
%4 = sext i8 %3 to i32
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %5, %4
%7 = icmp eq i8 %3, 121
%8 = or i1 %7, %6
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* @EXIT_SUCCESS
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %1, %12
%13 = tail call signext i8 (...) @getchar()
%14 = icmp eq i8 %13, 10
br i1 %14, label %15, label %12
15: ; preds = %12
ret void
}