#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*/ drawClosePacman(int, int, int);
int /*<<< orphan*/ drawPacman(int, int, int, int);
int getXFromQueue(int);
int getYFromQueue(int);
void drawAnimatedPacman(int index, int status) {
  int x = getXFromQueue(index) + -30;
  int y = getYFromQueue(index) + 30;
  int radius = 30;
  switch (status % 4) {
  case 0:
    drawPacman(x, y, radius, 6);
    break;
  case 1:
    drawPacman(x, y, radius, 12);
    break;
  case 2:
    drawClosePacman(x, y, radius);
    break;
  case 3:
    drawPacman(x, y, radius, 12);
    break;
  }
}


x86 assembly (clang, -O0):
<drawAnimatedPacman>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <getXFromQueue@plt>
add    $0xffffffe2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <getYFromQueue@plt>
add    $0x1e,%eax
mov    %eax,-0x10(%rbp)
movl   $0x1e,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%edx
add    $0x3,%edx
test   %eax,%eax
mov    %eax,%ecx
cmovs  %edx,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     11fe <drawAnimatedPacman+0xbe>
mov    -0x20(%rbp),%rax
lea    0xe61(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    $0x6,%ecx
call   1040 <drawPacman@plt>
jmp    11fe <drawAnimatedPacman+0xbe>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    $0xc,%ecx
call   1040 <drawPacman@plt>
jmp    11fe <drawAnimatedPacman+0xbe>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <drawClosePacman@plt>
jmp    11fe <drawAnimatedPacman+0xbe>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    $0xc,%ecx
call   1040 <drawPacman@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawAnimatedPacman>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
call   1030 <getXFromQueue@plt>
mov    %eax,%r14d
mov    %ebp,%edi
call   1060 <getYFromQueue@plt>
lea    0x3(%rbx),%ecx
test   %ebx,%ebx
cmovns %ebx,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%ebx
cmp    $0x3,%ebx
ja     1191 <drawAnimatedPacman+0x51>
add    $0xffffffe2,%r14d
add    $0x1e,%eax
lea    0xe89(%rip),%rcx
movslq (%rcx,%rbx,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
mov    %r14d,%edi
mov    %eax,%esi
mov    $0x1e,%edx
mov    $0xc,%ecx
jmp    11a5 <drawAnimatedPacman+0x65>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %r14d,%edi
mov    %eax,%esi
mov    $0x1e,%edx
mov    $0x6,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <drawPacman@plt>
mov    %r14d,%edi
mov    %eax,%esi
mov    $0x1e,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <drawClosePacman@plt>

LLVM IR (-O0):
define void @drawAnimatedPacman(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = call i32 @getXFromQueue(i32 %8)
%10 = add nsw i32 %9, -30
store i32 %10, i32* %5
%11 = load i32, i32* %3
%12 = call i32 @getYFromQueue(i32 %11)
%13 = add nsw i32 %12, 30
store i32 %13, i32* %6
store i32 30, i32* %7
%14 = load i32, i32* %4
%15 = srem i32 %14, 4
switch i32 %15, label %36 [
i32 0, label %16
i32 1, label %21
i32 2, label %26
i32 3, label %31
]
16: ; preds = %2
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = call i32 @drawPacman(i32 %17, i32 %18, i32 %19, i32 6)
br label %36
21: ; preds = %2
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = call i32 @drawPacman(i32 %22, i32 %23, i32 %24, i32 12)
br label %36
26: ; preds = %2
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = call i32 @drawClosePacman(i32 %27, i32 %28, i32 %29)
br label %36
31: ; preds = %2
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = call i32 @drawPacman(i32 %32, i32 %33, i32 %34, i32 12)
br label %36
36: ; preds = %2, %31, %26, %21, %16
ret void
}

LLVM IR (-O2):
define void @drawAnimatedPacman(i32 %0, i32 %1) {
%3 = tail call i32 @getXFromQueue(i32 %0)
%4 = add nsw i32 %3, -30
%5 = tail call i32 @getYFromQueue(i32 %0)
%6 = add nsw i32 %5, 30
%7 = srem i32 %1, 4
switch i32 %7, label %16 [
i32 0, label %8
i32 1, label %10
i32 2, label %12
i32 3, label %14
]
8: ; preds = %2
%9 = tail call i32 @drawPacman(i32 %4, i32 %6, i32 30, i32 6)
br label %16
10: ; preds = %2
%11 = tail call i32 @drawPacman(i32 %4, i32 %6, i32 30, i32 12)
br label %16
12: ; preds = %2
%13 = tail call i32 @drawClosePacman(i32 %4, i32 %6, i32 30)
br label %16
14: ; preds = %2
%15 = tail call i32 @drawPacman(i32 %4, i32 %6, i32 30, i32 12)
br label %16
16: ; preds = %2, %14, %12, %10, %8
ret void
}