#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*/ va_list;
struct katcl_parse {
  int dummy;
};
struct katcl_line {
  int dummy;
};

/* Variables and functions */
scalar_t__ append_parse_katcl(struct katcl_line *, struct katcl_parse *);
struct katcl_parse *create_referenced_parse_katcl();
int /*<<< orphan*/ destroy_parse_katcl(struct katcl_parse *);
int vlog_parse_katcl(struct katcl_parse *, int, char *, char *,
                     int /*<<< orphan*/);
int vlog_message_katcl(struct katcl_line *cl, int level, char *name, char *fmt,
                       va_list args) {
  struct katcl_parse *px;
  int result;
  px = create_referenced_parse_katcl();
  if (px == NULL) {
    return -1;
  }
  result = vlog_parse_katcl(px, level, name, fmt, args);
  if (result < 0) {
    destroy_parse_katcl(px);
    return -1;
  }
  if (append_parse_katcl(cl, px) < 0) {
    destroy_parse_katcl(px);
    return -1;
  }
  destroy_parse_katcl(px);
  return result;
}


x86 assembly (clang, -O0):
<vlog_message_katcl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    $0x0,%al
call   1060 <create_referenced_parse_katcl@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    117d <vlog_message_katcl+0x3d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f2 <vlog_message_katcl+0xb2>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1040 <vlog_parse_katcl@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    11b7 <vlog_message_katcl+0x77>
mov    -0x38(%rbp),%rdi
call   1050 <destroy_parse_katcl@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f2 <vlog_message_katcl+0xb2>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <append_parse_katcl@plt>
cmp    $0x0,%rax
jge    11e3 <vlog_message_katcl+0xa3>
mov    -0x38(%rbp),%rdi
call   1050 <destroy_parse_katcl@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f2 <vlog_message_katcl+0xb2>
mov    -0x38(%rbp),%rdi
call   1050 <destroy_parse_katcl@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vlog_message_katcl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r15d
mov    %rcx,%r12
mov    %rdx,%rbp
mov    %esi,%r14d
mov    %rdi,(%rsp)
xor    %eax,%eax
call   1060 <create_referenced_parse_katcl@plt>
mov    $0xffffffff,%r13d
test   %rax,%rax
je     11b9 <vlog_message_katcl+0x79>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14d,%esi
mov    %rbp,%rdx
mov    %r12,%rcx
mov    %r15d,%r8d
call   1040 <vlog_parse_katcl@plt>
test   %eax,%eax
js     11b1 <vlog_message_katcl+0x71>
mov    %eax,%ebp
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   1030 <append_parse_katcl@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <destroy_parse_katcl@plt>
test   %r14,%r14
mov    $0xffffffff,%eax
cmovs  %eax,%ebp
mov    %ebp,%r13d
jmp    11b9 <vlog_message_katcl+0x79>
mov    %rbx,%rdi
call   1050 <destroy_parse_katcl@plt>
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.katcl_line = type { i32 }
%struct.katcl_parse = type { i32 }
define i32 @vlog_message_katcl(%struct.katcl_line* %0, i32 %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca %struct.katcl_line*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca %struct.katcl_parse*
%13 = alloca i32
store %struct.katcl_line* %0, %struct.katcl_line** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
%14 = call %struct.katcl_parse* (...) @create_referenced_parse_katcl()
store %struct.katcl_parse* %14, %struct.katcl_parse** %12
%15 = load %struct.katcl_parse*, %struct.katcl_parse** %12
%16 = icmp eq %struct.katcl_parse* %15, null
br i1 %16, label %17, label %18
17: ; preds = %5
store i32 -1, i32* %6
br label %42
18: ; preds = %5
%19 = load %struct.katcl_parse*, %struct.katcl_parse** %12
%20 = load i32, i32* %8
%21 = load i8*, i8** %9
%22 = load i8*, i8** %10
%23 = load i32, i32* %11
%24 = call i32 @vlog_parse_katcl(%struct.katcl_parse* %19, i32 %20, i8* %21, i8* %22, i32 %23)
store i32 %24, i32* %13
%25 = load i32, i32* %13
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %18
%28 = load %struct.katcl_parse*, %struct.katcl_parse** %12
%29 = call i32 @destroy_parse_katcl(%struct.katcl_parse* %28)
store i32 -1, i32* %6
br label %42
30: ; preds = %18
%31 = load %struct.katcl_line*, %struct.katcl_line** %7
%32 = load %struct.katcl_parse*, %struct.katcl_parse** %12
%33 = call i64 @append_parse_katcl(%struct.katcl_line* %31, %struct.katcl_parse* %32)
%34 = icmp slt i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %30
%36 = load %struct.katcl_parse*, %struct.katcl_parse** %12
%37 = call i32 @destroy_parse_katcl(%struct.katcl_parse* %36)
store i32 -1, i32* %6
br label %42
38: ; preds = %30
%39 = load %struct.katcl_parse*, %struct.katcl_parse** %12
%40 = call i32 @destroy_parse_katcl(%struct.katcl_parse* %39)
%41 = load i32, i32* %13
store i32 %41, i32* %6
br label %42
42: ; preds = %38, %35, %27, %17
%43 = load i32, i32* %6
ret i32 %43
}

LLVM IR (-O2):
%struct.katcl_line = type { i32 }
%struct.katcl_parse = type { i32 }
define i32 @vlog_message_katcl(%struct.katcl_line* %0, i32 %1, i8* %2, i8* %3, i32 %4) {
%6 = tail call %struct.katcl_parse* (...) @create_referenced_parse_katcl()
%7 = icmp eq %struct.katcl_parse* %6, null
br i1 %7, label %18, label %8
8: ; preds = %5
%9 = tail call i32 @vlog_parse_katcl(%struct.katcl_parse* %6, i32 %1, i8* %2, i8* %3, i32 %4)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @destroy_parse_katcl(%struct.katcl_parse* %6)
br label %18
13: ; preds = %8
%14 = tail call i64 @append_parse_katcl(%struct.katcl_line* %0, %struct.katcl_parse* %6)
%15 = icmp slt i64 %14, 0
%16 = tail call i32 @destroy_parse_katcl(%struct.katcl_parse* %6)
%17 = select i1 %15, i32 -1, i32 %9
br label %18
18: ; preds = %13, %5, %11
%19 = phi i32 [ -1, %11 ], [ -1, %5 ], [ %17, %13 ]
ret i32 %19
}