#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 kfifo {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ __kfifo_add_out(struct kfifo *, unsigned int);
unsigned int __kfifo_peek_n(struct kfifo *, unsigned int);
unsigned int kfifo_len(struct kfifo *);
int /*<<< orphan*/ kfifo_reset_out(struct kfifo *);
void __kfifo_skip_rec(struct kfifo *fifo, unsigned int recsize) {
  unsigned int l;
  if (recsize) {
    l = __kfifo_peek_n(fifo, recsize);
    if (l + recsize <= kfifo_len(fifo)) {
      __kfifo_add_out(fifo, l + recsize);
      return;
    }
  }
  kfifo_reset_out(fifo);
}


x86 assembly (clang, -O0):
<__kfifo_skip_rec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11a0 <__kfifo_skip_rec+0x60>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <__kfifo_peek_n@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <kfifo_len@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
ja     119b <__kfifo_skip_rec+0x5b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
add    -0xc(%rbp),%esi
call   1050 <__kfifo_add_out@plt>
jmp    11a9 <__kfifo_skip_rec+0x69>
jmp    11a0 <__kfifo_skip_rec+0x60>
mov    -0x8(%rbp),%rdi
call   1030 <kfifo_reset_out@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__kfifo_skip_rec>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
test   %esi,%esi
je     1165 <__kfifo_skip_rec+0x25>
mov    %esi,%ebx
mov    %r14,%rdi
call   1040 <__kfifo_peek_n@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r14,%rdi
call   1060 <kfifo_len@plt>
cmp    %eax,%ebp
jbe    1171 <__kfifo_skip_rec+0x31>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <kfifo_reset_out@plt>
mov    %r14,%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <__kfifo_add_out@plt>

LLVM IR (-O0):
%struct.kfifo = type { i32 }
define void @__kfifo_skip_rec(%struct.kfifo* %0, i32 %1) {
%3 = alloca %struct.kfifo*
%4 = alloca i32
%5 = alloca i32
store %struct.kfifo* %0, %struct.kfifo** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %25
8: ; preds = %2
%9 = load %struct.kfifo*, %struct.kfifo** %3
%10 = load i32, i32* %4
%11 = call i32 @__kfifo_peek_n(%struct.kfifo* %9, i32 %10)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = add i32 %12, %13
%15 = load %struct.kfifo*, %struct.kfifo** %3
%16 = call i32 @kfifo_len(%struct.kfifo* %15)
%17 = icmp ule i32 %14, %16
br i1 %17, label %18, label %24
18: ; preds = %8
%19 = load %struct.kfifo*, %struct.kfifo** %3
%20 = load i32, i32* %5
%21 = load i32, i32* %4
%22 = add i32 %20, %21
%23 = call i32 @__kfifo_add_out(%struct.kfifo* %19, i32 %22)
br label %28
24: ; preds = %8
br label %25
25: ; preds = %24, %2
%26 = load %struct.kfifo*, %struct.kfifo** %3
%27 = call i32 @kfifo_reset_out(%struct.kfifo* %26)
br label %28
28: ; preds = %25, %18
ret void
}

LLVM IR (-O2):
%struct.kfifo = type { i32 }
define void @__kfifo_skip_rec(%struct.kfifo* %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = tail call i32 @__kfifo_peek_n(%struct.kfifo* %0, i32 %1)
%6 = add i32 %5, %1
%7 = tail call i32 @kfifo_len(%struct.kfifo* %0)
%8 = icmp ugt i32 %6, %7
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = tail call i32 @__kfifo_add_out(%struct.kfifo* %0, i32 %6)
br label %13
11: ; preds = %4, %2
%12 = tail call i32 @kfifo_reset_out(%struct.kfifo* %0)
br label %13
13: ; preds = %11, %9
ret void
}