#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 EXIT_SUCCESS;
int /*<<< orphan*/ _IONBF;
scalar_t__ create_message();
scalar_t__ destroy_message();
scalar_t__ edit_message();
int get_unum();
scalar_t__ print_index();
int /*<<< orphan*/ print_menu();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int choice = 0;
  srand(time(NULL));
  setvbuf(stdout, NULL, _IONBF, 0);
  while (1) {
    print_menu();
    printf("Enter Choice: ");
    choice = get_unum();
    printf("-----------------------------------------\n");
    if (choice == 1) {
      if (create_message())
        printf("-Failed to create message!\n");
      else
        printf("-Message created successfully!\n");
    } else if (choice == 2) {
      if (edit_message())
        printf("-Failed to edit message!\n");
      else
        printf("-Message has been successfully modified!\n");
    } else if (choice == 3) {
      if (destroy_message())
        printf("-Failed to destroy message!\n");
      else
        printf("-Message destroyed!\n");
    } else if (choice == 4) {
      if (print_index())
        printf("-Failed to print message!\n");
    } else if (choice == 5) {
      break;
    } else
      printf("-Invalid choice!\n");
    choice = 0;
    puts("");
  }
  printf("See you tomorrow!\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
mov    0x2e02(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   10c0 <setvbuf@plt>
mov    $0x0,%al
call   10a0 <print_menu@plt>
lea    0xdff(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   10b0 <get_unum@plt>
mov    %eax,-0x8(%rbp)
lea    0xdf8(%rip),%rdi
call   1060 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1259 <main+0xa9>
mov    $0x0,%al
call   1040 <create_message@plt>
cmp    $0x0,%rax
je     1248 <main+0x98>
lea    0xdfc(%rip),%rdi
call   1060 <printf@plt>
jmp    1254 <main+0xa4>
lea    0xe07(%rip),%rdi
call   1060 <printf@plt>
jmp    132e <main+0x17e>
cmpl   $0x2,-0x8(%rbp)
jne    1296 <main+0xe6>
mov    $0x0,%al
call   1080 <edit_message@plt>
cmp    $0x0,%rax
je     1285 <main+0xd5>
lea    0xdfb(%rip),%rdi
call   1060 <printf@plt>
jmp    1291 <main+0xe1>
lea    0xe04(%rip),%rdi
call   1060 <printf@plt>
jmp    1329 <main+0x179>
cmpl   $0x3,-0x8(%rbp)
jne    12d3 <main+0x123>
mov    $0x0,%al
call   1050 <destroy_message@plt>
cmp    $0x0,%rax
je     12c2 <main+0x112>
lea    0xe02(%rip),%rdi
call   1060 <printf@plt>
jmp    12ce <main+0x11e>
lea    0xe0e(%rip),%rdi
call   1060 <printf@plt>
jmp    1324 <main+0x174>
cmpl   $0x4,-0x8(%rbp)
jne    12ff <main+0x14f>
mov    $0x0,%al
call   10d0 <print_index@plt>
cmp    $0x0,%rax
je     12fa <main+0x14a>
lea    0xdf7(%rip),%rdi
call   1060 <printf@plt>
jmp    131f <main+0x16f>
cmpl   $0x5,-0x8(%rbp)
jne    130e <main+0x15e>
jmp    1346 <main+0x196>
lea    0xdf2(%rip),%rdi
call   1060 <printf@plt>
jmp    131f <main+0x16f>
jmp    1324 <main+0x174>
jmp    1329 <main+0x179>
jmp    132e <main+0x17e>
movl   $0x0,-0x8(%rbp)
lea    0xd7d(%rip),%rdi
call   1030 <puts@plt>
jmp    11f3 <main+0x43>
lea    0xdcc(%rip),%rdi
call   1060 <printf@plt>
mov    0x2c77(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
mov    0x2dff(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   10d0 <setvbuf@plt>
lea    0xe19(%rip),%r14
lea    0xe21(%rip),%r15
lea    0xe44(%rip),%r12
lea    0xdf0(%rip),%r13
lea    0xe59(%rip),%rbp
jmp    1244 <main+0x84>
xor    %eax,%eax
call   1060 <destroy_message@plt>
test   %rax,%rax
lea    0xe74(%rip),%rdi
lea    0xe59(%rip),%rax
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   10b0 <print_menu@plt>
mov    %r14,%rdi
call   1070 <printf@plt>
xor    %eax,%eax
call   10c0 <get_unum@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1040 <puts@plt>
add    $0xffffffff,%ebx
mov    %r12,%rdi
cmp    $0x4,%ebx
ja     1235 <main+0x75>
movslq 0x0(%r13,%rbx,4),%rax
add    %r13,%rax
jmp    *%rax
xor    %eax,%eax
call   1050 <create_message@plt>
test   %rax,%rax
lea    0xe91(%rip),%rdi
lea    0xe6b(%rip),%rax
jmp    1231 <main+0x71>
xor    %eax,%eax
call   1090 <edit_message@plt>
test   %rax,%rax
lea    0xe3f(%rip),%rdi
lea    0xe0f(%rip),%rax
jmp    1231 <main+0x71>
xor    %eax,%eax
call   10e0 <print_index@plt>
mov    %rbp,%rdi
test   %rax,%rax
jne    1235 <main+0x75>
jmp    123a <main+0x7a>
lea    0xd92(%rip),%rdi
call   1040 <puts@plt>
mov    0x2cf8(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@_IONBF = global i32 0
@.str = [15 x i8] c"Enter Choice: \00"
@.str.1 = [43 x i8] c"-----------------------------------------\0A\00"
@.str.2 = [28 x i8] c"-Failed to create message!\0A\00"
@.str.3 = [32 x i8] c"-Message created successfully!\0A\00"
@.str.4 = [26 x i8] c"-Failed to edit message!\0A\00"
@.str.5 = [42 x i8] c"-Message has been successfully modified!\0A\00"
@.str.6 = [29 x i8] c"-Failed to destroy message!\0A\00"
@.str.7 = [21 x i8] c"-Message destroyed!\0A\00"
@.str.8 = [27 x i8] c"-Failed to print message!\0A\00"
@.str.9 = [18 x i8] c"-Invalid choice!\0A\00"
@.str.10 = [1 x i8] zeroinitializer
@.str.11 = [19 x i8] c"See you tomorrow!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = call i32 @time(i32* null)
%4 = call i32 @srand(i32 %3)
%5 = load i32, i32* @stdout
%6 = load i32, i32* @_IONBF
%7 = call i32 @setvbuf(i32 %5, i32* null, i32 %6, i32 0)
br label %8
8: ; preds = %0, %64
%9 = call i32 (...) @print_menu()
%10 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (...) @get_unum()
store i32 %11, i32* %2
%12 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %23
15: ; preds = %8
%16 = call i64 (...) @create_message()
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %22
20: ; preds = %15
%21 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
br label %64
23: ; preds = %8
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 2
br i1 %25, label %26, label %34
26: ; preds = %23
%27 = call i64 (...) @edit_message()
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %33
31: ; preds = %26
%32 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
br label %33
33: ; preds = %31, %29
br label %63
34: ; preds = %23
%35 = load i32, i32* %2
%36 = icmp eq i32 %35, 3
br i1 %36, label %37, label %45
37: ; preds = %34
%38 = call i64 (...) @destroy_message()
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
br label %44
42: ; preds = %37
%43 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %44
44: ; preds = %42, %40
br label %62
45: ; preds = %34
%46 = load i32, i32* %2
%47 = icmp eq i32 %46, 4
br i1 %47, label %48, label %54
48: ; preds = %45
%49 = call i64 (...) @print_index()
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
br label %53
53: ; preds = %51, %48
br label %61
54: ; preds = %45
%55 = load i32, i32* %2
%56 = icmp eq i32 %55, 5
br i1 %56, label %57, label %58
57: ; preds = %54
br label %66
58: ; preds = %54
%59 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %60
60: ; preds = %58
br label %61
61: ; preds = %60, %53
br label %62
62: ; preds = %61, %44
br label %63
63: ; preds = %62, %33
br label %64
64: ; preds = %63, %22
store i32 0, i32* %2
%65 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
br label %8
66: ; preds = %57
%67 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%68 = load i32, i32* @EXIT_SUCCESS
ret i32 %68
}

LLVM IR (-O2):
@stdout = global i32 0
@_IONBF = global i32 0
@.str = [15 x i8] c"Enter Choice: \00"
@EXIT_SUCCESS = global i32 0
@str = [42 x i8] c"-----------------------------------------\00"
@str.12 = [17 x i8] c"-Invalid choice!\00"
@str.13 = [18 x i8] c"See you tomorrow!\00"
@str.14 = [26 x i8] c"-Failed to print message!\00"
@str.15 = [20 x i8] c"-Message destroyed!\00"
@str.16 = [28 x i8] c"-Failed to destroy message!\00"
@str.17 = [41 x i8] c"-Message has been successfully modified!\00"
@str.18 = [25 x i8] c"-Failed to edit message!\00"
@str.19 = [31 x i8] c"-Message created successfully!\00"
@str.20 = [27 x i8] c"-Failed to create message!\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = load i32, i32* @stdout
%4 = load i32, i32* @_IONBF
%5 = tail call i32 @setvbuf(i32 %3, i32* null, i32 %4, i32 0)
br label %6
6: ; preds = %29, %0
%7 = tail call i32 (...) @print_menu()
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 (...) @get_unum()
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
switch i32 %9, label %26 [
i32 1, label %11
i32 2, label %15
i32 3, label %19
i32 4, label %23
i32 5, label %31
]
11: ; preds = %6
%12 = tail call i64 (...) @create_message()
%13 = icmp eq i64 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @str.19, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str.20, i64 0, i64 0)
br label %26
15: ; preds = %6
%16 = tail call i64 (...) @edit_message()
%17 = icmp eq i64 %16, 0
%18 = select i1 %17, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @str.17, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @str.18, i64 0, i64 0)
br label %26
19: ; preds = %6
%20 = tail call i64 (...) @destroy_message()
%21 = icmp eq i64 %20, 0
%22 = select i1 %21, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @str.15, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @str.16, i64 0, i64 0)
br label %26
23: ; preds = %6
%24 = tail call i64 (...) @print_index()
%25 = icmp eq i64 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %6, %23, %19, %15, %11
%27 = phi i8* [ %14, %11 ], [ %18, %15 ], [ %22, %19 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @str.14, i64 0, i64 0), %23 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @str.12, i64 0, i64 0), %6 ]
%28 = tail call i32 @puts(i8* dereferenceable(1) %27)
br label %29
29: ; preds = %26, %23
%30 = tail call i32 @putchar(i32 10)
br label %6
31: ; preds = %6
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.13, i64 0, i64 0))
%33 = load i32, i32* @EXIT_SUCCESS
ret i32 %33
}