#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 get_next_rec_buffer(int);
int /*<<< orphan*/ is_pulse(int);
int /*<<< orphan*/ logprintf(int, char *);
int get_next_pulse(int maxusec) {
  int data;
  data = get_next_rec_buffer(maxusec);
  if (data == 0)
    return (0);
  if (!is_pulse(data)) {
    logprintf(2, "pulse expected");
    return (0);
  }
  return (data & (0x00FFFFFF));
}


x86 assembly (clang, -O0):
<get_next_pulse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <get_next_rec_buffer@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    115c <get_next_pulse+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    1195 <get_next_pulse+0x65>
mov    -0xc(%rbp),%edi
call   1030 <is_pulse@plt>
cmp    $0x0,%eax
jne    118a <get_next_pulse+0x5a>
mov    $0x2,%edi
lea    0xe87(%rip),%rsi
call   1050 <logprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1195 <get_next_pulse+0x65>
mov    -0xc(%rbp),%eax
and    $0xffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_next_pulse>:
push   %rbp
push   %rbx
push   %rax
call   1040 <get_next_rec_buffer@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     1166 <get_next_pulse+0x36>
mov    %eax,%ebp
mov    %eax,%edi
call   1030 <is_pulse@plt>
test   %eax,%eax
je     1155 <get_next_pulse+0x25>
and    $0xffffff,%ebp
mov    %ebp,%ebx
jmp    1166 <get_next_pulse+0x36>
lea    0xea4(%rip),%rsi
mov    $0x2,%edi
call   1050 <logprintf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"pulse expected\00"
define i32 @get_next_pulse(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = call i32 @get_next_rec_buffer(i32 %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %19
10: ; preds = %1
%11 = load i32, i32* %4
%12 = call i32 @is_pulse(i32 %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = call i32 @logprintf(i32 2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %19
16: ; preds = %10
%17 = load i32, i32* %4
%18 = and i32 %17, 16777215
store i32 %18, i32* %2
br label %19
19: ; preds = %16, %14, %9
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@.str = [15 x i8] c"pulse expected\00"
define i32 @get_next_pulse(i32 %0) {
%2 = tail call i32 @get_next_rec_buffer(i32 %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = tail call i32 @is_pulse(i32 %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @logprintf(i32 2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %11
9: ; preds = %4
%10 = and i32 %2, 16777215
br label %11
11: ; preds = %1, %9, %7
%12 = phi i32 [ %10, %9 ], [ 0, %7 ], [ 0, %1 ]
ret i32 %12
}