#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*/ adcinit();
void BSP_Joystick_Init(void) {
  (*((volatile uint32_t *)0x400FE608)) |= 0x0000001A;
  while (((*((volatile uint32_t *)0x400FEA08)) & 0x1A) != 0x1A) {
  };
  (*((volatile uint32_t *)0x40024528)) &= ~0x10;
  (*((volatile uint32_t *)0x40007528)) |= 0x08;
  (*((volatile uint32_t *)0x40005528)) |= 0x20;
  (*((volatile uint32_t *)0x4002452C)) =
      ((*((volatile uint32_t *)0x4002452C)) & 0xFFF0FFFF) + 0x00000000;
  (*((volatile uint32_t *)0x40024400)) &= ~0x10;
  (*((volatile uint32_t *)0x40007400)) &= ~0x08;
  (*((volatile uint32_t *)0x40005400)) &= ~0x20;
  (*((volatile uint32_t *)0x40024420)) &= ~0x10;
  (*((volatile uint32_t *)0x40007420)) |= 0x08;
  (*((volatile uint32_t *)0x40005420)) |= 0x20;
  (*((volatile uint32_t *)0x4002451C)) |= 0x10;
  (*((volatile uint32_t *)0x4000751C)) &= ~0x08;
  (*((volatile uint32_t *)0x4000551C)) &= ~0x20;
  adcinit();
  (*((volatile uint32_t *)0x40038000)) &= ~0x0002;
  (*((volatile uint32_t *)0x40038014)) &= ~0x00F0;
  (*((volatile uint32_t *)0x40038060)) = 0x004B;
  (*((volatile uint32_t *)0x40038064)) = 0x0060;
  (*((volatile uint32_t *)0x40038008)) &= ~0x0002;
  (*((volatile uint32_t *)0x40038000)) |= 0x0002;
}


x86 assembly (clang, -O0):
<BSP_Joystick_Init>:
push   %rbp
mov    %rsp,%rbp
mov    $0x400fe608,%eax
mov    (%rax),%ecx
or     $0x1a,%ecx
mov    $0x400fe608,%eax
mov    %ecx,(%rax)
mov    $0x400fea08,%eax
mov    (%rax),%eax
and    $0x1a,%eax
cmp    $0x1a,%eax
je     113d <BSP_Joystick_Init+0x2d>
jmp    1125 <BSP_Joystick_Init+0x15>
mov    $0x40024528,%eax
mov    (%rax),%ecx
and    $0xffffffef,%ecx
mov    $0x40024528,%eax
mov    %ecx,(%rax)
mov    $0x40007528,%eax
mov    (%rax),%ecx
or     $0x8,%ecx
mov    $0x40007528,%eax
mov    %ecx,(%rax)
mov    $0x40005528,%eax
mov    (%rax),%ecx
or     $0x20,%ecx
mov    $0x40005528,%eax
mov    %ecx,(%rax)
mov    $0x4002452c,%eax
mov    (%rax),%ecx
and    $0xfff0ffff,%ecx
add    $0x0,%ecx
mov    $0x4002452c,%eax
mov    %ecx,(%rax)
mov    $0x40024400,%eax
mov    (%rax),%ecx
and    $0xffffffef,%ecx
mov    $0x40024400,%eax
mov    %ecx,(%rax)
mov    $0x40007400,%eax
mov    (%rax),%ecx
and    $0xfffffff7,%ecx
mov    $0x40007400,%eax
mov    %ecx,(%rax)
mov    $0x40005400,%eax
mov    (%rax),%ecx
and    $0xffffffdf,%ecx
mov    $0x40005400,%eax
mov    %ecx,(%rax)
mov    $0x40024420,%eax
mov    (%rax),%ecx
and    $0xffffffef,%ecx
mov    $0x40024420,%eax
mov    %ecx,(%rax)
mov    $0x40007420,%eax
mov    (%rax),%ecx
or     $0x8,%ecx
mov    $0x40007420,%eax
mov    %ecx,(%rax)
mov    $0x40005420,%eax
mov    (%rax),%ecx
or     $0x20,%ecx
mov    $0x40005420,%eax
mov    %ecx,(%rax)
mov    $0x4002451c,%eax
mov    (%rax),%ecx
or     $0x10,%ecx
mov    $0x4002451c,%eax
mov    %ecx,(%rax)
mov    $0x4000751c,%eax
mov    (%rax),%ecx
and    $0xfffffff7,%ecx
mov    $0x4000751c,%eax
mov    %ecx,(%rax)
mov    $0x4000551c,%eax
mov    (%rax),%ecx
and    $0xffffffdf,%ecx
mov    $0x4000551c,%eax
mov    %ecx,(%rax)
mov    $0x0,%al
call   1030 <adcinit@plt>
mov    $0x40038000,%eax
mov    (%rax),%ecx
and    $0xfffffffd,%ecx
mov    $0x40038000,%eax
mov    %ecx,(%rax)
mov    $0x40038014,%eax
mov    (%rax),%ecx
and    $0xffffff0f,%ecx
mov    $0x40038014,%eax
mov    %ecx,(%rax)
mov    $0x40038060,%eax
movl   $0x4b,(%rax)
mov    $0x40038064,%eax
movl   $0x60,(%rax)
mov    $0x40038008,%eax
mov    (%rax),%ecx
and    $0xfffffffd,%ecx
mov    $0x40038008,%eax
mov    %ecx,(%rax)
mov    $0x40038000,%eax
mov    (%rax),%ecx
or     $0x2,%ecx
mov    $0x40038000,%eax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<BSP_Joystick_Init>:
push   %rax
orl    $0x1a,0x400fe608
1a
nopl   0x0(%rax)
mov    0x400fea08,%eax
not    %eax
test   $0x1a,%al
jne    1120 <BSP_Joystick_Init+0x10>
andl   $0xffffffef,0x40024528
ef
orl    $0x8,0x40007528
08
orl    $0x20,0x40005528
20
andl   $0xfff0ffff,0x4002452c
ff ff f0 ff
andl   $0xffffffef,0x40024400
ef
andl   $0xfffffff7,0x40007400
f7
andl   $0xffffffdf,0x40005400
df
andl   $0xffffffef,0x40024420
ef
orl    $0x8,0x40007420
08
orl    $0x20,0x40005420
20
orl    $0x10,0x4002451c
10
andl   $0xfffffff7,0x4000751c
f7
andl   $0xffffffdf,0x4000551c
df
xor    %eax,%eax
call   1030 <adcinit@plt>
andl   $0xfffffffd,0x40038000
fd
andl   $0xffffff0f,0x40038014
0f ff ff ff
movl   $0x4b,0x40038060
movl   $0x60,0x40038064
andl   $0xfffffffd,0x40038008
fd
orl    $0x2,0x40038000
02
pop    %rax
ret

