#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 button_pressed(int, unsigned short);
unsigned char buttons_pressed(void) {
  return button_pressed((0x40020400), ((unsigned short)0x4000)) |
         button_pressed((0x40020800), ((unsigned short)0x0040)) << 1 |
         button_pressed((0x40020800), ((unsigned short)0x0080)) << 2 |
         button_pressed((0x40020000), ((unsigned short)0x0100)) << 3 |
         button_pressed((0x40020000), ((unsigned short)0x8000)) << 4;
}


x86 assembly (clang, -O0):
<buttons_pressed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x40020400,%edi
mov    $0x4000,%esi
call   1030 <button_pressed@plt>
mov    %eax,-0x10(%rbp)
mov    $0x40020800,%edi
mov    $0x40,%esi
call   1030 <button_pressed@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
shl    $0x1,%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    $0x40020800,%edi
mov    $0x80,%esi
call   1030 <button_pressed@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
shl    $0x2,%ecx
or     %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    $0x40020000,%edi
mov    $0x100,%esi
call   1030 <button_pressed@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
shl    $0x3,%ecx
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    $0x40020000,%edi
mov    $0x8000,%esi
call   1030 <button_pressed@plt>
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
shl    $0x4,%ecx
or     %ecx,%eax
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buttons_pressed>:
push   %rbp
push   %r14
push   %rbx
mov    $0x40020400,%edi
mov    $0x4000,%esi
call   1030 <button_pressed@plt>
mov    %eax,%ebx
mov    $0x40020800,%edi
mov    $0x40,%esi
call   1030 <button_pressed@plt>
mov    %eax,%ebp
add    %eax,%ebp
or     %ebx,%ebp
mov    $0x40020800,%edi
mov    $0x80,%esi
call   1030 <button_pressed@plt>
mov    %eax,%r14d
shl    $0x2,%r14d
mov    $0x40020000,%edi
mov    $0x100,%esi
call   1030 <button_pressed@plt>
mov    %eax,%ebx
shl    $0x3,%ebx
or     %r14d,%ebx
or     %ebp,%ebx
mov    $0x40020000,%edi
mov    $0x8000,%esi
call   1030 <button_pressed@plt>
shl    $0x4,%eax
or     %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @buttons_pressed() {
%1 = call i32 @button_pressed(i32 1073873920, i16 zeroext 16384)
%2 = call i32 @button_pressed(i32 1073874944, i16 zeroext 64)
%3 = shl i32 %2, 1
%4 = or i32 %1, %3
%5 = call i32 @button_pressed(i32 1073874944, i16 zeroext 128)
%6 = shl i32 %5, 2
%7 = or i32 %4, %6
%8 = call i32 @button_pressed(i32 1073872896, i16 zeroext 256)
%9 = shl i32 %8, 3
%10 = or i32 %7, %9
%11 = call i32 @button_pressed(i32 1073872896, i16 zeroext -32768)
%12 = shl i32 %11, 4
%13 = or i32 %10, %12
%14 = trunc i32 %13 to i8
ret i8 %14
}

LLVM IR (-O2):
define zeroext i8 @buttons_pressed() {
%1 = tail call i32 @button_pressed(i32 1073873920, i16 zeroext 16384)
%2 = tail call i32 @button_pressed(i32 1073874944, i16 zeroext 64)
%3 = shl i32 %2, 1
%4 = or i32 %3, %1
%5 = tail call i32 @button_pressed(i32 1073874944, i16 zeroext 128)
%6 = shl i32 %5, 2
%7 = or i32 %4, %6
%8 = tail call i32 @button_pressed(i32 1073872896, i16 zeroext 256)
%9 = shl i32 %8, 3
%10 = or i32 %7, %9
%11 = tail call i32 @button_pressed(i32 1073872896, i16 zeroext -32768)
%12 = shl i32 %11, 4
%13 = or i32 %10, %12
%14 = trunc i32 %13 to i8
ret i8 %14
}