#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*/ exit(int);
char **malloc(int);
char *strdup(char const *);
char **arg_setup(const char *name, unsigned int size) {
  char **args = NULL;
  args = malloc(sizeof(char *) * (size + 3));
  if (!args)
    exit(1);
  args[0] = strdup("testing");
  if (!args[0])
    exit(1);
  args[1] = strdup(name);
  if (!args[1])
    exit(1);
  return args;
}


x86 assembly (clang, -O0):
<arg_setup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x3,%eax
mov    %eax,%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1173 <arg_setup+0x43>
mov    $0x1,%edi
call   1040 <exit@plt>
lea    0xe86(%rip),%rdi
call   1050 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11a1 <arg_setup+0x71>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    11ce <arg_setup+0x9e>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arg_setup>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0x18(,%rsi,8),%edi
call   1030 <malloc@plt>
test   %rax,%rax
je     117b <arg_setup+0x4b>
mov    %rax,%rbx
lea    0xeae(%rip),%rdi
call   1050 <strdup@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     117b <arg_setup+0x4b>
mov    %r14,%rdi
call   1050 <strdup@plt>
mov    %rax,0x8(%rbx)
test   %rax,%rax
je     117b <arg_setup+0x4b>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"testing\00"
define i8** @arg_setup(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8**
store i8* %0, i8** %3
store i32 %1, i32* %4
store i8** null, i8*** %5
%6 = load i32, i32* %4
%7 = add i32 %6, 3
%8 = zext i32 %7 to i64
%9 = mul i64 8, %8
%10 = trunc i64 %9 to i32
%11 = call i8** @malloc(i32 %10)
store i8** %11, i8*** %5
%12 = load i8**, i8*** %5
%13 = icmp ne i8** %12, null
br i1 %13, label %16, label %14
14: ; preds = %2
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = call i8* @strdup(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
store i8* %17, i8** %19
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = icmp ne i8* %22, null
br i1 %23, label %26, label %24
24: ; preds = %16
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %16
%27 = load i8*, i8** %3
%28 = call i8* @strdup(i8* %27)
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
store i8* %28, i8** %30
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = icmp ne i8* %33, null
br i1 %34, label %37, label %35
35: ; preds = %26
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %26
%38 = load i8**, i8*** %5
ret i8** %38
}

LLVM IR (-O2):
@.str = [8 x i8] c"testing\00"
define noalias i8** @arg_setup(i8* nocapture %0, i32 %1) {
%3 = shl i32 %1, 3
%4 = add i32 %3, 24
%5 = tail call i8** @malloc(i32 %4)
%6 = icmp eq i8** %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = tail call dereferenceable_or_null(8) i8* @strdup(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %5
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %9
%15 = tail call i8* @strdup(i8* %0)
%16 = getelementptr inbounds i8*, i8** %5, i64 1
store i8* %15, i8** %16
%17 = icmp eq i8* %15, null
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %14
ret i8** %5
}