#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;
};

/* Variables and functions */
int add_buffer_parse_katcl(struct katcl_parse *, int, char *,
                           int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int add_string_parse_katcl(struct katcl_parse *p, int flags, char *buffer) {
  if (buffer) {
    return add_buffer_parse_katcl(p, flags, buffer, strlen(buffer));
  } else {
    return add_buffer_parse_katcl(p, flags, NULL, 0);
  }
}


x86 assembly (clang, -O0):
<add_string_parse_katcl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1177 <add_string_parse_katcl+0x57>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    %eax,%ecx
call   1040 <add_buffer_parse_katcl@plt>
mov    %eax,-0x4(%rbp)
jmp    118c <add_string_parse_katcl+0x6c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <add_buffer_parse_katcl@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_string_parse_katcl>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbp
test   %rdx,%rdx
je     1147 <add_string_parse_katcl+0x27>
mov    %rdx,%rbx
mov    %rdx,%rdi
call   1030 <strlen@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
mov    %eax,%ecx
jmp    1151 <add_string_parse_katcl+0x31>
mov    %rbp,%rdi
mov    %r14d,%esi
xor    %edx,%edx
xor    %ecx,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <add_buffer_parse_katcl@plt>

LLVM IR (-O0):
%struct.katcl_parse = type { i32 }
define i32 @add_string_parse_katcl(%struct.katcl_parse* %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.katcl_parse*
%6 = alloca i32
%7 = alloca i8*
store %struct.katcl_parse* %0, %struct.katcl_parse** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%8 = load i8*, i8** %7
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %17
10: ; preds = %3
%11 = load %struct.katcl_parse*, %struct.katcl_parse** %5
%12 = load i32, i32* %6
%13 = load i8*, i8** %7
%14 = load i8*, i8** %7
%15 = call i32 @strlen(i8* %14)
%16 = call i32 @add_buffer_parse_katcl(%struct.katcl_parse* %11, i32 %12, i8* %13, i32 %15)
store i32 %16, i32* %4
br label %21
17: ; preds = %3
%18 = load %struct.katcl_parse*, %struct.katcl_parse** %5
%19 = load i32, i32* %6
%20 = call i32 @add_buffer_parse_katcl(%struct.katcl_parse* %18, i32 %19, i8* null, i32 0)
store i32 %20, i32* %4
br label %21
21: ; preds = %17, %10
%22 = load i32, i32* %4
ret i32 %22
}

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