LLVM IR (-O0):
define void @BSP_Joystick_Init() {
%1 = load volatile i32, i32* inttoptr (i64 1074783752 to i32*)
%2 = or i32 %1, 26
store volatile i32 %2, i32* inttoptr (i64 1074783752 to i32*)
br label %3
3: ; preds = %7, %0
%4 = load volatile i32, i32* inttoptr (i64 1074784776 to i32*)
%5 = and i32 %4, 26
%6 = icmp ne i32 %5, 26
br i1 %6, label %7, label %8
7: ; preds = %3
br label %3
8: ; preds = %3
%9 = load volatile i32, i32* inttoptr (i64 1073890600 to i32*)
%10 = and i32 %9, -17
store volatile i32 %10, i32* inttoptr (i64 1073890600 to i32*)
%11 = load volatile i32, i32* inttoptr (i64 1073771816 to i32*)
%12 = or i32 %11, 8
store volatile i32 %12, i32* inttoptr (i64 1073771816 to i32*)
%13 = load volatile i32, i32* inttoptr (i64 1073763624 to i32*)
%14 = or i32 %13, 32
store volatile i32 %14, i32* inttoptr (i64 1073763624 to i32*)
%15 = load volatile i32, i32* inttoptr (i64 1073890604 to i32*)
%16 = and i32 %15, -983041
%17 = add i32 %16, 0
store volatile i32 %17, i32* inttoptr (i64 1073890604 to i32*)
%18 = load volatile i32, i32* inttoptr (i64 1073890304 to i32*)
%19 = and i32 %18, -17
store volatile i32 %19, i32* inttoptr (i64 1073890304 to i32*)
%20 = load volatile i32, i32* inttoptr (i64 1073771520 to i32*)
%21 = and i32 %20, -9
store volatile i32 %21, i32* inttoptr (i64 1073771520 to i32*)
%22 = load volatile i32, i32* inttoptr (i64 1073763328 to i32*)
%23 = and i32 %22, -33
store volatile i32 %23, i32* inttoptr (i64 1073763328 to i32*)
%24 = load volatile i32, i32* inttoptr (i64 1073890336 to i32*)
%25 = and i32 %24, -17
store volatile i32 %25, i32* inttoptr (i64 1073890336 to i32*)
%26 = load volatile i32, i32* inttoptr (i64 1073771552 to i32*)
%27 = or i32 %26, 8
store volatile i32 %27, i32* inttoptr (i64 1073771552 to i32*)
%28 = load volatile i32, i32* inttoptr (i64 1073763360 to i32*)
%29 = or i32 %28, 32
store volatile i32 %29, i32* inttoptr (i64 1073763360 to i32*)
%30 = load volatile i32, i32* inttoptr (i64 1073890588 to i32*)
%31 = or i32 %30, 16
store volatile i32 %31, i32* inttoptr (i64 1073890588 to i32*)
%32 = load volatile i32, i32* inttoptr (i64 1073771804 to i32*)
%33 = and i32 %32, -9
store volatile i32 %33, i32* inttoptr (i64 1073771804 to i32*)
%34 = load volatile i32, i32* inttoptr (i64 1073763612 to i32*)
%35 = and i32 %34, -33
store volatile i32 %35, i32* inttoptr (i64 1073763612 to i32*)
%36 = call i32 (...) @adcinit()
%37 = load volatile i32, i32* inttoptr (i64 1073971200 to i32*)
%38 = and i32 %37, -3
store volatile i32 %38, i32* inttoptr (i64 1073971200 to i32*)
%39 = load volatile i32, i32* inttoptr (i64 1073971220 to i32*)
%40 = and i32 %39, -241
store volatile i32 %40, i32* inttoptr (i64 1073971220 to i32*)
store volatile i32 75, i32* inttoptr (i64 1073971296 to i32*)
store volatile i32 96, i32* inttoptr (i64 1073971300 to i32*)
%41 = load volatile i32, i32* inttoptr (i64 1073971208 to i32*)
%42 = and i32 %41, -3
store volatile i32 %42, i32* inttoptr (i64 1073971208 to i32*)
%43 = load volatile i32, i32* inttoptr (i64 1073971200 to i32*)
%44 = or i32 %43, 2
store volatile i32 %44, i32* inttoptr (i64 1073971200 to i32*)
ret void
}

