#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*/ block();
int /*<<< orphan*/ create();
int /*<<< orphan*/ display();
int /*<<< orphan*/ kill();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ schedule();
int /*<<< orphan*/ wakeup();
int main() {
  int run = 1;
  while (run) {
    printf("######ProcessSimulation:  menu #####\n1. create process  2. kill "
           "process\n3. block process   4. wakeup process\n5. just run        "
           "0. exit\n");
    printf("##########-->");
    int choice = 5;
    scanf("%d", &choice);
    switch (choice) {
    case 1: {
      create();
      break;
    }
    case 2: {
      kill();
      break;
    }
    case 3: {
      block();
      break;
    }
    case 4: {
      wakeup();
      break;
    }
    case 5: {
      break;
    }
    case 0: {
      run = 0;
      break;
    }
    default: {
      printf("input error! Don't test my robustness ,,,\n");
      continue;
      break;
    }
    }
    if (run) {
      schedule();
      display();
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1263 <main+0xe3>
lea    0xe71(%rip),%rdi
call   1060 <printf@plt>
lea    0xeee(%rip),%rdi
call   1060 <printf@plt>
movl   $0x5,-0xc(%rbp)
lea    0xee9(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x5,%rax
ja     1235 <main+0xb5>
mov    -0x18(%rbp),%rax
lea    0xe15(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1070 <create@plt>
jmp    1246 <main+0xc6>
mov    $0x0,%al
call   1080 <kill@plt>
jmp    1246 <main+0xc6>
mov    $0x0,%al
call   10a0 <block@plt>
jmp    1246 <main+0xc6>
mov    $0x0,%al
call   1040 <wakeup@plt>
jmp    1246 <main+0xc6>
jmp    1246 <main+0xc6>
movl   $0x0,-0x8(%rbp)
jmp    1246 <main+0xc6>
lea    0xe76(%rip),%rdi
call   1060 <printf@plt>
jmp    1196 <main+0x16>
cmpl   $0x0,-0x8(%rbp)
je     125e <main+0xde>
mov    $0x0,%al
call   1030 <schedule@plt>
mov    $0x0,%al
call   1050 <display@plt>
jmp    1196 <main+0x16>
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    0xe87(%rip),%r14
lea    0xe6f(%rip),%r15
lea    0xe76(%rip),%r12
lea    0x4(%rsp),%rbx
lea    0xef5(%rip),%r13
lea    0xe3d(%rip),%rbp
jmp    11de <main+0x4e>
xor    %eax,%eax
call   1080 <create@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <schedule@plt>
xor    %eax,%eax
call   1060 <display@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   1070 <printf@plt>
movl   $0x5,0x4(%rsp)
mov    %r12,%rdi
mov    %rbx,%rsi
call   10a0 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x5,%rax
ja     121e <main+0x8e>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
xor    %eax,%eax
call   1090 <kill@plt>
jmp    11d0 <main+0x40>
mov    %r13,%rdi
call   1050 <puts@plt>
jmp    11de <main+0x4e>
xor    %eax,%eax
call   10b0 <block@plt>
jmp    11d0 <main+0x40>
xor    %eax,%eax
call   1040 <wakeup@plt>
jmp    11d0 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [137 x i8] c"######ProcessSimulation: menu #####\0A1. create process 2. kill process\0A3. block process 4. wakeup process\0A5. just run 0. exit\0A\00"
@.str.1 = [14 x i8] c"##########-->\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [43 x i8] c"input error! Don't test my robustness ,,,\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
br label %4
4: ; preds = %30, %22, %0
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %31
7: ; preds = %4
%8 = call i32 @printf(i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 5, i32* %3
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
switch i32 %11, label %22 [
i32 1, label %12
i32 2, label %14
i32 3, label %16
i32 4, label %18
i32 5, label %20
i32 0, label %21
]
12: ; preds = %7
%13 = call i32 (...) @create()
br label %24
14: ; preds = %7
%15 = call i32 (...) @kill()
br label %24
16: ; preds = %7
%17 = call i32 (...) @block()
br label %24
18: ; preds = %7
%19 = call i32 (...) @wakeup()
br label %24
20: ; preds = %7
br label %24
21: ; preds = %7
store i32 0, i32* %2
br label %24
22: ; preds = %7
%23 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
br label %4
24: ; preds = %21, %20, %18, %16, %14, %12
%25 = load i32, i32* %2
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = call i32 (...) @schedule()
%29 = call i32 (...) @display()
br label %30
30: ; preds = %27, %24
br label %4
31: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"##########-->\00"
@.str.2 = [3 x i8] c"%d\00"
@str = [136 x i8] c"######ProcessSimulation: menu #####\0A1. create process 2. kill process\0A3. block process 4. wakeup process\0A5. just run 0. exit\00"
@str.4 = [42 x i8] c"input error! Don't test my robustness ,,,\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %21, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([136 x i8], [136 x i8]* @str, i64 0, i64 0))
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 5, i32* %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
switch i32 %7, label %16 [
i32 1, label %8
i32 2, label %10
i32 3, label %12
i32 4, label %14
i32 5, label %18
i32 0, label %22
]
8: ; preds = %3
%9 = call i32 (...) @create()
br label %18
10: ; preds = %3
%11 = call i32 (...) @kill()
br label %18
12: ; preds = %3
%13 = call i32 (...) @block()
br label %18
14: ; preds = %3
%15 = call i32 (...) @wakeup()
br label %18
16: ; preds = %3
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.4, i64 0, i64 0))
br label %21
18: ; preds = %3, %14, %12, %10, %8
%19 = call i32 (...) @schedule()
%20 = call i32 (...) @display()
br label %21
21: ; preds = %18, %16
br label %3
22: ; preds = %3
ret i32 0
}