#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 */
scalar_t__ LIRC_IS_PULSE(unsigned int);
unsigned int LIRC_VALUE(unsigned int);
int /*<<< orphan*/ bpf_rc_keydown(unsigned int *, int, unsigned int,
                                  int /*<<< orphan*/);
int /*<<< orphan*/ bpf_rc_pointer_rel(unsigned int *, unsigned int,
                                      unsigned int);
__attribute__((section("lirc_mode2"), used)) int
bpf_decoder(unsigned int *sample) {
  if (LIRC_IS_PULSE(*sample)) {
    unsigned int duration = LIRC_VALUE(*sample);
    if (duration & 0x10000)
      bpf_rc_keydown(sample, 0x40, duration & 0xffff, 0);
    if (duration & 0x20000)
      bpf_rc_pointer_rel(sample, (duration >> 8) & 0xff, duration & 0xff);
  }
  return 0;
}


x86 assembly (clang, -O0):
<bpf_decoder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <LIRC_IS_PULSE@plt>
cmp    $0x0,%rax
je     11cd <bpf_decoder+0x8d>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1060 <LIRC_VALUE@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x10000,%eax
cmp    $0x0,%eax
je     1199 <bpf_decoder+0x59>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
and    $0xffff,%edx
mov    $0x40,%esi
xor    %ecx,%ecx
call   1040 <bpf_rc_keydown@plt>
mov    -0xc(%rbp),%eax
and    $0x20000,%eax
cmp    $0x0,%eax
je     11c8 <bpf_decoder+0x88>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
shr    $0x8,%esi
and    $0xff,%esi
mov    -0xc(%rbp),%edx
and    $0xff,%edx
call   1050 <bpf_rc_pointer_rel@plt>
jmp    11cd <bpf_decoder+0x8d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bpf_decoder>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%edi
call   1030 <LIRC_IS_PULSE@plt>
test   %rax,%rax
je     118c <bpf_decoder+0x4c>
mov    (%r14),%edi
call   1060 <LIRC_VALUE@plt>
mov    %eax,%ebx
test   $0x10000,%eax
je     1176 <bpf_decoder+0x36>
movzwl %bx,%edx
mov    %r14,%rdi
mov    $0x40,%esi
xor    %ecx,%ecx
call   1040 <bpf_rc_keydown@plt>
test   $0x20000,%ebx
je     118c <bpf_decoder+0x4c>
movzbl %bh,%esi
movzbl %bl,%edx
mov    %r14,%rdi
call   1050 <bpf_rc_pointer_rel@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i32 (i32*)* @bpf_decoder to i8*)], section "llvm.metadata"
define i32 @bpf_decoder(i32* %0) section "lirc_mode2" {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = load i32, i32* %4
%6 = call i64 @LIRC_IS_PULSE(i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %33
8: ; preds = %1
%9 = load i32*, i32** %2
%10 = load i32, i32* %9
%11 = call i32 @LIRC_VALUE(i32 %10)
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = and i32 %12, 65536
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %8
%16 = load i32*, i32** %2
%17 = load i32, i32* %3
%18 = and i32 %17, 65535
%19 = call i32 @bpf_rc_keydown(i32* %16, i32 64, i32 %18, i32 0)
br label %20
20: ; preds = %15, %8
%21 = load i32, i32* %3
%22 = and i32 %21, 131072
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %20
%25 = load i32*, i32** %2
%26 = load i32, i32* %3
%27 = lshr i32 %26, 8
%28 = and i32 %27, 255
%29 = load i32, i32* %3
%30 = and i32 %29, 255
%31 = call i32 @bpf_rc_pointer_rel(i32* %25, i32 %28, i32 %30)
br label %32
32: ; preds = %24, %20
br label %33
33: ; preds = %32, %1
ret i32 0
}

LLVM IR (-O2):
@llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i32 (i32*)* @bpf_decoder to i8*)], section "llvm.metadata"
define i32 @bpf_decoder(i32* %0) section "lirc_mode2" {
%2 = load i32, i32* %0
%3 = tail call i64 @LIRC_IS_PULSE(i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %1
%6 = load i32, i32* %0
%7 = tail call i32 @LIRC_VALUE(i32 %6)
%8 = and i32 %7, 65536
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %5
%11 = and i32 %7, 65535
%12 = tail call i32 @bpf_rc_keydown(i32* %0, i32 64, i32 %11, i32 0)
br label %13
13: ; preds = %10, %5
%14 = and i32 %7, 131072
%15 = icmp eq i32 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %13
%17 = lshr i32 %7, 8
%18 = and i32 %17, 255
%19 = and i32 %7, 255
%20 = tail call i32 @bpf_rc_pointer_rel(i32* %0, i32 %18, i32 %19)
br label %21
21: ; preds = %13, %16, %1
ret i32 0
}