#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 fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int user_ack(int def) {
  char s[2];
  int ret;
  if (!fgets(s, 2, stdin))
    return 0;
  switch (s[0]) {
  case 'y':
  case 'Y':
    ret = 1;
    break;
  case 'n':
  case 'N':
    ret = 0;
    break;
  default:
    ret = def;
  }
  while (s[0] != '\n') {
    int c = fgetc(stdin);
    if (c == EOF) {
      ret = 0;
      break;
    }
    s[0] = c;
  }
  return ret;
}


x86 assembly (clang, -O0):
<user_ack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
lea    -0xa(%rbp),%rdi
mov    0x2eb2(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%esi
call   1040 <fgets@plt>
cmp    $0x0,%eax
jne    1157 <user_ack+0x37>
movl   $0x0,-0x4(%rbp)
jmp    120f <user_ack+0xef>
movsbl -0xa(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x4e,%eax
je     11ab <user_ack+0x8b>
jmp    116c <user_ack+0x4c>
mov    -0x18(%rbp),%eax
sub    $0x59,%eax
je     119f <user_ack+0x7f>
jmp    117d <user_ack+0x5d>
mov    -0x18(%rbp),%eax
sub    $0x6e,%eax
je     11ab <user_ack+0x8b>
jmp    118e <user_ack+0x6e>
mov    -0x18(%rbp),%eax
sub    $0x79,%eax
jne    11b7 <user_ack+0x97>
jmp    119f <user_ack+0x7f>
movl   $0x1,-0x10(%rbp)
jmp    11bd <user_ack+0x9d>
movl   $0x0,-0x10(%rbp)
jmp    11bd <user_ack+0x9d>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11c2 <user_ack+0xa2>
movsbl -0xa(%rbp),%eax
cmp    $0xa,%eax
je     1209 <user_ack+0xe9>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2df6(%rip),%rcx
cmp    (%rcx),%eax
jne    11fe <user_ack+0xde>
movl   $0x0,-0x10(%rbp)
jmp    1209 <user_ack+0xe9>
mov    -0x14(%rbp),%eax
mov    %al,-0xa(%rbp)
jmp    11c2 <user_ack+0xa2>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<user_ack>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r14d
mov    0x2eb2(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0xe(%rsp),%rdi
mov    $0x2,%esi
call   1040 <fgets@plt>
xor    %r12d,%r12d
test   %eax,%eax
je     11a7 <user_ack+0x87>
mov    0xe(%rsp),%al
movsbl %al,%ecx
mov    $0x1,%r15d
cmp    $0x6d,%ecx
jg     116d <user_ack+0x4d>
cmp    $0x4e,%ecx
je     1177 <user_ack+0x57>
cmp    $0x59,%ecx
je     117a <user_ack+0x5a>
jmp    1180 <user_ack+0x60>
cmp    $0x79,%ecx
je     117a <user_ack+0x5a>
cmp    $0x6e,%ecx
jne    1180 <user_ack+0x60>
xor    %r15d,%r15d
cmp    $0xa,%al
jne    1187 <user_ack+0x67>
jmp    11a4 <user_ack+0x84>
mov    %r14d,%r15d
cmp    $0xa,%al
je     11a4 <user_ack+0x84>
mov    0x2e52(%rip),%rbx
xchg   %ax,%ax
mov    0x0(%rbp),%edi
call   1030 <fgetc@plt>
cmp    (%rbx),%eax
je     11a7 <user_ack+0x87>
mov    %al,0xe(%rsp)
cmp    $0xa,%al
jne    1190 <user_ack+0x70>
mov    %r15d,%r12d
mov    %r12d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i32 0
define i32 @user_ack(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x i8]
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 2, i32 %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %1
store i32 0, i32* %2
br label %39
12: ; preds = %1
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %18 [
i32 121, label %16
i32 89, label %16
i32 110, label %17
i32 78, label %17
]
16: ; preds = %12, %12
store i32 1, i32* %5
br label %20
17: ; preds = %12, %12
store i32 0, i32* %5
br label %20
18: ; preds = %12
%19 = load i32, i32* %3
store i32 %19, i32* %5
br label %20
20: ; preds = %18, %17, %16
br label %21
21: ; preds = %33, %20
%22 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 10
br i1 %25, label %26, label %37
26: ; preds = %21
%27 = load i32, i32* @stdin
%28 = call i32 @fgetc(i32 %27)
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = load i32, i32* @EOF
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %33
32: ; preds = %26
store i32 0, i32* %5
br label %37
33: ; preds = %26
%34 = load i32, i32* %6
%35 = trunc i32 %34 to i8
%36 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
store i8 %35, i8* %36
br label %21
37: ; preds = %32, %21
%38 = load i32, i32* %5
store i32 %38, i32* %2
br label %39
39: ; preds = %37, %11
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
define i32 @user_ack(i32 %0) {
%2 = alloca [2 x i8]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %3, i32 2, i32 %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %23, label %7
7: ; preds = %1
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
switch i32 %9, label %11 [
i32 121, label %12
i32 89, label %12
i32 110, label %10
i32 78, label %10
]
10: ; preds = %7, %7
br label %12
11: ; preds = %7
br label %12
12: ; preds = %7, %7, %11, %10
%13 = phi i32 [ %0, %11 ], [ 0, %10 ], [ 1, %7 ], [ 1, %7 ]
%14 = icmp eq i8 %8, 10
br i1 %14, label %23, label %15
15: ; preds = %12, %20
%16 = load i32, i32* @stdin
%17 = call i32 @fgetc(i32 %16)
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %23, label %20
20: ; preds = %15
%21 = trunc i32 %17 to i8
store i8 %21, i8* %3
%22 = icmp eq i8 %21, 10
br i1 %22, label %23, label %15
23: ; preds = %20, %15, %12, %1
%24 = phi i32 [ 0, %1 ], [ %13, %12 ], [ %13, %20 ], [ 0, %15 ]
ret i32 %24
}