#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*/ uint32_t;

/* Variables and functions */
unsigned char JFFS2_COMPR_NONE;
unsigned char JFFS2_COMPR_RTIME;
unsigned char JFFS2_COMPR_ZLIB;
int jffs2_rtime_compress(unsigned char *, unsigned char *, int /*<<< orphan*/ *,
                         int /*<<< orphan*/ *);
int jffs2_zlib_compress(unsigned char *, unsigned char *, int /*<<< orphan*/ *,
                        int /*<<< orphan*/ *);
unsigned char jffs2_compress(unsigned char *data_in, unsigned char *cpage_out,
                             uint32_t *datalen, uint32_t *cdatalen) {
  int ret;
  ret = jffs2_zlib_compress(data_in, cpage_out, datalen, cdatalen);
  if (!ret) {
    return JFFS2_COMPR_ZLIB;
  }
  ret = jffs2_rtime_compress(data_in, cpage_out, datalen, cdatalen);
  if (!ret) {
    return JFFS2_COMPR_RTIME;
  }
  return JFFS2_COMPR_NONE;
}


x86 assembly (clang, -O0):
<jffs2_compress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1040 <jffs2_zlib_compress@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    116b <jffs2_compress+0x4b>
mov    0x2e77(%rip),%rax
mov    (%rax),%al
mov    %al,-0x1(%rbp)
jmp    11aa <jffs2_compress+0x8a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <jffs2_rtime_compress@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    119e <jffs2_compress+0x7e>
mov    0x2e64(%rip),%rax
mov    (%rax),%al
mov    %al,-0x1(%rbp)
jmp    11aa <jffs2_compress+0x8a>
mov    0x2e2b(%rip),%rax
mov    (%rax),%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jffs2_compress>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
call   1040 <jffs2_zlib_compress@plt>
test   %eax,%eax
je     115b <jffs2_compress+0x3b>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <jffs2_rtime_compress@plt>
test   %eax,%eax
jne    1164 <jffs2_compress+0x44>
mov    0x2e9f(%rip),%rax
jmp    116b <jffs2_compress+0x4b>
mov    0x2e76(%rip),%rax
jmp    116b <jffs2_compress+0x4b>
mov    0x2e65(%rip),%rax
mov    (%rax),%al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@JFFS2_COMPR_ZLIB = global i8 0
@JFFS2_COMPR_RTIME = global i8 0
@JFFS2_COMPR_NONE = global i8 0
define zeroext i8 @jffs2_compress(i8* %0, i8* %1, i32* %2, i32* %3) {
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
%11 = load i8*, i8** %6
%12 = load i8*, i8** %7
%13 = load i32*, i32** %8
%14 = load i32*, i32** %9
%15 = call i32 @jffs2_zlib_compress(i8* %11, i8* %12, i32* %13, i32* %14)
store i32 %15, i32* %10
%16 = load i32, i32* %10
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %4
%19 = load i8, i8* @JFFS2_COMPR_ZLIB
store i8 %19, i8* %5
br label %32
20: ; preds = %4
%21 = load i8*, i8** %6
%22 = load i8*, i8** %7
%23 = load i32*, i32** %8
%24 = load i32*, i32** %9
%25 = call i32 @jffs2_rtime_compress(i8* %21, i8* %22, i32* %23, i32* %24)
store i32 %25, i32* %10
%26 = load i32, i32* %10
%27 = icmp ne i32 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %20
%29 = load i8, i8* @JFFS2_COMPR_RTIME
store i8 %29, i8* %5
br label %32
30: ; preds = %20
%31 = load i8, i8* @JFFS2_COMPR_NONE
store i8 %31, i8* %5
br label %32
32: ; preds = %30, %28, %18
%33 = load i8, i8* %5
ret i8 %33
}

LLVM IR (-O2):
@JFFS2_COMPR_ZLIB = global i8 0
@JFFS2_COMPR_RTIME = global i8 0
@JFFS2_COMPR_NONE = global i8 0
define zeroext i8 @jffs2_compress(i8* %0, i8* %1, i32* %2, i32* %3) {
%5 = tail call i32 @jffs2_zlib_compress(i8* %0, i8* %1, i32* %2, i32* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i32 @jffs2_rtime_compress(i8* %0, i8* %1, i32* %2, i32* %3)
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8* @JFFS2_COMPR_RTIME, i8* @JFFS2_COMPR_NONE
br label %11
11: ; preds = %7, %4
%12 = phi i8* [ @JFFS2_COMPR_ZLIB, %4 ], [ %10, %7 ]
%13 = load i8, i8* %12
ret i8 %13
}