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

/* Variables and functions */
int add_end_parse_katcl(struct katcl_parse *);
int after_append_katcl(struct katcl_line *, int, int);
struct katcl_parse *before_append_katcl(struct katcl_line *, int);
int append_end_katcl(struct katcl_line *l) {
  struct katcl_parse *p;
  int result;
  p = before_append_katcl(l, 0x02);
  if (p == NULL) {
    return -1;
  }
  result = add_end_parse_katcl(p);
  return after_append_katcl(l, 0x02, result);
}


x86 assembly (clang, -O0):
<append_end_katcl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1030 <before_append_katcl@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1165 <append_end_katcl+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    1185 <append_end_katcl+0x55>
mov    -0x18(%rbp),%rdi
call   1040 <add_end_parse_katcl@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    $0x2,%esi
call   1050 <after_append_katcl@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_end_katcl>:
push   %rbx
mov    %rdi,%rbx
mov    $0x2,%esi
call   1030 <before_append_katcl@plt>
test   %rax,%rax
je     115b <append_end_katcl+0x2b>
mov    %rax,%rdi
call   1040 <add_end_parse_katcl@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %eax,%edx
pop    %rbx
jmp    1050 <after_append_katcl@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.katcl_line = type { i32 }
%struct.katcl_parse = type { i32 }
define i32 @append_end_katcl(%struct.katcl_line* %0) {
%2 = alloca i32
%3 = alloca %struct.katcl_line*
%4 = alloca %struct.katcl_parse*
%5 = alloca i32
store %struct.katcl_line* %0, %struct.katcl_line** %3
%6 = load %struct.katcl_line*, %struct.katcl_line** %3
%7 = call %struct.katcl_parse* @before_append_katcl(%struct.katcl_line* %6, i32 2)
store %struct.katcl_parse* %7, %struct.katcl_parse** %4
%8 = load %struct.katcl_parse*, %struct.katcl_parse** %4
%9 = icmp eq %struct.katcl_parse* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 -1, i32* %2
br label %17
11: ; preds = %1
%12 = load %struct.katcl_parse*, %struct.katcl_parse** %4
%13 = call i32 @add_end_parse_katcl(%struct.katcl_parse* %12)
store i32 %13, i32* %5
%14 = load %struct.katcl_line*, %struct.katcl_line** %3
%15 = load i32, i32* %5
%16 = call i32 @after_append_katcl(%struct.katcl_line* %14, i32 2, i32 %15)
store i32 %16, i32* %2
br label %17
17: ; preds = %11, %10
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
%struct.katcl_line = type { i32 }
%struct.katcl_parse = type { i32 }
define i32 @append_end_katcl(%struct.katcl_line* %0) {
%2 = tail call %struct.katcl_parse* @before_append_katcl(%struct.katcl_line* %0, i32 2)
%3 = icmp eq %struct.katcl_parse* %2, null
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 @add_end_parse_katcl(%struct.katcl_parse* %2)
%6 = tail call i32 @after_append_katcl(%struct.katcl_line* %0, i32 2, i32 %5)
br label %7
7: ; preds = %1, %4
%8 = phi i32 [ %6, %4 ], [ -1, %1 ]
ret i32 %8
}