#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*/ delay();
int menu();
int /*<<< orphan*/ puts(char *);
int main(int argc, char *argv[]) {
  int command = 0;
  while (command != 5) {
    command = menu();
    switch (command) {
    case 1: {
      puts("\nExecuting task A.");
      delay();
      break;
    }
    case 2: {
      puts("\nExecuting task B.");
      delay();
      break;
    }
    case 3: {
      puts("\nExecuting task C.");
      delay();
      break;
    }
    case 4: {
      puts("\nExecuting task D.");
      delay();
      break;
    }
    case 5: {
      puts("\nExiting program now...\n");
      delay();
      break;
    }
    default: {
      puts("\nInvalid choice, try again.");
    }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
je     1213 <main+0xe3>
xor    %eax,%eax
call   1040 <menu@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x4,%eax
ja     1202 <main+0xd2>
mov    -0x20(%rbp),%rax
lea    0xe7f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1050 <delay@plt>
jmp    120e <main+0xde>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1050 <delay@plt>
jmp    120e <main+0xde>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1050 <delay@plt>
jmp    120e <main+0xde>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1050 <delay@plt>
jmp    120e <main+0xde>
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1050 <delay@plt>
jmp    120e <main+0xde>
lea    0xe70(%rip),%rdi
call   1030 <puts@plt>
jmp    114d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf37(%rip),%r14
lea    0xeb7(%rip),%rbp
lea    0xec4(%rip),%r15
lea    0xed0(%rip),%r12
lea    0xedc(%rip),%r13
lea    0xee8(%rip),%rbx
jmp    1176 <main+0x46>
mov    %r15,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
call   1040 <menu@plt>
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     1194 <main+0x64>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    %r12,%rdi
jmp    116a <main+0x3a>
mov    %r14,%rdi
call   1030 <puts@plt>
jmp    1176 <main+0x46>
mov    %r13,%rdi
jmp    116a <main+0x3a>
mov    %rbx,%rdi
jmp    116a <main+0x3a>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <delay@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"\0AExecuting task A.\00"
@.str.1 = [19 x i8] c"\0AExecuting task B.\00"
@.str.2 = [19 x i8] c"\0AExecuting task C.\00"
@.str.3 = [19 x i8] c"\0AExecuting task D.\00"
@.str.4 = [25 x i8] c"\0AExiting program now...\0A\00"
@.str.5 = [28 x i8] c"\0AInvalid choice, try again.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %7
7: ; preds = %30, %2
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, 5
br i1 %9, label %10, label %31
10: ; preds = %7
%11 = call i32 (...) @menu()
store i32 %11, i32* %6
%12 = load i32, i32* %6
switch i32 %12, label %28 [
i32 1, label %13
i32 2, label %16
i32 3, label %19
i32 4, label %22
i32 5, label %25
]
13: ; preds = %10
%14 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (...) @delay()
br label %30
16: ; preds = %10
%17 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 (...) @delay()
br label %30
19: ; preds = %10
%20 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (...) @delay()
br label %30
22: ; preds = %10
%23 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 (...) @delay()
br label %30
25: ; preds = %10
%26 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 (...) @delay()
br label %30
28: ; preds = %10
%29 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %30
30: ; preds = %28, %25, %22, %19, %16, %13
br label %7
31: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"\0AExecuting task A.\00"
@.str.1 = [19 x i8] c"\0AExecuting task B.\00"
@.str.2 = [19 x i8] c"\0AExecuting task C.\00"
@.str.3 = [19 x i8] c"\0AExecuting task D.\00"
@.str.4 = [25 x i8] c"\0AExiting program now...\0A\00"
@.str.5 = [28 x i8] c"\0AInvalid choice, try again.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %19, %2
%4 = tail call i32 (...) @menu()
switch i32 %4, label %17 [
i32 1, label %5
i32 2, label %8
i32 3, label %11
i32 4, label %14
i32 5, label %20
]
5: ; preds = %3
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (...) @delay()
br label %19
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 (...) @delay()
br label %19
11: ; preds = %3
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 (...) @delay()
br label %19
14: ; preds = %3
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%16 = tail call i32 (...) @delay()
br label %19
17: ; preds = %3
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %19
19: ; preds = %17, %14, %11, %8, %5
br label %3
20: ; preds = %3
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%22 = tail call i32 (...) @delay()
ret i32 0
}