LLVM IR (-O2):
define void @BSP_Joystick_Init() {
%1 = load volatile i32, i32* inttoptr (i64 1074783752 to i32*)
%2 = or i32 %1, 26
store volatile i32 %2, i32* inttoptr (i64 1074783752 to i32*)
br label %3
3: ; preds = %3, %0
%4 = load volatile i32, i32* inttoptr (i64 1074784776 to i32*)
%5 = and i32 %4, 26
%6 = icmp eq i32 %5, 26
br i1 %6, label %7, label %3
7: ; preds = %3
%8 = load volatile i32, i32* inttoptr (i64 1073890600 to i32*)
%9 = and i32 %8, -17
store volatile i32 %9, i32* inttoptr (i64 1073890600 to i32*)
%10 = load volatile i32, i32* inttoptr (i64 1073771816 to i32*)
%11 = or i32 %10, 8
store volatile i32 %11, i32* inttoptr (i64 1073771816 to i32*)
%12 = load volatile i32, i32* inttoptr (i64 1073763624 to i32*)
%13 = or i32 %12, 32
store volatile i32 %13, i32* inttoptr (i64 1073763624 to i32*)
%14 = load volatile i32, i32* inttoptr (i64 1073890604 to i32*)
%15 = and i32 %14, -983041
store volatile i32 %15, i32* inttoptr (i64 1073890604 to i32*)
%16 = load volatile i32, i32* inttoptr (i64 1073890304 to i32*)
%17 = and i32 %16, -17
store volatile i32 %17, i32* inttoptr (i64 1073890304 to i32*)
%18 = load volatile i32, i32* inttoptr (i64 1073771520 to i32*)
%19 = and i32 %18, -9
store volatile i32 %19, i32* inttoptr (i64 1073771520 to i32*)
%20 = load volatile i32, i32* inttoptr (i64 1073763328 to i32*)
%21 = and i32 %20, -33
store volatile i32 %21, i32* inttoptr (i64 1073763328 to i32*)
%22 = load volatile i32, i32* inttoptr (i64 1073890336 to i32*)
%23 = and i32 %22, -17
store volatile i32 %23, i32* inttoptr (i64 1073890336 to i32*)
%24 = load volatile i32, i32* inttoptr (i64 1073771552 to i32*)
%25 = or i32 %24, 8
store volatile i32 %25, i32* inttoptr (i64 1073771552 to i32*)
%26 = load volatile i32, i32* inttoptr (i64 1073763360 to i32*)
%27 = or i32 %26, 32
store volatile i32 %27, i32* inttoptr (i64 1073763360 to i32*)
%28 = load volatile i32, i32* inttoptr (i64 1073890588 to i32*)
%29 = or i32 %28, 16
store volatile i32 %29, i32* inttoptr (i64 1073890588 to i32*)
%30 = load volatile i32, i32* inttoptr (i64 1073771804 to i32*)
%31 = and i32 %30, -9
store volatile i32 %31, i32* inttoptr (i64 1073771804 to i32*)
%32 = load volatile i32, i32* inttoptr (i64 1073763612 to i32*)
%33 = and i32 %32, -33
store volatile i32 %33, i32* inttoptr (i64 1073763612 to i32*)
%34 = tail call i32 (...) @adcinit()
%35 = load volatile i32, i32* inttoptr (i64 1073971200 to i32*)
%36 = and i32 %35, -3
store volatile i32 %36, i32* inttoptr (i64 1073971200 to i32*)
%37 = load volatile i32, i32* inttoptr (i64 1073971220 to i32*)
%38 = and i32 %37, -241
store volatile i32 %38, i32* inttoptr (i64 1073971220 to i32*)
store volatile i32 75, i32* inttoptr (i64 1073971296 to i32*)
store volatile i32 96, i32* inttoptr (i64 1073971300 to i32*)
%39 = load volatile i32, i32* inttoptr (i64 1073971208 to i32*)
%40 = and i32 %39, -3
store volatile i32 %40, i32* inttoptr (i64 1073971208 to i32*)
%41 = load volatile i32, i32* inttoptr (i64 1073971200 to i32*)
%42 = or i32 %41, 2
store volatile i32 %42, i32* inttoptr (i64 1073971200 to i32*)
ret void
}