#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 uint8_t;
typedef int uint32_t;
typedef int uint16_t;

/* Variables and functions */
void BSP_Joystick_Input(uint16_t *x, uint16_t *y, uint8_t *select) {
  (*((volatile uint32_t *)0x40038028)) = 0x0002;
  while (((*((volatile uint32_t *)0x40038004)) & 0x02) == 0) {
  };
  *x = (*((volatile uint32_t *)0x40038068)) >> 2;
  *y = (*((volatile uint32_t *)0x40038068)) >> 2;
  *select = (*((volatile uint32_t *)0x40024040));
  (*((volatile uint32_t *)0x4003800C)) = 0x0002;
}


x86 assembly (clang, -O0):
<BSP_Joystick_Input>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x40038028,%eax
movl   $0x2,(%rax)
mov    $0x40038004,%eax
mov    (%rax),%eax
and    $0x2,%eax
cmp    $0x0,%eax
jne    1133 <BSP_Joystick_Input+0x33>
jmp    111b <BSP_Joystick_Input+0x1b>
mov    $0x40038068,%eax
mov    (%rax),%ecx
sar    $0x2,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x40038068,%eax
mov    (%rax),%ecx
sar    $0x2,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x40024040,%eax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x4003800c,%eax
movl   $0x2,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<BSP_Joystick_Input>:
movl   $0x2,0x40038028
nopl   0x0(%rax,%rax,1)
testl  $0x2,0x40038004
je     1110 <BSP_Joystick_Input+0x10>
mov    0x40038068,%eax
sar    $0x2,%eax
mov    %eax,(%rdi)
mov    0x40038068,%eax
sar    $0x2,%eax
mov    %eax,(%rsi)
mov    0x40024040,%eax
mov    %eax,(%rdx)
movl   $0x2,0x4003800c
ret

LLVM IR (-O0):
define void @BSP_Joystick_Input(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
store volatile i32 2, i32* inttoptr (i64 1073971240 to i32*)
br label %7
7: ; preds = %11, %3
%8 = load volatile i32, i32* inttoptr (i64 1073971204 to i32*)
%9 = and i32 %8, 2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
br label %7
12: ; preds = %7
%13 = load volatile i32, i32* inttoptr (i64 1073971304 to i32*)
%14 = ashr i32 %13, 2
%15 = load i32*, i32** %4
store i32 %14, i32* %15
%16 = load volatile i32, i32* inttoptr (i64 1073971304 to i32*)
%17 = ashr i32 %16, 2
%18 = load i32*, i32** %5
store i32 %17, i32* %18
%19 = load volatile i32, i32* inttoptr (i64 1073889344 to i32*)
%20 = load i32*, i32** %6
store i32 %19, i32* %20
store volatile i32 2, i32* inttoptr (i64 1073971212 to i32*)
ret void
}

LLVM IR (-O2):
define void @BSP_Joystick_Input(i32* nocapture writeonly %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
store volatile i32 2, i32* inttoptr (i64 1073971240 to i32*)
br label %4
4: ; preds = %4, %3
%5 = load volatile i32, i32* inttoptr (i64 1073971204 to i32*)
%6 = and i32 %5, 2
%7 = icmp eq i32 %6, 0
br i1 %7, label %4, label %8
8: ; preds = %4
%9 = load volatile i32, i32* inttoptr (i64 1073971304 to i32*)
%10 = ashr i32 %9, 2
store i32 %10, i32* %0
%11 = load volatile i32, i32* inttoptr (i64 1073971304 to i32*)
%12 = ashr i32 %11, 2
store i32 %12, i32* %1
%13 = load volatile i32, i32* inttoptr (i64 1073889344 to i32*)
store i32 %13, i32* %2
store volatile i32 2, i32* inttoptr (i64 1073971212 to i32*)
ret void
}