#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 inb(int);
void lecture_boutons(char boutons[4]) {
  char t = (inb(0x379) ^ 0x70) & 0xF0;
  unsigned int u = (2) | ((2) << 8) | ((2) << 16) | ((2) << 24);
  if (t & 0x10)
    u |= 1;
  if (t & 0x20)
    u |= 1 << 8;
  if (t & 0x80)
    u |= 1 << 16;
  if (t & 0x40)
    u |= 1 << 24;
  *(int *)boutons = u;
}


x86 assembly (clang, -O0):
<lecture_boutons>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x379,%edi
call   1030 <inb@plt>
xor    $0x70,%eax
and    $0xf0,%eax
mov    %al,-0x9(%rbp)
movl   $0x2020202,-0x10(%rbp)
movsbl -0x9(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     1151 <lecture_boutons+0x41>
mov    -0x10(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x10(%rbp)
movsbl -0x9(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     116c <lecture_boutons+0x5c>
mov    -0x10(%rbp),%eax
or     $0x100,%eax
mov    %eax,-0x10(%rbp)
movsbl -0x9(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1189 <lecture_boutons+0x79>
mov    -0x10(%rbp),%eax
or     $0x10000,%eax
mov    %eax,-0x10(%rbp)
movsbl -0x9(%rbp),%eax
and    $0x40,%eax
cmp    $0x0,%eax
je     11a4 <lecture_boutons+0x94>
mov    -0x10(%rbp),%eax
or     $0x1000000,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lecture_boutons>:
push   %rbx
mov    %rdi,%rbx
mov    $0x379,%edi
call   1030 <inb@plt>
movsbl %al,%ecx
and    $0xfffffff0,%ecx
xor    $0x70,%ecx
mov    %ecx,%edx
and    $0x10,%edx
mov    %ecx,%esi
and    $0x20,%esi
shl    $0x9,%eax
and    $0x10000,%eax
and    $0x40,%ecx
shl    $0x12,%ecx
lea    (%rax,%rsi,8),%eax
or     %ecx,%eax
cmp    $0x1,%edx
sbb    $0x0,%eax
add    $0x2020203,%eax
mov    %eax,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @lecture_boutons(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 @inb(i32 889)
%6 = xor i32 %5, 112
%7 = and i32 %6, 240
%8 = trunc i32 %7 to i8
store i8 %8, i8* %3
store i32 33686018, i32* %4
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = and i32 %10, 16
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i32, i32* %4
%15 = or i32 %14, 1
store i32 %15, i32* %4
br label %16
16: ; preds = %13, %1
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
%19 = and i32 %18, 32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i32, i32* %4
%23 = or i32 %22, 256
store i32 %23, i32* %4
br label %24
24: ; preds = %21, %16
%25 = load i8, i8* %3
%26 = sext i8 %25 to i32
%27 = and i32 %26, 128
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %24
%30 = load i32, i32* %4
%31 = or i32 %30, 65536
store i32 %31, i32* %4
br label %32
32: ; preds = %29, %24
%33 = load i8, i8* %3
%34 = sext i8 %33 to i32
%35 = and i32 %34, 64
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load i32, i32* %4
%39 = or i32 %38, 16777216
store i32 %39, i32* %4
br label %40
40: ; preds = %37, %32
%41 = load i32, i32* %4
%42 = load i8*, i8** %2
%43 = bitcast i8* %42 to i32*
store i32 %41, i32* %43
ret void
}

LLVM IR (-O2):
define void @lecture_boutons(i8* nocapture writeonly %0) {
%2 = tail call i32 @inb(i32 889)
%3 = shl i32 %2, 24
%4 = ashr exact i32 %3, 24
%5 = and i32 %4, -16
%6 = xor i32 %5, 112
%7 = and i32 %6, 16
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i32 33686018, i32 33686019
%10 = shl nsw i32 %6, 3
%11 = and i32 %10, 256
%12 = shl i32 %2, 9
%13 = and i32 %12, 65536
%14 = shl nsw i32 %6, 18
%15 = and i32 %14, 16777216
%16 = or i32 %11, %13
%17 = or i32 %16, %15
%18 = or i32 %17, %9
%19 = bitcast i8* %0 to i32*
store i32 %18, i32* %19
ret void
}