#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 *);
int yesno() {
  char answer;
  printf("Would you like to continue(y/n)?\n");
  scanf(" %c", &answer);
  printf("You answered %c\n", answer);
  while (answer == 'y' || answer == 'Y') {
    printf("Success!");
    printf("\nDo you want to try again(y/n)?\n");
    scanf(" %c", &answer);
    printf("Your answer is %c\n", answer);
  }
  printf("GoodBye!\n");
  return 0;
}


x86 assembly (clang, -O0):
<yesno>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
lea    -0x1(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x1(%rbp),%esi
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0x79,%ecx
mov    %al,-0x2(%rbp)
je     1177 <yesno+0x57>
movsbl -0x1(%rbp),%eax
cmp    $0x59,%eax
sete   %al
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
test   $0x1,%al
jne    1187 <yesno+0x67>
jmp    11ca <yesno+0xaa>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe78(%rip),%rdi
lea    -0x1(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x1(%rbp),%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1158 <yesno+0x38>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yesno>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb0(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1050 <scanf@plt>
movsbl 0xf(%rsp),%esi
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xf(%rsp),%al
and    $0xdf,%al
cmp    $0x59,%al
jne    11d7 <yesno+0xa7>
lea    0xe97(%rip),%r14
lea    0xed6(%rip),%r15
lea    0xe74(%rip),%r12
lea    0xf(%rsp),%r13
lea    0xe86(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
movsbl 0xf(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0xf(%rsp),%eax
and    $0xdf,%al
cmp    $0x59,%al
je     11a0 <yesno+0x70>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Would you like to continue(y/n)?\0A\00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [17 x i8] c"You answered %c\0A\00"
@.str.3 = [9 x i8] c"Success!\00"
@.str.4 = [33 x i8] c"\0ADo you want to try again(y/n)?\0A\00"
@.str.5 = [19 x i8] c"Your answer is %c\0A\00"
@.str.6 = [10 x i8] c"GoodBye!\0A\00"
define i32 @yesno() {
%1 = alloca i8
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%4 = load i8, i8* %1
%5 = sext i8 %4 to i32
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %5)
br label %7
7: ; preds = %17, %0
%8 = load i8, i8* %1
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 121
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = load i8, i8* %1
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 89
br label %15
15: ; preds = %11, %7
%16 = phi i1 [ true, %7 ], [ %14, %11 ]
br i1 %16, label %17, label %24
17: ; preds = %15
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%21 = load i8, i8* %1
%22 = sext i8 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %22)
br label %7
24: ; preds = %15
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [17 x i8] c"You answered %c\0A\00"
@.str.3 = [9 x i8] c"Success!\00"
@.str.5 = [19 x i8] c"Your answer is %c\0A\00"
@str = [33 x i8] c"Would you like to continue(y/n)?\00"
@str.7 = [9 x i8] c"GoodBye!\00"
@str.8 = [32 x i8] c"\0ADo you want to try again(y/n)?\00"
define i32 @yesno() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%4 = load i8, i8* %1
%5 = sext i8 %4 to i32
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = load i8, i8* %1
%8 = and i8 %7, -33
%9 = icmp eq i8 %8, 89
br i1 %9, label %10, label %20
10: ; preds = %0, %10
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.8, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%14 = load i8, i8* %1
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %15)
%17 = load i8, i8* %1
%18 = and i8 %17, -33
%19 = icmp eq i8 %18, 89
br i1 %19, label %10, label %20
20: ; preds = %10, %0
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0))
ret i32 0
}