#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 */
char a_lower(char);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int tw1_qn_answer(char *msg, int ans) {
  register int i = 0;
  char c, str[80];
  printf("%s", msg);
  while ((c = getchar()) != (int)'\n')
    str[i++] = a_lower(c);
  if (*str == 'y')
    ans = 1;
  else if (*str == 'n')
    ans = -1;
  printf("\n");
  return ans;
}


x86 assembly (clang, -O0):
<tw1_qn_answer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     118f <tw1_qn_answer+0x5f>
movsbl -0x11(%rbp),%edi
call   1050 <a_lower@plt>
mov    %al,%cl
mov    -0x10(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
cltq
mov    %cl,-0x70(%rbp,%rax,1)
jmp    1158 <tw1_qn_answer+0x28>
movsbl -0x70(%rbp),%eax
cmp    $0x79,%eax
jne    11a8 <tw1_qn_answer+0x78>
movl   $0x1,-0xc(%rbp)
jmp    11c1 <tw1_qn_answer+0x91>
movsbl -0x70(%rbp),%eax
cmp    $0x6e,%eax
jne    11bc <tw1_qn_answer+0x8c>
movl   $0xffffffff,-0xc(%rbp)
jmp    11c1 <tw1_qn_answer+0x91>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tw1_qn_answer>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
mov    %esi,%ebp
mov    %rdi,%rsi
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     11a0 <tw1_qn_answer+0x60>
mov    %rsp,%rbx
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1060 <a_lower@plt>
mov    %al,(%rbx)
xor    %eax,%eax
call   1050 <getchar@plt>
add    $0x1,%rbx
cmp    $0xa,%al
jne    1170 <tw1_qn_answer+0x30>
mov    (%rsp),%al
cmp    $0x79,%al
je     119b <tw1_qn_answer+0x5b>
cmp    $0x6e,%al
jne    11a0 <tw1_qn_answer+0x60>
mov    $0xffffffff,%ebp
jmp    11a0 <tw1_qn_answer+0x60>
mov    $0x1,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @tw1_qn_answer(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca [80 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%8 = load i8*, i8** %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %14, %2
%11 = call signext i8 (...) @getchar()
store i8 %11, i8* %6
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 10
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = load i8, i8* %6
%16 = call signext i8 @a_lower(i8 signext %15)
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 %19
store i8 %16, i8* %20
br label %10
21: ; preds = %10
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 121
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 1, i32* %4
br label %34
27: ; preds = %21
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 110
br i1 %31, label %32, label %33
32: ; preds = %27
store i32 -1, i32* %4
br label %33
33: ; preds = %32, %27
br label %34
34: ; preds = %33, %26
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @tw1_qn_answer(i8* %0, i32 %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = tail call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 10
br i1 %7, label %19, label %8
8: ; preds = %2, %8
%9 = phi i64 [ %12, %8 ], [ 0, %2 ]
%10 = phi i8 [ %14, %8 ], [ %6, %2 ]
%11 = tail call signext i8 @a_lower(i8 signext %10)
%12 = add nuw i64 %9, 1
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %9
store i8 %11, i8* %13
%14 = tail call signext i8 (...) @getchar()
%15 = icmp eq i8 %14, 10
br i1 %15, label %16, label %8
16: ; preds = %8
%17 = load i8, i8* %4
switch i8 %17, label %19 [
i8 121, label %20
i8 110, label %18
]
18: ; preds = %16
br label %20
19: ; preds = %2, %16
br label %20
20: ; preds = %16, %19, %18
%21 = phi i32 [ -1, %18 ], [ 1, %16 ], [ %1, %19 ]
%22 = tail call i32 @putchar(i32 10)
ret i32 %21
}