#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int we_wordc;
  int we_offs;
  char **we_wordv;
};
typedef TYPE_1__ wordexp_t;

/* Variables and functions */
int WRDE_NOSPACE;
char **realloc(char **, int);
char *strdup(char *);
int w_addword(wordexp_t *pwordexp, char *word) {
  size_t num_p;
  char **new_wordv;
  if (word == NULL) {
    word = strdup("");
    if (word == NULL)
      goto no_space;
  }
  num_p = 2 + pwordexp->we_wordc + pwordexp->we_offs;
  new_wordv = realloc(pwordexp->we_wordv, sizeof(char *) * num_p);
  if (new_wordv != NULL) {
    pwordexp->we_wordv = new_wordv;
    pwordexp->we_wordv[pwordexp->we_offs + pwordexp->we_wordc++] = word;
    pwordexp->we_wordv[pwordexp->we_offs + pwordexp->we_wordc] = NULL;
    return 0;
  }
no_space:
  return WRDE_NOSPACE;
}


x86 assembly (clang, -O0):
<w_addword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1160 <w_addword+0x40>
lea    0xebe(%rip),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    115b <w_addword+0x3b>
jmp    1205 <w_addword+0xe5>
jmp    1160 <w_addword+0x40>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
add    $0x2,%eax
mov    -0x10(%rbp),%rcx
add    0x4(%rcx),%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x20(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1030 <realloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1200 <w_addword+0xe0>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x10(%rbp),%rcx
mov    0x4(%rcx),%ecx
mov    -0x10(%rbp),%rdi
mov    (%rdi),%esi
mov    %esi,%r8d
add    $0x1,%r8d
mov    %r8d,(%rdi)
add    %esi,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x10(%rbp),%rcx
mov    0x4(%rcx),%ecx
mov    -0x10(%rbp),%rdx
add    (%rdx),%ecx
movslq %ecx,%rcx
movq   $0x0,(%rax,%rcx,8)
movl   $0x0,-0x4(%rbp)
jmp    1211 <w_addword+0xf1>
jmp    1205 <w_addword+0xe5>
mov    0x2ddc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<w_addword>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rsi,%rsi
jne    1143 <w_addword+0x23>
lea    0xeca(%rip),%rdi
call   1040 <strdup@plt>
mov    %rax,%r14
test   %rax,%rax
je     118d <w_addword+0x6d>
mov    (%rbx),%eax
add    0x4(%rbx),%eax
mov    0x8(%rbx),%rdi
lea    0x10(,%rax,8),%esi
call   1030 <realloc@plt>
test   %rax,%rax
je     118d <w_addword+0x6d>
mov    %rax,0x8(%rbx)
mov    (%rbx),%ecx
mov    0x4(%rbx),%edx
lea    0x1(%rcx),%esi
mov    %esi,(%rbx)
lea    (%rcx,%rdx,1),%esi
movslq %esi,%rsi
mov    %r14,(%rax,%rsi,8)
mov    0x8(%rbx),%rax
add    %edx,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movq   $0x0,(%rax,%rcx,8)
xor    %eax,%eax
jmp    1196 <w_addword+0x76>
mov    0x2e54(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32, i8** }
@.str = [1 x i8] zeroinitializer
@WRDE_NOSPACE = global i32 0
define i32 @w_addword(%struct.TYPE_3__* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_3__*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8**
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %10
br label %66
15: ; preds = %10
br label %16
16: ; preds = %15, %2
%17 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = add nsw i32 2, %19
%21 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %21, i32 0, i32 1
%23 = load i32, i32* %22
%24 = add nsw i32 %20, %23
%25 = sext i32 %24 to i64
store i64 %25, i64* %6
%26 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %26, i32 0, i32 2
%28 = load i8**, i8*** %27
%29 = load i64, i64* %6
%30 = mul i64 8, %29
%31 = trunc i64 %30 to i32
%32 = call i8** @realloc(i8** %28, i32 %31)
store i8** %32, i8*** %7
%33 = load i8**, i8*** %7
%34 = icmp ne i8** %33, null
br i1 %34, label %35, label %65
35: ; preds = %16
%36 = load i8**, i8*** %7
%37 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%38 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %37, i32 0, i32 2
store i8** %36, i8*** %38
%39 = load i8*, i8** %5
%40 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%41 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %40, i32 0, i32 2
%42 = load i8**, i8*** %41
%43 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%44 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %43, i32 0, i32 1
%45 = load i32, i32* %44
%46 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%47 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %46, i32 0, i32 0
%48 = load i32, i32* %47
%49 = add nsw i32 %48, 1
store i32 %49, i32* %47
%50 = add nsw i32 %45, %48
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %42, i64 %51
store i8* %39, i8** %52
%53 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%54 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %53, i32 0, i32 2
%55 = load i8**, i8*** %54
%56 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%57 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %56, i32 0, i32 1
%58 = load i32, i32* %57
%59 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%60 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %59, i32 0, i32 0
%61 = load i32, i32* %60
%62 = add nsw i32 %58, %61
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %55, i64 %63
store i8* null, i8** %64
store i32 0, i32* %3
br label %68
65: ; preds = %16
br label %66
66: ; preds = %65, %14
%67 = load i32, i32* @WRDE_NOSPACE
store i32 %67, i32* %3
br label %68
68: ; preds = %66, %35
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32, i8** }
@.str = [1 x i8] zeroinitializer
@WRDE_NOSPACE = global i32 0
define i32 @w_addword(%struct.TYPE_3__* nocapture %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %31, label %7
7: ; preds = %4, %2
%8 = phi i8* [ %5, %4 ], [ %1, %2 ]
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 2
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%13 = load i32, i32* %12
%14 = add nsw i32 %11, %13
%15 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 2
%16 = load i8**, i8*** %15
%17 = shl i32 %14, 3
%18 = tail call i8** @realloc(i8** %16, i32 %17)
%19 = icmp eq i8** %18, null
br i1 %19, label %31, label %20
20: ; preds = %7
store i8** %18, i8*** %15
%21 = load i32, i32* %12
%22 = load i32, i32* %9
%23 = add nsw i32 %22, 1
store i32 %23, i32* %9
%24 = add nsw i32 %22, %21
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %18, i64 %25
store i8* %8, i8** %26
%27 = load i8**, i8*** %15
%28 = add nsw i32 %23, %21
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
store i8* null, i8** %30
br label %33
31: ; preds = %7, %4
%32 = load i32, i32* @WRDE_NOSPACE
br label %33
33: ; preds = %31, %20
%34 = phi i32 [ %32, %31 ], [ 0, %20 ]
ret i32 %34
}