#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ PortF_Init();
int PortF_Input();
int /*<<< orphan*/ PortF_Output(int);
int main(void) {
  uint32_t status;
  PortF_Init();
  while (1) {
    status = PortF_Input();
    switch (status) {
    case 0x01:
      PortF_Output(0x04);
      break;
    case 0x10:
      PortF_Output(0x02);
      break;
    case 0x00:
      PortF_Output(0x08);
      break;
    case 0x11:
      PortF_Output(0);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <PortF_Init@plt>
xor    %eax,%eax
call   1030 <PortF_Input@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x11,%rax
ja     11a9 <main+0x79>
mov    -0x10(%rbp),%rax
lea    0xe94(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x4,%edi
call   1050 <PortF_Output@plt>
jmp    11a9 <main+0x79>
mov    $0x2,%edi
call   1050 <PortF_Output@plt>
jmp    11a9 <main+0x79>
mov    $0x8,%edi
call   1050 <PortF_Output@plt>
jmp    11a9 <main+0x79>
xor    %edi,%edi
call   1050 <PortF_Output@plt>
jmp    1146 <main+0x16>

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <PortF_Init@plt>
lea    0xec1(%rip),%rbx
jmp    1157 <main+0x27>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1050 <PortF_Output@plt>
xor    %eax,%eax
call   1030 <PortF_Input@plt>
cmp    $0x11,%eax
ja     1157 <main+0x27>
mov    $0x4,%edi
mov    %eax,%eax
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    $0x8,%edi
call   1050 <PortF_Output@plt>
jmp    1157 <main+0x27>
nop
mov    $0x2,%edi
call   1050 <PortF_Output@plt>
jmp    1157 <main+0x27>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (...) @PortF_Init()
br label %4
4: ; preds = %0, %15
%5 = call i32 (...) @PortF_Input()
store i32 %5, i32* %2
%6 = load i32, i32* %2
switch i32 %6, label %15 [
i32 1, label %7
i32 16, label %9
i32 0, label %11
i32 17, label %13
]
7: ; preds = %4
%8 = call i32 @PortF_Output(i32 4)
br label %15
9: ; preds = %4
%10 = call i32 @PortF_Output(i32 2)
br label %15
11: ; preds = %4
%12 = call i32 @PortF_Output(i32 8)
br label %15
13: ; preds = %4
%14 = call i32 @PortF_Output(i32 0)
br label %15
15: ; preds = %4, %13, %11, %9, %7
br label %4
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @PortF_Init()
br label %2
2: ; preds = %10, %0
%3 = tail call i32 (...) @PortF_Input()
switch i32 %3, label %10 [
i32 1, label %7
i32 16, label %4
i32 0, label %5
i32 17, label %6
]
4: ; preds = %2
br label %7
5: ; preds = %2
br label %7
6: ; preds = %2
br label %7
7: ; preds = %2, %4, %5, %6
%8 = phi i32 [ 0, %6 ], [ 8, %5 ], [ 2, %4 ], [ 4, %2 ]
%9 = tail call i32 @PortF_Output(i32 %8)
br label %10
10: ; preds = %7, %2
br label %2
}