#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 */

/* Variables and functions */
char *fixspaces(int /*<<< orphan*/);
int /*<<< orphan*/ strdup(char const *);
int strlen(char const *);
scalar_t__ strncmp(char const *, char const *, int const);
int add_item(const char *line, const char *name, char **item) {
  const int len = strlen(name);
  if (*item != NULL)
    return 0;
  if (strncmp(line, name, len) != 0)
    return 0;
  *item = fixspaces(strdup(line + len));
  return 1;
}


x86 assembly (clang, -O0):
<add_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     117a <add_item+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <add_item+0x88>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11a0 <add_item+0x60>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <add_item+0x88>
mov    -0x10(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
call   1050 <strdup@plt>
mov    %eax,%edi
call   1060 <fixspaces@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_item>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
call   1040 <strlen@plt>
xor    %ebp,%ebp
cmpq   $0x0,(%r14)
jne    1193 <add_item+0x53>
mov    %eax,%r12d
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1193 <add_item+0x53>
movslq %r12d,%rax
add    %rax,%r15
mov    %r15,%rdi
call   1050 <strdup@plt>
mov    %eax,%edi
call   1060 <fixspaces@plt>
mov    %rax,(%r14)
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @add_item(i8* %0, i8* %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8** %2, i8*** %7
%9 = load i8*, i8** %6
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %8
%11 = load i8**, i8*** %7
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 0, i32* %4
br label %30
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = load i8*, i8** %6
%18 = load i32, i32* %8
%19 = call i64 @strncmp(i8* %16, i8* %17, i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %15
store i32 0, i32* %4
br label %30
22: ; preds = %15
%23 = load i8*, i8** %5
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = call i32 @strdup(i8* %26)
%28 = call i8* @fixspaces(i32 %27)
%29 = load i8**, i8*** %7
store i8* %28, i8** %29
store i32 1, i32* %4
br label %30
30: ; preds = %22, %21, %14
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
define i32 @add_item(i8* %0, i8* %1, i8** nocapture %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %15
7: ; preds = %3
%8 = tail call i64 @strncmp(i8* %0, i8* %1, i32 %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = sext i32 %4 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = tail call i32 @strdup(i8* %12)
%14 = tail call i8* @fixspaces(i32 %13)
store i8* %14, i8** %2
br label %15
15: ; preds = %7, %3, %10
%16 = phi i32 [ 1, %10 ], [ 0, %3 ], [ 0, %7 ]
ret i32 %16
}