#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 *, char *);
int main() {
  char resp, enter;
  printf("break Command Example 3\n\n");
  do {
    printf("Please enter either A, B or C: ");
    scanf("%c%c", &resp, &enter);
    if (resp == 'A' || resp == 'B' || resp == 'C')
      break;
    printf("Invalid response, try again.\n");
  } while (1);
  printf("Your valid entry was %c.\n\n", resp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee8(%rip),%rdi
lea    -0x5(%rbp),%rsi
lea    -0x6(%rbp),%rdx
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
je     1186 <main+0x66>
movsbl -0x5(%rbp),%eax
cmp    $0x42,%eax
je     1186 <main+0x66>
movsbl -0x5(%rbp),%eax
cmp    $0x43,%eax
jne    118b <main+0x6b>
jmp    11a8 <main+0x88>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%al
test   $0x1,%al
jne    113d <main+0x1d>
jmp    11a8 <main+0x88>
movsbl -0x5(%rbp),%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xefc(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
lea    0xe(%rsp),%rsi
lea    0xf(%rsp),%rdx
call   1050 <scanf@plt>
mov    0xe(%rsp),%al
lea    -0x41(%rax),%ecx
cmp    $0x3,%cl
jb     11cd <main+0x9d>
lea    0xed9(%rip),%r14
lea    0xe79(%rip),%r15
lea    0xe92(%rip),%r12
lea    0xe(%rsp),%r13
lea    0xf(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1050 <scanf@plt>
movzbl 0xe(%rsp),%eax
lea    -0x41(%rax),%ecx
cmp    $0x2,%cl
ja     11a0 <main+0x70>
movzbl %al,%esi
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"break Command Example 3\0A\0A\00"
@.str.1 = [32 x i8] c"Please enter either A, B or C: \00"
@.str.2 = [5 x i8] c"%c%c\00"
@.str.3 = [30 x i8] c"Invalid response, try again.\0A\00"
@.str.4 = [27 x i8] c"Your valid entry was %c.\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %22, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %2, i8* %3)
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 65
br i1 %10, label %19, label %11
11: ; preds = %5
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 66
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 67
br i1 %18, label %19, label %20
19: ; preds = %15, %11, %5
br label %23
20: ; preds = %15
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %20
br i1 true, label %5, label %23
23: ; preds = %22, %19
%24 = load i8, i8* %2
%25 = sext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %25)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [32 x i8] c"Please enter either A, B or C: \00"
@.str.2 = [5 x i8] c"%c%c\00"
@.str.4 = [27 x i8] c"Your valid entry was %c.\0A\0A\00"
@str = [25 x i8] c"break Command Example 3\0A\00"
@str.5 = [29 x i8] c"Invalid response, try again.\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i8
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %2)
%6 = load i8, i8* %1
%7 = add i8 %6, -65
%8 = icmp ult i8 %7, 3
br i1 %8, label %16, label %9
9: ; preds = %0, %9
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.5, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %2)
%13 = load i8, i8* %1
%14 = add i8 %13, -65
%15 = icmp ult i8 %14, 3
br i1 %15, label %16, label %9
16: ; preds = %9, %0
%17 = phi i8 [ %6, %0 ], [ %13, %9 ]
%18 = zext i8 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %18)
ret i32 0
}