#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*/ ack();
int /*<<< orphan*/ infof(char *);
int /*<<< orphan*/ intr();
int /*<<< orphan*/ jsr();
int /*<<< orphan*/ lda();
int /*<<< orphan*/ ldf();
int /*<<< orphan*/ nafetch();
int /*<<< orphan*/ nastore();
int /*<<< orphan*/ nffetch();
int /*<<< orphan*/ nfstore();
int /*<<< orphan*/ npop();
int /*<<< orphan*/ npush();
int rx();
void interpret_packet(void) {
  int size = rx();
  (void)size;
  int command = rx();
  switch (command & 0x0F) {
  default:
  case 0:
    ack();
    break;
  case 1:
    npush();
    break;
  case 2:
    npop();
    break;
  case 3:
    jsr();
    break;
  case 4:
    lda();
    break;
  case 5:
    ldf();
    break;
  case 7:
    intr();
    break;
  case 8:
    nafetch();
    break;
  case 9:
    nffetch();
    break;
  case 10:
    nastore();
    break;
  case 11:
    nfstore();
    break;
  }
  infof("\n");
}


x86 assembly (clang, -O0):
<interpret_packet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
mov    %al,-0x11(%rbp)
call   10a0 <rx@plt>
mov    %eax,%ecx
mov    -0x11(%rbp),%al
mov    %ecx,-0x4(%rbp)
call   10a0 <rx@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xf,%eax
mov    %rax,-0x10(%rbp)
sub    $0xb,%eax
ja     1219 <interpret_packet+0x49>
mov    -0x10(%rbp),%rax
lea    0xdf0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    121e <interpret_packet+0x4e>
mov    $0x0,%al
call   1040 <ack@plt>
jmp    129d <interpret_packet+0xcd>
mov    $0x0,%al
call   1060 <npush@plt>
jmp    129d <interpret_packet+0xcd>
mov    $0x0,%al
call   10c0 <npop@plt>
jmp    129d <interpret_packet+0xcd>
mov    $0x0,%al
call   1050 <jsr@plt>
jmp    129d <interpret_packet+0xcd>
mov    $0x0,%al
call   10e0 <lda@plt>
jmp    129d <interpret_packet+0xcd>
mov    $0x0,%al
call   1090 <ldf@plt>
jmp    129d <interpret_packet+0xcd>
mov    $0x0,%al
call   1030 <intr@plt>
jmp    129d <interpret_packet+0xcd>
mov    $0x0,%al
call   1070 <nafetch@plt>
jmp    129d <interpret_packet+0xcd>
mov    $0x0,%al
call   10f0 <nffetch@plt>
jmp    129d <interpret_packet+0xcd>
mov    $0x0,%al
call   10d0 <nastore@plt>
jmp    129d <interpret_packet+0xcd>
mov    $0x0,%al
call   1080 <nfstore@plt>
lea    0xd8c(%rip),%rdi
call   10b0 <infof@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interpret_packet>:
push   %rax
xor    %eax,%eax
call   10a0 <rx@plt>
xor    %eax,%eax
call   10a0 <rx@plt>
and    $0xf,%eax
add    $0xffffffff,%eax
cmp    $0xa,%eax
ja     1227 <interpret_packet+0x57>
lea    0xe0f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1060 <npush@plt>
jmp    125b <interpret_packet+0x8b>
xor    %eax,%eax
call   10c0 <npop@plt>
jmp    125b <interpret_packet+0x8b>
xor    %eax,%eax
call   1050 <jsr@plt>
jmp    125b <interpret_packet+0x8b>
xor    %eax,%eax
call   10e0 <lda@plt>
jmp    125b <interpret_packet+0x8b>
xor    %eax,%eax
call   1090 <ldf@plt>
jmp    125b <interpret_packet+0x8b>
xor    %eax,%eax
call   1040 <ack@plt>
jmp    125b <interpret_packet+0x8b>
xor    %eax,%eax
call   1030 <intr@plt>
jmp    125b <interpret_packet+0x8b>
xor    %eax,%eax
call   1070 <nafetch@plt>
jmp    125b <interpret_packet+0x8b>
xor    %eax,%eax
call   10f0 <nffetch@plt>
jmp    125b <interpret_packet+0x8b>
xor    %eax,%eax
call   10d0 <nastore@plt>
jmp    125b <interpret_packet+0x8b>
xor    %eax,%eax
call   1080 <nfstore@plt>
lea    0xdca(%rip),%rdi
pop    %rax
jmp    10b0 <infof@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define void @interpret_packet() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @rx()
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = call i32 (...) @rx()
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = and i32 %6, 15
switch i32 %7, label %8 [
i32 0, label %9
i32 1, label %11
i32 2, label %13
i32 3, label %15
i32 4, label %17
i32 5, label %19
i32 7, label %21
i32 8, label %23
i32 9, label %25
i32 10, label %27
i32 11, label %29
]
8: ; preds = %0
br label %9
9: ; preds = %0, %8
%10 = call i32 (...) @ack()
br label %31
11: ; preds = %0
%12 = call i32 (...) @npush()
br label %31
13: ; preds = %0
%14 = call i32 (...) @npop()
br label %31
15: ; preds = %0
%16 = call i32 (...) @jsr()
br label %31
17: ; preds = %0
%18 = call i32 (...) @lda()
br label %31
19: ; preds = %0
%20 = call i32 (...) @ldf()
br label %31
21: ; preds = %0
%22 = call i32 (...) @intr()
br label %31
23: ; preds = %0
%24 = call i32 (...) @nafetch()
br label %31
25: ; preds = %0
%26 = call i32 (...) @nffetch()
br label %31
27: ; preds = %0
%28 = call i32 (...) @nastore()
br label %31
29: ; preds = %0
%30 = call i32 (...) @nfstore()
br label %31
31: ; preds = %29, %27, %25, %23, %21, %19, %17, %15, %13, %11, %9
%32 = call i32 @infof(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
define void @interpret_packet() {
%1 = tail call i32 (...) @rx()
%2 = tail call i32 (...) @rx()
%3 = and i32 %2, 15
switch i32 %3, label %4 [
i32 11, label %24
i32 1, label %6
i32 2, label %8
i32 3, label %10
i32 4, label %12
i32 5, label %14
i32 7, label %16
i32 8, label %18
i32 9, label %20
i32 10, label %22
]
4: ; preds = %0
%5 = tail call i32 (...) @ack()
br label %26
6: ; preds = %0
%7 = tail call i32 (...) @npush()
br label %26
8: ; preds = %0
%9 = tail call i32 (...) @npop()
br label %26
10: ; preds = %0
%11 = tail call i32 (...) @jsr()
br label %26
12: ; preds = %0
%13 = tail call i32 (...) @lda()
br label %26
14: ; preds = %0
%15 = tail call i32 (...) @ldf()
br label %26
16: ; preds = %0
%17 = tail call i32 (...) @intr()
br label %26
18: ; preds = %0
%19 = tail call i32 (...) @nafetch()
br label %26
20: ; preds = %0
%21 = tail call i32 (...) @nffetch()
br label %26
22: ; preds = %0
%23 = tail call i32 (...) @nastore()
br label %26
24: ; preds = %0
%25 = tail call i32 (...) @nfstore()
br label %26
26: ; preds = %24, %22, %20, %18, %16, %14, %12, %10, %8, %6, %4
%27 = tail call i32 @infof(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}