#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);
char **add_token(char **tokens, unsigned int *tokens_num,
                 const char **exp_string) {
  (*tokens_num)++;
  tokens = (char **)ec_realloc(tokens, sizeof(char *) * *tokens_num);
  tokens[*tokens_num - 1] = ec_malloc(sizeof(char) * 2);
  tokens[*tokens_num - 1][0] = *exp_string[0];
  tokens[*tokens_num - 1][1] = '\0';
  (*exp_string)++;
  return tokens;
}


x86 assembly (clang, -O0):
<add_token>:
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   1040 <ec_realloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x2,%edi
call   1030 <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    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rdx
mov    (%rdx),%edx
sub    $0x1,%edx
mov    %edx,%edx
mov    (%rax,%rdx,8),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,8),%rax
movb   $0x0,0x1(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_token>:
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   1040 <ec_realloc@plt>
mov    %rax,%r15
mov    $0x2,%edi
call   1030 <ec_malloc@plt>
mov    (%rbx),%ecx
add    $0xffffffff,%ecx
mov    %rax,(%r15,%rcx,8)
mov    (%r14),%rcx
mov    (%rcx),%cl
mov    %cl,(%rax)
mov    (%rbx),%eax
add    $0xffffffff,%eax
mov    (%r15,%rax,8),%rax
movb   $0x0,0x1(%rax)
addq   $0x1,(%r14)
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8** @add_token(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 = call i8* @ec_malloc(i32 2)
%19 = load i8**, i8*** %4
%20 = load i32*, i32** %5
%21 = load i32, i32* %20
%22 = sub i32 %21, 1
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %19, i64 %23
store i8* %18, i8** %24
%25 = load i8**, i8*** %6
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = load i8, i8* %27
%29 = load i8**, i8*** %4
%30 = load i32*, i32** %5
%31 = load i32, i32* %30
%32 = sub i32 %31, 1
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %29, i64 %33
%35 = load i8*, i8** %34
%36 = getelementptr inbounds i8, i8* %35, i64 0
store i8 %28, i8* %36
%37 = load i8**, i8*** %4
%38 = load i32*, i32** %5
%39 = load i32, i32* %38
%40 = sub i32 %39, 1
%41 = zext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %37, i64 %41
%43 = load i8*, i8** %42
%44 = getelementptr inbounds i8, i8* %43, i64 1
store i8 0, i8* %44
%45 = load i8**, i8*** %6
%46 = load i8*, i8** %45
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %45
%48 = load i8**, i8*** %4
ret i8** %48
}

LLVM IR (-O2):
define i8** @add_token(i8** %0, i32* nocapture %1, i8** nocapture %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 i8* @ec_malloc(i32 2)
%10 = load i32, i32* %1
%11 = add i32 %10, -1
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds i8*, i8** %8, i64 %12
store i8* %9, i8** %13
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
store i8 %15, i8* %9
%16 = load i32, i32* %1
%17 = add i32 %16, -1
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %8, i64 %18
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8, i8* %20, i64 1
store i8 0, i8* %21
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 1
store i8* %23, i8** %2
ret i8** %8
}