#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 tl_scheme_object {
  int dummy;
};
struct tl_compiler {
  int dummy;
};
struct tl_buffer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ tl_compiler_clear_errors(struct tl_compiler *);
int tl_expression_unserialize(struct tl_compiler *, int *, int, int,
                              int /*<<< orphan*/ *, struct tl_scheme_object **);
int /*<<< orphan*/ tl_scheme_object_free(struct tl_scheme_object *);
int /*<<< orphan*/ tl_scheme_object_sbdump(struct tl_buffer *,
                                           struct tl_scheme_object *);
int tl_unserialize(struct tl_compiler *C, struct tl_buffer *b, int *input,
                   int ilen, int section_mask) {
  struct tl_scheme_object *O = NULL;
  tl_compiler_clear_errors(C);
  int r = tl_expression_unserialize(C, input, ilen, section_mask, NULL, &O);
  if (r >= 0 && O != NULL) {
    tl_scheme_object_sbdump(b, O);
    tl_scheme_object_free(O);
  }
  return r;
}


x86 assembly (clang, -O0):
<tl_unserialize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <tl_compiler_clear_errors@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
xor    %eax,%eax
mov    %eax,%r8d
lea    -0x28(%rbp),%r9
call   1060 <tl_expression_unserialize@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     11b6 <tl_unserialize+0x76>
cmpq   $0x0,-0x28(%rbp)
je     11b6 <tl_unserialize+0x76>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <tl_scheme_object_sbdump@plt>
mov    -0x28(%rbp),%rdi
call   1040 <tl_scheme_object_free@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tl_unserialize>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %rdx,%rbp
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
call   1030 <tl_compiler_clear_errors@plt>
lea    0x8(%rsp),%r9
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
mov    %r15d,%ecx
xor    %r8d,%r8d
call   1060 <tl_expression_unserialize@plt>
mov    %eax,%ebp
test   %eax,%eax
js     11a4 <tl_unserialize+0x64>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     11a4 <tl_unserialize+0x64>
mov    %r14,%rdi
call   1050 <tl_scheme_object_sbdump@plt>
mov    0x8(%rsp),%rdi
call   1040 <tl_scheme_object_free@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tl_compiler = type { i32 }
%struct.tl_buffer = type { i32 }
%struct.tl_scheme_object = type { i32 }
define i32 @tl_unserialize(%struct.tl_compiler* %0, %struct.tl_buffer* %1, i32* %2, i32 %3, i32 %4) {
%6 = alloca %struct.tl_compiler*
%7 = alloca %struct.tl_buffer*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.tl_scheme_object*
%12 = alloca i32
store %struct.tl_compiler* %0, %struct.tl_compiler** %6
store %struct.tl_buffer* %1, %struct.tl_buffer** %7
store i32* %2, i32** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store %struct.tl_scheme_object* null, %struct.tl_scheme_object** %11
%13 = load %struct.tl_compiler*, %struct.tl_compiler** %6
%14 = call i32 @tl_compiler_clear_errors(%struct.tl_compiler* %13)
%15 = load %struct.tl_compiler*, %struct.tl_compiler** %6
%16 = load i32*, i32** %8
%17 = load i32, i32* %9
%18 = load i32, i32* %10
%19 = call i32 @tl_expression_unserialize(%struct.tl_compiler* %15, i32* %16, i32 %17, i32 %18, i32* null, %struct.tl_scheme_object** %11)
store i32 %19, i32* %12
%20 = load i32, i32* %12
%21 = icmp sge i32 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %5
%23 = load %struct.tl_scheme_object*, %struct.tl_scheme_object** %11
%24 = icmp ne %struct.tl_scheme_object* %23, null
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = load %struct.tl_buffer*, %struct.tl_buffer** %7
%27 = load %struct.tl_scheme_object*, %struct.tl_scheme_object** %11
%28 = call i32 @tl_scheme_object_sbdump(%struct.tl_buffer* %26, %struct.tl_scheme_object* %27)
%29 = load %struct.tl_scheme_object*, %struct.tl_scheme_object** %11
%30 = call i32 @tl_scheme_object_free(%struct.tl_scheme_object* %29)
br label %31
31: ; preds = %25, %22, %5
%32 = load i32, i32* %12
ret i32 %32
}

LLVM IR (-O2):
%struct.tl_compiler = type { i32 }
%struct.tl_buffer = type { i32 }
%struct.tl_scheme_object = type { i32 }
define i32 @tl_unserialize(%struct.tl_compiler* %0, %struct.tl_buffer* %1, i32* %2, i32 %3, i32 %4) {
%6 = alloca %struct.tl_scheme_object*
%7 = bitcast %struct.tl_scheme_object** %6 to i8*
store %struct.tl_scheme_object* null, %struct.tl_scheme_object** %6
%8 = tail call i32 @tl_compiler_clear_errors(%struct.tl_compiler* %0)
%9 = call i32 @tl_expression_unserialize(%struct.tl_compiler* %0, i32* %2, i32 %3, i32 %4, i32* null, %struct.tl_scheme_object** %6)
%10 = icmp sgt i32 %9, -1
%11 = load %struct.tl_scheme_object*, %struct.tl_scheme_object** %6
%12 = icmp ne %struct.tl_scheme_object* %11, null
%13 = select i1 %10, i1 %12, i1 false
br i1 %13, label %14, label %18
14: ; preds = %5
%15 = call i32 @tl_scheme_object_sbdump(%struct.tl_buffer* %1, %struct.tl_scheme_object* %11)
%16 = load %struct.tl_scheme_object*, %struct.tl_scheme_object** %6
%17 = call i32 @tl_scheme_object_free(%struct.tl_scheme_object* %16)
br label %18
18: ; preds = %14, %5
ret i32 %9
}