#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*/);
__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);
  }
  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     118e <bpf_decoder+0x5e>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1050 <LIRC_VALUE@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x10000,%eax
cmp    $0x0,%eax
je     1189 <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>
jmp    118e <bpf_decoder+0x5e>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bpf_decoder>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%edi
call   1030 <LIRC_IS_PULSE@plt>
test   %rax,%rax
je     1160 <bpf_decoder+0x30>
mov    (%rbx),%edi
call   1050 <LIRC_VALUE@plt>
test   $0x10000,%eax
je     1160 <bpf_decoder+0x30>
movzwl %ax,%edx
mov    %rbx,%rdi
mov    $0x40,%esi
xor    %ecx,%ecx
call   1040 <bpf_rc_keydown@plt>
xor    %eax,%eax
pop    %rbx
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 %21
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
br label %21
21: ; preds = %20, %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 %13, 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 = %5, %10, %1
ret i32 0
}