#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*/ dg_panic(char *);
void move(int *x, int *y, int dir) {
  switch (dir) {
  case 0:
    --(*y);
    break;
  case 1:
    (*x)++;
    break;
  case 2:
    (*y)++;
    break;
  case 3:
    --(*x);
    break;
  default:
    dg_panic("move: bad direction");
  }
}


x86 assembly (clang, -O0):
<move>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x3,%rax
ja     1188 <move+0x78>
mov    -0x20(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
jmp    1194 <move+0x84>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1194 <move+0x84>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1194 <move+0x84>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
jmp    1194 <move+0x84>
lea    0xe81(%rip),%rdi
call   1030 <dg_panic@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<move>:
cmp    $0x3,%edx
ja     112b <move+0x1b>
mov    %edx,%eax
lea    0xee2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
addl   $0xffffffff,(%rsi)
ret
lea    0xede(%rip),%rdi
jmp    1030 <dg_panic@plt>
addl   $0x1,(%rdi)
ret
addl   $0x1,(%rsi)
ret
addl   $0xffffffff,(%rdi)
ret

LLVM IR (-O0):
@.str = [20 x i8] c"move: bad direction\00"
define void @move(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
switch i32 %7, label %24 [
i32 0, label %8
i32 1, label %12
i32 2, label %16
i32 3, label %20
]
8: ; preds = %3
%9 = load i32*, i32** %5
%10 = load i32, i32* %9
%11 = add nsw i32 %10, -1
store i32 %11, i32* %9
br label %26
12: ; preds = %3
%13 = load i32*, i32** %4
%14 = load i32, i32* %13
%15 = add nsw i32 %14, 1
store i32 %15, i32* %13
br label %26
16: ; preds = %3
%17 = load i32*, i32** %5
%18 = load i32, i32* %17
%19 = add nsw i32 %18, 1
store i32 %19, i32* %17
br label %26
20: ; preds = %3
%21 = load i32*, i32** %4
%22 = load i32, i32* %21
%23 = add nsw i32 %22, -1
store i32 %23, i32* %21
br label %26
24: ; preds = %3
%25 = call i32 @dg_panic(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %26
26: ; preds = %24, %20, %16, %12, %8
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"move: bad direction\00"
define void @move(i32* nocapture %0, i32* nocapture %1, i32 %2) {
switch i32 %2, label %16 [
i32 0, label %4
i32 1, label %7
i32 2, label %10
i32 3, label %13
]
4: ; preds = %3
%5 = load i32, i32* %1
%6 = add nsw i32 %5, -1
store i32 %6, i32* %1
br label %18
7: ; preds = %3
%8 = load i32, i32* %0
%9 = add nsw i32 %8, 1
store i32 %9, i32* %0
br label %18
10: ; preds = %3
%11 = load i32, i32* %1
%12 = add nsw i32 %11, 1
store i32 %12, i32* %1
br label %18
13: ; preds = %3
%14 = load i32, i32* %0
%15 = add nsw i32 %14, -1
store i32 %15, i32* %0
br label %18
16: ; preds = %3
%17 = tail call i32 @dg_panic(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %13, %10, %7, %4
ret void
}