#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*/ printRectangle(int, int);
int /*<<< orphan*/ printStar();
int /*<<< orphan*/ printTriangle(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a;
LOOP:
  printf("Enter a number\n");
  scanf("%d", &a);
  printf("a = %d\n", a);
  switch (a) {
  case 0: {
    printStar();
    break;
  }
  case 1: {
    printTriangle(5);
    break;
  }
  case 2: {
    printRectangle(4, 5);
    break;
  }
  case 3: {
    printf("END\n");
    break;
  }
  default: {
    goto LOOP;
  }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x11(%rbp)
call   1040 <printf@plt>
lea    0xea9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x11(%rbp),%al
mov    -0x8(%rbp),%esi
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x3,%rax
ja     11f9 <main+0xa9>
mov    -0x10(%rbp),%rax
lea    0xe52(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1030 <printStar@plt>
jmp    11fe <main+0xae>
mov    $0x5,%edi
call   1050 <printTriangle@plt>
jmp    11fe <main+0xae>
mov    $0x4,%edi
mov    $0x5,%esi
call   1060 <printRectangle@plt>
jmp    11fe <main+0xae>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fe <main+0xae>
jmp    115f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeac(%rip),%r14
lea    0xe9a(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe91(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%rax
ja     1190 <main+0x30>
lea    0xe3e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1040 <printStar@plt>
jmp    11fd <main+0x9d>
mov    $0x4,%edi
mov    $0x5,%esi
call   1070 <printRectangle@plt>
jmp    11fd <main+0x9d>
lea    0xe3e(%rip),%rdi
call   1030 <puts@plt>
jmp    11fd <main+0x9d>
mov    $0x5,%edi
call   1060 <printTriangle@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Enter a number\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [8 x i8] c"a = %d\0A\00"
@.str.3 = [5 x i8] c"END\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %17, %0
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %2
switch i32 %8, label %17 [
i32 0, label %9
i32 1, label %11
i32 2, label %13
i32 3, label %15
]
9: ; preds = %3
%10 = call i32 (...) @printStar()
br label %18
11: ; preds = %3
%12 = call i32 @printTriangle(i32 5)
br label %18
13: ; preds = %3
%14 = call i32 @printRectangle(i32 4, i32 5)
br label %18
15: ; preds = %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %18
17: ; preds = %3
br label %3
18: ; preds = %15, %13, %11, %9
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [8 x i8] c"a = %d\0A\00"
@str = [15 x i8] c"Enter a number\00"
@str.4 = [4 x i8] c"END\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %1
switch i32 %8, label %3 [
i32 0, label %9
i32 1, label %11
i32 2, label %13
i32 3, label %15
]
9: ; preds = %3
%10 = call i32 (...) @printStar()
br label %17
11: ; preds = %3
%12 = call i32 @printTriangle(i32 5)
br label %17
13: ; preds = %3
%14 = call i32 @printRectangle(i32 4, i32 5)
br label %17
15: ; preds = %3
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.4, i64 0, i64 0))
br label %17
17: ; preds = %15, %13, %11, %9
ret i32 0
}