#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 */
struct evbuffer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ evbuffer_copyout(struct evbuffer *, int *, int);
int evbuffer_get_length(struct evbuffer *);
int message_incomplete(struct evbuffer *b) {
  int bsize;
  int msize;
  bsize = evbuffer_get_length(b);
  if (bsize < sizeof(int))
    return 1;
  evbuffer_copyout(b, &msize, sizeof(int));
  if (bsize < (2 * sizeof(int) + msize))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<message_incomplete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <evbuffer_get_length@plt>
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x4,%rax
jae    1152 <message_incomplete+0x32>
movl   $0x1,-0x4(%rbp)
jmp    118c <message_incomplete+0x6c>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1040 <evbuffer_copyout@plt>
movslq -0x14(%rbp),%rax
movslq -0x18(%rbp),%rcx
add    $0x8,%rcx
cmp    %rcx,%rax
jae    1185 <message_incomplete+0x65>
movl   $0x1,-0x4(%rbp)
jmp    118c <message_incomplete+0x6c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<message_incomplete>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <evbuffer_get_length@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x4,%ecx
jb     115e <message_incomplete+0x3e>
movslq %ecx,%r14
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <evbuffer_copyout@plt>
movslq 0x4(%rsp),%rcx
add    $0x8,%rcx
xor    %eax,%eax
cmp    %r14,%rcx
seta   %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.evbuffer = type { i32 }
define i32 @message_incomplete(%struct.evbuffer* %0) {
%2 = alloca i32
%3 = alloca %struct.evbuffer*
%4 = alloca i32
%5 = alloca i32
store %struct.evbuffer* %0, %struct.evbuffer** %3
%6 = load %struct.evbuffer*, %struct.evbuffer** %3
%7 = call i32 @evbuffer_get_length(%struct.evbuffer* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = icmp ult i64 %9, 4
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 1, i32* %2
br label %23
12: ; preds = %1
%13 = load %struct.evbuffer*, %struct.evbuffer** %3
%14 = call i32 @evbuffer_copyout(%struct.evbuffer* %13, i32* %5, i32 4)
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = add i64 8, %18
%20 = icmp ult i64 %16, %19
br i1 %20, label %21, label %22
21: ; preds = %12
store i32 1, i32* %2
br label %23
22: ; preds = %12
store i32 0, i32* %2
br label %23
23: ; preds = %22, %21, %11
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
%struct.evbuffer = type { i32 }
define i32 @message_incomplete(%struct.evbuffer* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @evbuffer_get_length(%struct.evbuffer* %0)
%5 = icmp ult i32 %4, 4
br i1 %5, label %14, label %6
6: ; preds = %1
%7 = sext i32 %4 to i64
%8 = call i32 @evbuffer_copyout(%struct.evbuffer* %0, i32* %2, i32 4)
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = add nsw i64 %10, 8
%12 = icmp ugt i64 %11, %7
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %6, %1
%15 = phi i32 [ 1, %1 ], [ %13, %6 ]
ret i32 %15
}