#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 getchar();
int /*<<< orphan*/ printf(char *, char *);
int tolower(int);
int getYesNo(char *msg) {
  int c;
  int res;
  do {
    printf("%s", msg);
    res = tolower(getchar());
    c = res;
    while (c != '\n')
      c = getchar();
  } while (res != 's' && res != 'n');
  return res == 's';
}


x86 assembly (clang, -O0):
<getYesNo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%edi
call   1050 <tolower@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
je     117c <getYesNo+0x4c>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0xc(%rbp)
jmp    1163 <getYesNo+0x33>
jmp    1181 <getYesNo+0x51>
xor    %eax,%eax
cmpl   $0x73,-0x10(%rbp)
mov    %al,-0x11(%rbp)
je     119a <getYesNo+0x6a>
cmpl   $0x6e,-0x10(%rbp)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    113c <getYesNo+0xc>
cmpl   $0x73,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getYesNo>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xec2(%rip),%r14
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%edi
call   1050 <tolower@plt>
cmp    $0xa,%eax
je     1140 <getYesNo+0x10>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
jne    1160 <getYesNo+0x30>
cmp    $0x73,%ebp
je     1176 <getYesNo+0x46>
cmp    $0x6e,%ebp
jne    1140 <getYesNo+0x10>
xor    %eax,%eax
cmp    $0x73,%ebp
sete   %al
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i32 @getYesNo(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
br label %5
5: ; preds = %23, %1
%6 = load i8*, i8** %2
%7 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call i32 (...) @getchar()
%9 = call i32 @tolower(i32 %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
store i32 %10, i32* %3
br label %11
11: ; preds = %14, %5
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 10
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 (...) @getchar()
store i32 %15, i32* %3
br label %11
16: ; preds = %11
br label %17
17: ; preds = %16
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 115
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 110
br label %23
23: ; preds = %20, %17
%24 = phi i1 [ false, %17 ], [ %22, %20 ]
br i1 %24, label %5, label %25
25: ; preds = %23
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 115
%28 = zext i1 %27 to i32
ret i32 %28
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @getYesNo(i8* %0) {
br label %2
2: ; preds = %11, %1
%3 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = tail call i32 (...) @getchar()
%5 = tail call i32 @tolower(i32 %4)
%6 = icmp eq i32 %5, 10
br i1 %6, label %11, label %7
7: ; preds = %2, %7
%8 = tail call i32 (...) @getchar()
%9 = icmp eq i32 %8, 10
br i1 %9, label %10, label %7
10: ; preds = %7
switch i32 %5, label %11 [
i32 115, label %12
i32 110, label %12
]
11: ; preds = %10, %2
br label %2
12: ; preds = %10, %10
%13 = icmp eq i32 %5, 115
%14 = zext i1 %13 to i32
ret i32 %14
}