#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 c40_getchar();
int /*<<< orphan*/ c40_printf(char *, ...);
unsigned long parity_type(void) {
  c40_printf("\n\nEven or odd parity (E/O)?");
  while (1) {
    switch (c40_getchar()) {
    case 'E':
    case 'e':
      c40_printf("\n");
      return (2);
    case 'O':
    case 'o':
      c40_printf("\n");
      return (1);
    default:
      c40_printf("%c", 7);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<parity_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1040 <c40_printf@plt>
xor    %eax,%eax
call   1030 <c40_getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
sub    $0x45,%eax
je     1183 <parity_type+0x63>
jmp    1150 <parity_type+0x30>
mov    -0xc(%rbp),%eax
sub    $0x4f,%eax
je     119e <parity_type+0x7e>
jmp    1161 <parity_type+0x41>
mov    -0xc(%rbp),%eax
sub    $0x65,%eax
je     1183 <parity_type+0x63>
jmp    1172 <parity_type+0x52>
mov    -0xc(%rbp),%eax
sub    $0x6f,%eax
je     119e <parity_type+0x7e>
jmp    11b9 <parity_type+0x99>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <c40_printf@plt>
movq   $0x2,-0x8(%rbp)
jmp    11d1 <parity_type+0xb1>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <c40_printf@plt>
movq   $0x1,-0x8(%rbp)
jmp    11d1 <parity_type+0xb1>
lea    0xe5e(%rip),%rdi
mov    $0x7,%esi
mov    $0x0,%al
call   1040 <c40_printf@plt>
jmp    1136 <parity_type+0x16>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parity_type>:
push   %rbx
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1040 <c40_printf@plt>
lea    0xee8(%rip),%rbx
jmp    114f <parity_type+0x2f>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <c40_printf@plt>
xor    %eax,%eax
call   1030 <c40_getchar@plt>
cmp    $0x64,%eax
jg     1170 <parity_type+0x50>
cmp    $0x45,%eax
je     1181 <parity_type+0x61>
cmp    $0x4f,%eax
jne    1140 <parity_type+0x20>
jmp    117a <parity_type+0x5a>
nopw   0x0(%rax,%rax,1)
cmp    $0x65,%eax
je     1181 <parity_type+0x61>
cmp    $0x6f,%eax
jne    1140 <parity_type+0x20>
mov    $0x1,%ebx
jmp    1186 <parity_type+0x66>
mov    $0x2,%ebx
lea    0xe8f(%rip),%rdi
xor    %eax,%eax
call   1040 <c40_printf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"\0A\0AEven or odd parity (E/O)?\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [3 x i8] c"%c\00"
define i64 @parity_type() {
%1 = alloca i64
%2 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %3
3: ; preds = %0, %11
%4 = call i32 (...) @c40_getchar()
switch i32 %4, label %9 [
i32 69, label %5
i32 101, label %5
i32 79, label %7
i32 111, label %7
]
5: ; preds = %3, %3
%6 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i64 2, i64* %1
br label %12
7: ; preds = %3, %3
%8 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i64 1, i64* %1
br label %12
9: ; preds = %3
%10 = call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 7)
br label %11
11: ; preds = %9
br label %3
12: ; preds = %7, %5
%13 = load i64, i64* %1
ret i64 %13
}

LLVM IR (-O2):
@.str = [28 x i8] c"\0A\0AEven or odd parity (E/O)?\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [3 x i8] c"%c\00"
define i64 @parity_type() {
%1 = tail call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %0, %4
%3 = tail call i32 (...) @c40_getchar()
switch i32 %3, label %4 [
i32 69, label %7
i32 101, label %7
i32 79, label %6
i32 111, label %6
]
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 7)
br label %2
6: ; preds = %2, %2
br label %7
7: ; preds = %2, %2, %6
%8 = phi i64 [ 1, %6 ], [ 2, %2 ], [ 2, %2 ]
%9 = tail call i32 (i8*, ...) @c40_printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i64 %8
}