#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 *ec_malloc(int);
scalar_t__ ec_realloc(char **, int);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
char **add_string(char **tokens, unsigned int *tokens_num, const char *string) {
  (*tokens_num)++;
  tokens = (char **)ec_realloc(tokens, sizeof(char *) * *tokens_num);
  tokens[*tokens_num - 1] = ec_malloc(sizeof(char) * (strlen(string) + 1));
  strcpy(tokens[*tokens_num - 1], string);
  return tokens;
}


x86 assembly (clang, -O0):
<add_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
shl    $0x3,%rax
mov    %eax,%esi
call   1060 <ec_realloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <ec_malloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_string>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    (%rsi),%eax
lea    0x1(%rax),%ecx
mov    %ecx,(%rsi)
lea    0x8(,%rax,8),%esi
call   1060 <ec_realloc@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1040 <ec_malloc@plt>
mov    (%rbx),%ecx
add    $0xffffffff,%ecx
mov    %rax,(%r15,%rcx,8)
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8** @add_string(i8** %0, i32* %1, i8* %2) {
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i8*
store i8** %0, i8*** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%7 = load i32*, i32** %5
%8 = load i32, i32* %7
%9 = add i32 %8, 1
store i32 %9, i32* %7
%10 = load i8**, i8*** %4
%11 = load i32*, i32** %5
%12 = load i32, i32* %11
%13 = zext i32 %12 to i64
%14 = mul i64 8, %13
%15 = trunc i64 %14 to i32
%16 = call i64 @ec_realloc(i8** %10, i32 %15)
%17 = inttoptr i64 %16 to i8**
store i8** %17, i8*** %4
%18 = load i8*, i8** %6
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = mul i64 1, %21
%23 = trunc i64 %22 to i32
%24 = call i8* @ec_malloc(i32 %23)
%25 = load i8**, i8*** %4
%26 = load i32*, i32** %5
%27 = load i32, i32* %26
%28 = sub i32 %27, 1
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %25, i64 %29
store i8* %24, i8** %30
%31 = load i8**, i8*** %4
%32 = load i32*, i32** %5
%33 = load i32, i32* %32
%34 = sub i32 %33, 1
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %31, i64 %35
%37 = load i8*, i8** %36
%38 = load i8*, i8** %6
%39 = call i32 @strcpy(i8* %37, i8* %38)
%40 = load i8**, i8*** %4
ret i8** %40
}

LLVM IR (-O2):
define i8** @add_string(i8** %0, i32* nocapture %1, i8* %2) {
%4 = load i32, i32* %1
%5 = add i32 %4, 1
store i32 %5, i32* %1
%6 = shl i32 %5, 3
%7 = tail call i64 @ec_realloc(i8** %0, i32 %6)
%8 = inttoptr i64 %7 to i8**
%9 = tail call i32 @strlen(i8* %2)
%10 = add nsw i32 %9, 1
%11 = tail call i8* @ec_malloc(i32 %10)
%12 = load i32, i32* %1
%13 = add i32 %12, -1
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %8, i64 %14
store i8* %11, i8** %15
%16 = tail call i32 @strcpy(i8* %11, i8* %2)
ret i8** %8
}