#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 */
typedef int /*<<< orphan*/ b;

/* Variables and functions */
int /*<<< orphan*/ clearerr(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
char tolower(char);
wanttocontinue() {
  char b[10], c;
  fprintf(stderr, "\n*** Do you want to continue? ");
  if (fgets(b, sizeof(b) - 1, stdin) == NULL)
    exit(1);
  c = tolower(b[0]);
  while (c != 'y' && c != 'n') {
    (void)clearerr(stdin);
    fprintf(stderr, "\n*** Please enter 'y' or 'n'.\n");
    fprintf(stderr, "\n*** Do you want to continue? ");
    if (fgets(b, sizeof(b) - 1, stdin) == NULL)
      exit(1);
    c = tolower(b[0]);
  }
  if (c == 'n') {
    fprintf(stderr, "\n**** ABORTING TURNIN ****\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<wanttocontinue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1040 <fprintf@plt>
lea    -0xe(%rbp),%rdi
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
mov    $0x9,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
jne    1198 <wanttocontinue+0x48>
mov    $0x1,%edi
call   1070 <exit@plt>
movsbl -0xe(%rbp),%edi
call   1060 <tolower@plt>
mov    %al,-0xf(%rbp)
movsbl -0xf(%rbp),%ecx
xor    %eax,%eax
cmp    $0x79,%ecx
mov    %al,-0x10(%rbp)
je     11c3 <wanttocontinue+0x73>
movsbl -0xf(%rbp),%eax
cmp    $0x6e,%eax
setne  %al
mov    %al,-0x10(%rbp)
mov    -0x10(%rbp),%al
test   $0x1,%al
jne    11d3 <wanttocontinue+0x83>
jmp    1247 <wanttocontinue+0xf7>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1050 <clearerr@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
lea    0xe2e(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xdfa(%rip),%rsi
call   1040 <fprintf@plt>
lea    -0xe(%rbp),%rdi
mov    0x2dd2(%rip),%rax
mov    (%rax),%edx
mov    $0x9,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
jne    1236 <wanttocontinue+0xe6>
mov    $0x1,%edi
call   1070 <exit@plt>
movsbl -0xe(%rbp),%edi
call   1060 <tolower@plt>
mov    %al,-0xf(%rbp)
jmp    11a4 <wanttocontinue+0x54>
movsbl -0xf(%rbp),%eax
cmp    $0x6e,%eax
jne    1273 <wanttocontinue+0x123>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
lea    0xdda(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wanttocontinue>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    0x2e74(%rip),%r13
mov    0x0(%r13),%edi
lea    0xe91(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e6d(%rip),%rbx
mov    (%rbx),%edx
lea    0x6(%rsp),%rdi
mov    $0x9,%esi
call   1030 <fgets@plt>
test   %rax,%rax
je     1218 <wanttocontinue+0xc8>
mov    0x6(%rsp),%al
lea    0xe7f(%rip),%r14
lea    0xe59(%rip),%r15
lea    0x6(%rsp),%r12
nopl   0x0(%rax)
movsbl %al,%edi
call   1060 <tolower@plt>
cmp    $0x79,%al
je     11fa <wanttocontinue+0xaa>
cmp    $0x6e,%al
je     1208 <wanttocontinue+0xb8>
mov    (%rbx),%edi
call   1050 <clearerr@plt>
mov    0x0(%r13),%edi
mov    %r14,%rsi
call   1040 <fprintf@plt>
mov    0x0(%r13),%edi
mov    %r15,%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edx
mov    %r12,%rdi
mov    $0x9,%esi
call   1030 <fgets@plt>
test   %rax,%rax
je     1218 <wanttocontinue+0xc8>
movzbl 0x6(%rsp),%eax
jmp    11b0 <wanttocontinue+0x60>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x0(%r13),%edi
lea    0xe2b(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"\0A*** Do you want to continue? \00"
@stdin = global i32 0
@.str.1 = [31 x i8] c"\0A*** Please enter 'y' or 'n'.\0A\00"
@.str.2 = [28 x i8] c"\0A**** ABORTING TURNIN ****\0A\00"
define i32 @wanttocontinue() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i8
%4 = load i32, i32* @stderr
%5 = call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32* @fgets(i8* %6, i32 9, i32 %7)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%14 = load i8, i8* %13
%15 = call signext i8 @tolower(i8 signext %14)
store i8 %15, i8* %3
br label %16
16: ; preds = %39, %12
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 121
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i8, i8* %3
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 110
br label %24
24: ; preds = %20, %16
%25 = phi i1 [ false, %16 ], [ %23, %20 ]
br i1 %25, label %26, label %43
26: ; preds = %24
%27 = load i32, i32* @stdin
%28 = call i32 @clearerr(i32 %27)
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%34 = load i32, i32* @stdin
%35 = call i32* @fgets(i8* %33, i32 9, i32 %34)
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %39
37: ; preds = %26
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %26
%40 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%41 = load i8, i8* %40
%42 = call signext i8 @tolower(i8 signext %41)
store i8 %42, i8* %3
br label %16
43: ; preds = %24
%44 = load i8, i8* %3
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 110
br i1 %46, label %47, label %51
47: ; preds = %43
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %43
%52 = load i32, i32* %1
ret i32 %52
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"\0A*** Do you want to continue? \00"
@stdin = global i32 0
@.str.1 = [31 x i8] c"\0A*** Please enter 'y' or 'n'.\0A\00"
@.str.2 = [28 x i8] c"\0A**** ABORTING TURNIN ****\0A\00"
define i32 @wanttocontinue() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdin
%6 = call i32* @fgets(i8* %2, i32 9, i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = load i8, i8* %2
br label %12
12: ; preds = %27, %10
%13 = phi i8 [ %28, %27 ], [ %11, %10 ]
%14 = call signext i8 @tolower(i8 signext %13)
switch i8 %14, label %15 [
i8 110, label %29
i8 121, label %33
]
15: ; preds = %12
%16 = load i32, i32* @stdin
%17 = call i32 @clearerr(i32 %16)
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* @stdin
%23 = call i32* @fgets(i8* %2, i32 9, i32 %22)
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %27
25: ; preds = %15
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %15
%28 = load i8, i8* %2
br label %12
29: ; preds = %12
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %12
ret i32 undef
}