#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 */
int /*<<< orphan*/ free(char **);
int /*<<< orphan*/ ft_memcpy(char **, char **, int);
size_t ft_tabstrlen(char **);
scalar_t__ malloc(int);
char **ft_tabstradd(char **tab, char *str) {
  char **newtab;
  size_t size_tab;
  size_tab = (tab) ? ft_tabstrlen(tab) : 0;
  if (tab) {
    newtab = (char **)malloc(sizeof(char *) * (size_tab + 2));
    ft_memcpy(newtab, tab, sizeof(char *) * size_tab);
  } else
    newtab = (char **)malloc(sizeof(char *) * 2);
  newtab[size_tab] = str;
  newtab[size_tab + 1] = 0;
  free(tab);
  return (newtab);
}


x86 assembly (clang, -O0):
<ft_tabstradd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     116d <ft_tabstradd+0x2d>
mov    -0x8(%rbp),%rdi
call   1060 <ft_tabstrlen@plt>
mov    %rax,-0x28(%rbp)
jmp    1178 <ft_tabstradd+0x38>
xor    %eax,%eax
mov    %rax,-0x28(%rbp)
jmp    1178 <ft_tabstradd+0x38>
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11be <ft_tabstradd+0x7e>
mov    -0x20(%rbp),%rax
add    $0x2,%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1050 <ft_memcpy@plt>
jmp    11cc <ft_tabstradd+0x8c>
mov    $0x10,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movq   $0x0,0x8(%rax,%rcx,8)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_tabstradd>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
test   %rdi,%rdi
je     1183 <ft_tabstradd+0x43>
mov    %r15,%rdi
call   1060 <ft_tabstrlen@plt>
mov    %rax,%r12
lea    0x0(,%rax,8),%ebp
lea    0x10(,%rax,8),%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <ft_memcpy@plt>
jmp    1193 <ft_tabstradd+0x53>
mov    $0x10,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
xor    %r12d,%r12d
mov    %r14,(%rbx,%r12,8)
movq   $0x0,0x8(%rbx,%r12,8)
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8** @ft_tabstradd(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i64
store i8** %0, i8*** %3
store i8* %1, i8** %4
%7 = load i8**, i8*** %3
%8 = icmp ne i8** %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8**, i8*** %3
%11 = call i64 @ft_tabstrlen(i8** %10)
br label %13
12: ; preds = %2
br label %13
13: ; preds = %12, %9
%14 = phi i64 [ %11, %9 ], [ 0, %12 ]
store i64 %14, i64* %6
%15 = load i8**, i8*** %3
%16 = icmp ne i8** %15, null
br i1 %16, label %17, label %30
17: ; preds = %13
%18 = load i64, i64* %6
%19 = add i64 %18, 2
%20 = mul i64 8, %19
%21 = trunc i64 %20 to i32
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i8**
store i8** %23, i8*** %5
%24 = load i8**, i8*** %5
%25 = load i8**, i8*** %3
%26 = load i64, i64* %6
%27 = mul i64 8, %26
%28 = trunc i64 %27 to i32
%29 = call i32 @ft_memcpy(i8** %24, i8** %25, i32 %28)
br label %33
30: ; preds = %13
%31 = call i64 @malloc(i32 16)
%32 = inttoptr i64 %31 to i8**
store i8** %32, i8*** %5
br label %33
33: ; preds = %30, %17
%34 = load i8*, i8** %4
%35 = load i8**, i8*** %5
%36 = load i64, i64* %6
%37 = getelementptr inbounds i8*, i8** %35, i64 %36
store i8* %34, i8** %37
%38 = load i8**, i8*** %5
%39 = load i64, i64* %6
%40 = add i64 %39, 1
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
store i8* null, i8** %41
%42 = load i8**, i8*** %3
%43 = call i32 @free(i8** %42)
%44 = load i8**, i8*** %5
ret i8** %44
}

LLVM IR (-O2):
define i8** @ft_tabstradd(i8** %0, i8* %1) {
%3 = icmp eq i8** %0, null
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = tail call i64 @ft_tabstrlen(i8** %0)
%6 = trunc i64 %5 to i32
%7 = shl i32 %6, 3
%8 = add i32 %7, 16
%9 = tail call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i8**
%11 = tail call i32 @ft_memcpy(i8** %10, i8** %0, i32 %7)
br label %15
12: ; preds = %2
%13 = tail call i64 @malloc(i32 16)
%14 = inttoptr i64 %13 to i8**
br label %15
15: ; preds = %12, %4
%16 = phi i64 [ %5, %4 ], [ 0, %12 ]
%17 = phi i8** [ %10, %4 ], [ %14, %12 ]
%18 = getelementptr inbounds i8*, i8** %17, i64 %16
store i8* %1, i8** %18
%19 = add i64 %16, 1
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
store i8* null, i8** %20
%21 = tail call i32 @free(i8** %0)
ret i8** %17
}