#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_in(struct kfifo *, unsigned int);
unsigned int __kfifo_in_n(struct kfifo *, void const *, unsigned int,
                          unsigned int);
int /*<<< orphan*/ __kfifo_poke_n(struct kfifo *, unsigned int, unsigned int);
scalar_t__ likely(int);
unsigned int __kfifo_in_rec(struct kfifo *fifo, const void *from,
                            unsigned int n, unsigned int recsize) {
  unsigned int ret;
  ret = __kfifo_in_n(fifo, from, n, recsize);
  if (likely(ret == 0)) {
    if (recsize)
      __kfifo_poke_n(fifo, recsize, n);
    __kfifo_add_in(fifo, n + recsize);
  }
  return ret;
}


x86 assembly (clang, -O0):
<__kfifo_in_rec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <__kfifo_in_n@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <likely@plt>
cmp    $0x0,%rax
je     11af <__kfifo_in_rec+0x6f>
cmpl   $0x0,-0x18(%rbp)
je     11a0 <__kfifo_in_rec+0x60>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1060 <__kfifo_poke_n@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    -0x18(%rbp),%esi
call   1030 <__kfifo_add_in@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__kfifo_in_rec>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%r15d
mov    %rdi,%r14
call   1040 <__kfifo_in_n@plt>
mov    %eax,%ebp
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <likely@plt>
test   %rax,%rax
je     1186 <__kfifo_in_rec+0x46>
test   %ebx,%ebx
je     1179 <__kfifo_in_rec+0x39>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
call   1060 <__kfifo_poke_n@plt>
add    %r15d,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <__kfifo_add_in@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.kfifo = type { i32 }
define i32 @__kfifo_in_rec(%struct.kfifo* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca %struct.kfifo*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store %struct.kfifo* %0, %struct.kfifo** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load %struct.kfifo*, %struct.kfifo** %5
%11 = load i8*, i8** %6
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = call i32 @__kfifo_in_n(%struct.kfifo* %10, i8* %11, i32 %12, i32 %13)
store i32 %14, i32* %9
%15 = load i32, i32* %9
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = call i64 @likely(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %34
20: ; preds = %4
%21 = load i32, i32* %8
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load %struct.kfifo*, %struct.kfifo** %5
%25 = load i32, i32* %8
%26 = load i32, i32* %7
%27 = call i32 @__kfifo_poke_n(%struct.kfifo* %24, i32 %25, i32 %26)
br label %28
28: ; preds = %23, %20
%29 = load %struct.kfifo*, %struct.kfifo** %5
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = add i32 %30, %31
%33 = call i32 @__kfifo_add_in(%struct.kfifo* %29, i32 %32)
br label %34
34: ; preds = %28, %4
%35 = load i32, i32* %9
ret i32 %35
}

LLVM IR (-O2):
%struct.kfifo = type { i32 }
define i32 @__kfifo_in_rec(%struct.kfifo* %0, i8* %1, i32 %2, i32 %3) {
%5 = tail call i32 @__kfifo_in_n(%struct.kfifo* %0, i8* %1, i32 %2, i32 %3)
%6 = icmp eq i32 %5, 0
%7 = zext i1 %6 to i32
%8 = tail call i64 @likely(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %4
%11 = icmp eq i32 %3, 0
br i1 %11, label %14, label %12
12: ; preds = %10
%13 = tail call i32 @__kfifo_poke_n(%struct.kfifo* %0, i32 %3, i32 %2)
br label %14
14: ; preds = %12, %10
%15 = add i32 %3, %2
%16 = tail call i32 @__kfifo_add_in(%struct.kfifo* %0, i32 %15)
br label %17
17: ; preds = %14, %4
ret i32 %5
}