#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_parameter_parse_katcl(struct katcl_parse *, int, struct katcl_parse *,
                              unsigned int);
int after_append_katcl(struct katcl_line *, int, int);
struct katcl_parse *before_append_katcl(struct katcl_line *, int);
int append_parameter_katcl(struct katcl_line *l, int flags,
                           struct katcl_parse *px, unsigned int index) {
  struct katcl_parse *p;
  int result;
  p = before_append_katcl(l, flags);
  if (p == NULL) {
    return -1;
  }
  result = add_parameter_parse_katcl(p, flags, px, index);
  return after_append_katcl(l, flags, result);
}


x86 assembly (clang, -O0):
<append_parameter_katcl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <before_append_katcl@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    116d <append_parameter_katcl+0x3d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1195 <append_parameter_katcl+0x65>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1040 <add_parameter_parse_katcl@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x34(%rbp),%edx
call   1050 <after_append_katcl@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_parameter_katcl>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %rdx,%rbp
mov    %esi,%ebx
mov    %rdi,%r14
call   1030 <before_append_katcl@plt>
test   %rax,%rax
je     1172 <append_parameter_katcl+0x42>
mov    %rax,%rdi
mov    %ebx,%esi
mov    %rbp,%rdx
mov    %r15d,%ecx
call   1040 <add_parameter_parse_katcl@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <after_append_katcl@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.katcl_line = type { i32 }
%struct.katcl_parse = type { i32 }
define i32 @append_parameter_katcl(%struct.katcl_line* %0, i32 %1, %struct.katcl_parse* %2, i32 %3) {
%5 = alloca i32
%6 = alloca %struct.katcl_line*
%7 = alloca i32
%8 = alloca %struct.katcl_parse*
%9 = alloca i32
%10 = alloca %struct.katcl_parse*
%11 = alloca i32
store %struct.katcl_line* %0, %struct.katcl_line** %6
store i32 %1, i32* %7
store %struct.katcl_parse* %2, %struct.katcl_parse** %8
store i32 %3, i32* %9
%12 = load %struct.katcl_line*, %struct.katcl_line** %6
%13 = load i32, i32* %7
%14 = call %struct.katcl_parse* @before_append_katcl(%struct.katcl_line* %12, i32 %13)
store %struct.katcl_parse* %14, %struct.katcl_parse** %10
%15 = load %struct.katcl_parse*, %struct.katcl_parse** %10
%16 = icmp eq %struct.katcl_parse* %15, null
br i1 %16, label %17, label %18
17: ; preds = %4
store i32 -1, i32* %5
br label %28
18: ; preds = %4
%19 = load %struct.katcl_parse*, %struct.katcl_parse** %10
%20 = load i32, i32* %7
%21 = load %struct.katcl_parse*, %struct.katcl_parse** %8
%22 = load i32, i32* %9
%23 = call i32 @add_parameter_parse_katcl(%struct.katcl_parse* %19, i32 %20, %struct.katcl_parse* %21, i32 %22)
store i32 %23, i32* %11
%24 = load %struct.katcl_line*, %struct.katcl_line** %6
%25 = load i32, i32* %7
%26 = load i32, i32* %11
%27 = call i32 @after_append_katcl(%struct.katcl_line* %24, i32 %25, i32 %26)
store i32 %27, i32* %5
br label %28
28: ; preds = %18, %17
%29 = load i32, i32* %5
ret i32 %29
}

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