#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int prompt_continue(void) {
  char input[64];
  char *t;
  int valid;
  while (1) {
    printf("Enter C to continue, Q to stop printing (c/q): ");
    fflush(stdout);
    fgets(input, 64, stdin);
    valid = 1;
    for (t = input + 1; t < input + 64; t++) {
      if (*t == 0)
        break;
      ;
      if (*t > 20) {
        valid = 0;
        break;
      }
    }
    if (valid) {
      switch (*input) {
      case 'c':
      case 'C':
      case '\n':
        return 1;
      case 'q':
      case 'Q':
        return 0;
      }
    }
    printf("Please enter C or Q\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<prompt_continue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    -0x50(%rbp),%rdi
mov    0x2e8b(%rip),%rax
mov    (%rax),%edx
mov    $0x40,%esi
call   1040 <fgets@plt>
movl   $0x1,-0x5c(%rbp)
lea    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
lea    -0x50(%rbp),%rcx
add    $0x40,%rcx
cmp    %rcx,%rax
jae    11d8 <prompt_continue+0xa8>
mov    -0x58(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11a6 <prompt_continue+0x76>
jmp    11d8 <prompt_continue+0xa8>
mov    -0x58(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x14,%eax
jle    11c2 <prompt_continue+0x92>
movl   $0x0,-0x5c(%rbp)
jmp    11d8 <prompt_continue+0xa8>
jmp    11c7 <prompt_continue+0x97>
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    117c <prompt_continue+0x4c>
cmpl   $0x0,-0x5c(%rbp)
je     1258 <prompt_continue+0x128>
movsbl -0x50(%rbp),%eax
mov    %eax,-0x60(%rbp)
sub    $0xa,%eax
je     123b <prompt_continue+0x10b>
jmp    11f7 <prompt_continue+0xc7>
mov    -0x60(%rbp),%eax
sub    $0x43,%eax
je     123b <prompt_continue+0x10b>
jmp    1208 <prompt_continue+0xd8>
mov    -0x60(%rbp),%eax
sub    $0x51,%eax
je     1247 <prompt_continue+0x117>
jmp    1219 <prompt_continue+0xe9>
mov    -0x60(%rbp),%eax
sub    $0x63,%eax
je     123b <prompt_continue+0x10b>
jmp    122a <prompt_continue+0xfa>
mov    -0x60(%rbp),%eax
sub    $0x71,%eax
je     1247 <prompt_continue+0x117>
jmp    1253 <prompt_continue+0x123>
movl   $0x1,-0x4(%rbp)
jmp    1269 <prompt_continue+0x139>
movl   $0x0,-0x4(%rbp)
jmp    1269 <prompt_continue+0x139>
jmp    1258 <prompt_continue+0x128>
lea    0xdd1(%rip),%rdi
call   1030 <printf@plt>
jmp    1138 <prompt_continue+0x8>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prompt_continue>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0x1(%rsp),%r12
lea    0x40(%rsp),%rbx
lea    0xea1(%rip),%r14
mov    0x2e72(%rip),%rbp
mov    0x2e7b(%rip),%r15
mov    %rsp,%r13
jmp    118c <prompt_continue+0x4c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    0x0(%rbp),%edi
call   1060 <fflush@plt>
mov    (%r15),%edx
mov    %r13,%rdi
mov    $0x40,%esi
call   1050 <fgets@plt>
mov    %r12,%rax
nop
movzbl (%rax),%ecx
test   %cl,%cl
je     11c5 <prompt_continue+0x85>
cmp    $0x14,%cl
jg     1180 <prompt_continue+0x40>
add    $0x1,%rax
cmp    %rbx,%rax
jb     11b0 <prompt_continue+0x70>
movsbl (%rsp),%eax
cmp    $0x50,%eax
jle    11e0 <prompt_continue+0xa0>
cmp    $0x51,%eax
je     11f1 <prompt_continue+0xb1>
cmp    $0x63,%eax
je     11ea <prompt_continue+0xaa>
cmp    $0x71,%eax
jne    1180 <prompt_continue+0x40>
jmp    11f1 <prompt_continue+0xb1>
nop
cmp    $0xa,%eax
je     11ea <prompt_continue+0xaa>
cmp    $0x43,%eax
jne    1180 <prompt_continue+0x40>
mov    $0x1,%eax
jmp    11f3 <prompt_continue+0xb3>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"Enter C to continue, Q to stop printing (c/q): \00"
@stdout = global i32 0
@stdin = global i32 0
@.str.1 = [21 x i8] c"Please enter C or Q\0A\00"
define i32 @prompt_continue() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca i8*
%4 = alloca i32
br label %5
5: ; preds = %0, %45
%6 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdout
%8 = call i32 @fflush(i32 %7)
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %9, i32 64, i32 %10)
store i32 1, i32* %4
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds i8, i8* %12, i64 1
store i8* %13, i8** %3
br label %14
14: ; preds = %32, %5
%15 = load i8*, i8** %3
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%17 = getelementptr inbounds i8, i8* %16, i64 64
%18 = icmp ult i8* %15, %17
br i1 %18, label %19, label %35
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19
br label %35
25: ; preds = %19
%26 = load i8*, i8** %3
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp sgt i32 %28, 20
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 0, i32* %4
br label %35
31: ; preds = %25
br label %32
32: ; preds = %31
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
br label %14
35: ; preds = %30, %24, %14
%36 = load i32, i32* %4
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %35
%39 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
switch i32 %41, label %44 [
i32 99, label %42
i32 67, label %42
i32 10, label %42
i32 113, label %43
i32 81, label %43
]
42: ; preds = %38, %38, %38
store i32 1, i32* %1
br label %47
43: ; preds = %38, %38
store i32 0, i32* %1
br label %47
44: ; preds = %38
br label %45
45: ; preds = %44, %35
%46 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %5
47: ; preds = %43, %42
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [48 x i8] c"Enter C to continue, Q to stop printing (c/q): \00"
@stdout = global i32 0
@stdin = global i32 0
@str = [20 x i8] c"Please enter C or Q\00"
define i32 @prompt_continue() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 1
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 64
br label %5
5: ; preds = %23, %0
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdout
%8 = call i32 @fflush(i32 %7)
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %2, i32 64, i32 %9)
br label %13
11: ; preds = %17
%12 = icmp ult i8* %19, %4
br i1 %12, label %13, label %20
13: ; preds = %5, %11
%14 = phi i8* [ %3, %5 ], [ %19, %11 ]
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %13
%18 = icmp sgt i8 %15, 20
%19 = getelementptr inbounds i8, i8* %14, i64 1
br i1 %18, label %23, label %11
20: ; preds = %11, %13
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
switch i32 %22, label %23 [
i32 99, label %25
i32 67, label %25
i32 10, label %25
i32 113, label %26
i32 81, label %26
]
23: ; preds = %17, %20
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %5
25: ; preds = %20, %20, %20
br label %26
26: ; preds = %20, %20, %25
%27 = phi i32 [ 1, %25 ], [ 0, %20 ], [ 0, %20 ]
ret i32 %27
}