#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef scalar_t__ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ *read_uint32(scalar_t__ *, int /*<<< orphan*/ const *,
                                int /*<<< orphan*/ const *);
const uint8_t *skip_bytes(const uint8_t *buffer, const uint8_t *buffer_end) {
  uint32_t v = 0;
  if ((buffer = read_uint32(&v, buffer, buffer_end)) == NULL)
    return NULL;
  buffer += v;
  if (buffer_end >= buffer)
    return buffer;
  return NULL;
}


x86 assembly (clang, -O0):
<skip_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
call   1030 <read_uint32@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1154 <skip_bytes+0x44>
movq   $0x0,-0x8(%rbp)
jmp    1187 <skip_bytes+0x77>
mov    -0x20(%rbp),%rax
shl    $0x2,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jb     117f <skip_bytes+0x6f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1187 <skip_bytes+0x77>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_bytes>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%rsi
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    %rbx,%rdx
call   1030 <read_uint32@plt>
mov    0x8(%rsp),%rcx
lea    (%rax,%rcx,4),%rcx
xor    %edx,%edx
cmp    %rbx,%rcx
cmovbe %rcx,%rdx
test   %rax,%rax
cmovne %rdx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32* @skip_bytes(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i64
store i32* %0, i32** %4
store i32* %1, i32** %5
store i64 0, i64* %6
%7 = load i32*, i32** %4
%8 = load i32*, i32** %5
%9 = call i32* @read_uint32(i64* %6, i32* %7, i32* %8)
store i32* %9, i32** %4
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
store i32* null, i32** %3
br label %22
12: ; preds = %2
%13 = load i64, i64* %6
%14 = load i32*, i32** %4
%15 = getelementptr inbounds i32, i32* %14, i64 %13
store i32* %15, i32** %4
%16 = load i32*, i32** %5
%17 = load i32*, i32** %4
%18 = icmp uge i32* %16, %17
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = load i32*, i32** %4
store i32* %20, i32** %3
br label %22
21: ; preds = %12
store i32* null, i32** %3
br label %22
22: ; preds = %21, %19, %11
%23 = load i32*, i32** %3
ret i32* %23
}

LLVM IR (-O2):
define i32* @skip_bytes(i32* %0, i32* %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%5 = call i32* @read_uint32(i64* %3, i32* %0, i32* %1)
%6 = icmp eq i32* %5, null
%7 = load i64, i64* %3
%8 = getelementptr inbounds i32, i32* %5, i64 %7
%9 = icmp ugt i32* %8, %1
%10 = select i1 %6, i1 true, i1 %9
%11 = select i1 %10, i32* null, i32* %8
ret i32* %11
}