#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*/ flushall();
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
main() {
  char ch;
  printf("Please enter your marital status\n");
  printf("Options are:\n(W)\n(M)\n(S)\n(E)\n(D)\n");
  scanf("%c", &ch);
  flushall();
  switch (ch) {
  case 'S': {
    printf("Single");
    break;
  }
  case 'M': {
    printf("Married");
    break;
  }
  case 'W': {
    printf("Widowed");
    break;
  }
  case 'E': {
    printf("Seperated");
    break;
  }
  case 'D': {
    printf("Divorced");
    break;
  }
  default: {
    printf("Error: Invalid code");
  }
  }
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xefa(%rip),%rdi
call   1030 <printf@plt>
lea    0xf10(%rip),%rdi
call   1030 <printf@plt>
lea    0xf26(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1040 <flushall@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffbc,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x13,%eax
ja     11fd <main+0xbd>
mov    -0x10(%rbp),%rax
lea    0xe61(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xee8(%rip),%rdi
call   1030 <printf@plt>
jmp    1209 <main+0xc9>
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
jmp    1209 <main+0xc9>
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
jmp    1209 <main+0xc9>
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
jmp    1209 <main+0xc9>
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
jmp    1209 <main+0xc9>
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf39(%rip),%rdi
call   1030 <puts@plt>
lea    0xf4e(%rip),%rdi
call   1030 <puts@plt>
lea    0xee0(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
movsbl 0x7(%rsp),%eax
add    $0xffffffbc,%eax
cmp    $0x13,%eax
ja     11b7 <main+0x67>
lea    0xebe(%rip),%rdi
lea    0xe64(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec8(%rip),%rdi
jmp    11d0 <main+0x80>
lea    0xeb5(%rip),%rdi
jmp    11d0 <main+0x80>
lea    0xebf(%rip),%rdi
jmp    11d0 <main+0x80>
lea    0xe93(%rip),%rdi
jmp    11d0 <main+0x80>
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Please enter your marital status\0A\00"
@.str.1 = [34 x i8] c"Options are:\0A(W)\0A(M)\0A(S)\0A(E)\0A(D)\0A\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [7 x i8] c"Single\00"
@.str.4 = [8 x i8] c"Married\00"
@.str.5 = [8 x i8] c"Widowed\00"
@.str.6 = [10 x i8] c"Seperated\00"
@.str.7 = [9 x i8] c"Divorced\00"
@.str.8 = [20 x i8] c"Error: Invalid code\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%6 = call i32 (...) @flushall()
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
switch i32 %8, label %19 [
i32 83, label %9
i32 77, label %11
i32 87, label %13
i32 69, label %15
i32 68, label %17
]
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %21
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %21
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %21
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
br label %21
17: ; preds = %0
%18 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %21
19: ; preds = %0
%20 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %21
21: ; preds = %19, %17, %15, %13, %11, %9
%22 = call i32 (...) @getchar()
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [7 x i8] c"Single\00"
@.str.4 = [8 x i8] c"Married\00"
@.str.5 = [8 x i8] c"Widowed\00"
@.str.6 = [10 x i8] c"Seperated\00"
@.str.7 = [9 x i8] c"Divorced\00"
@.str.8 = [20 x i8] c"Error: Invalid code\00"
@str = [33 x i8] c"Please enter your marital status\00"
@str.9 = [33 x i8] c"Options are:\0A(W)\0A(M)\0A(S)\0A(E)\0A(D)\00"
define i32 @main() {
%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 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.9, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%5 = call i32 (...) @flushall()
%6 = load i8, i8* %1
%7 = sext i8 %6 to i32
switch i32 %7, label %12 [
i32 83, label %13
i32 77, label %8
i32 87, label %9
i32 69, label %10
i32 68, label %11
]
8: ; preds = %0
br label %13
9: ; preds = %0
br label %13
10: ; preds = %0
br label %13
11: ; preds = %0
br label %13
12: ; preds = %0
br label %13
13: ; preds = %0, %12, %11, %10, %9, %8
%14 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), %12 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), %11 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), %10 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), %9 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %8 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), %0 ]
%15 = call i32 @printf(i8* dereferenceable(1) %14)
%16 = call i32 (...) @getchar()
ret i32 0
}