#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 /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int getYes(void) {
  char command[10];
  int yn;
  int commandDone = -1;
  while (commandDone == -1) {
    scanf("%9s", command);
    if (strcmp(command, "yes") == 0) {
      yn = 1;
      commandDone = 1;
    } else if (strcmp(command, "no") == 0) {
      yn = -1;
      commandDone = 1;
    } else {
      printf("Enter yes or no.\n");
    }
  }
  return yn;
}


x86 assembly (clang, -O0):
<getYes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0xffffffff,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11c9 <getYes+0x99>
lea    -0xa(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1050 <scanf@plt>
lea    -0xa(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1186 <getYes+0x56>
movl   $0x1,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    11c4 <getYes+0x94>
lea    -0xa(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b3 <getYes+0x83>
movl   $0xffffffff,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    11bf <getYes+0x8f>
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
jmp    11c4 <getYes+0x94>
jmp    113f <getYes+0xf>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getYes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
lea    0xe(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    $0x1,%r14d
test   %rax,%rax
je     11cb <getYes+0x9b>
lea    0xe95(%rip),%r15
lea    0xe(%rsp),%rbp
lea    0xe8c(%rip),%r12
lea    0xe7a(%rip),%r13
lea    0xe77(%rip),%rbx
nopl   (%rax)
mov    %rbp,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11c5 <getYes+0x95>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1190 <getYes+0x60>
jmp    11cb <getYes+0x9b>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%9s\00"
@.str.1 = [4 x i8] c"yes\00"
@.str.2 = [3 x i8] c"no\00"
@.str.3 = [18 x i8] c"Enter yes or no.\0A\00"
define i32 @getYes() {
%1 = alloca [10 x i8]
%2 = alloca i32
%3 = alloca i32
store i32 -1, i32* %3
br label %4
4: ; preds = %22, %0
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %23
7: ; preds = %4
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %7
store i32 1, i32* %2
store i32 1, i32* %3
br label %22
14: ; preds = %7
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 -1, i32* %2
store i32 1, i32* %3
br label %21
19: ; preds = %14
%20 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %18
br label %22
22: ; preds = %21, %13
br label %4
23: ; preds = %4
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [4 x i8] c"%9s\00"
@.str.1 = [4 x i8] c"yes\00"
@.str.2 = [3 x i8] c"no\00"
@str = [17 x i8] c"Enter yes or no.\00"
define i32 @getYes() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %0, %9
%7 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %6
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%12 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %6
14: ; preds = %6, %9, %0
%15 = phi i32 [ 1, %0 ], [ -1, %6 ], [ 1, %9 ]
ret i32 %15
}