#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 */
scalar_t__ realloc(char **, int);
scalar_t__ strdup(char const *);
void oauth_add_param_to_array(int *argcp, char ***argvp, const char *addparam) {
  (*argvp) = (char **)realloc(*argvp, sizeof(char *) * ((*argcp) + 1));
  (*argvp)[(*argcp)++] = (char *)strdup(addparam);
}


x86 assembly (clang, -O0):
<oauth_add_param_to_array>:
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),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%esi
call   1030 <realloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rsi
mov    (%rsi),%ecx
mov    %ecx,%edi
add    $0x1,%edi
mov    %edi,(%rsi)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oauth_add_param_to_array>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    (%rsi),%rdi
mov    (%r15),%eax
lea    0x8(,%rax,8),%esi
call   1030 <realloc@plt>
mov    %rax,(%rbx)
mov    %r14,%rdi
call   1040 <strdup@plt>
mov    (%rbx),%rcx
movslq (%r15),%rdx
lea    0x1(%rdx),%esi
mov    %esi,(%r15)
mov    %rax,(%rcx,%rdx,8)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @oauth_add_param_to_array(i32* %0, i8*** %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8***
%6 = alloca i8*
store i32* %0, i32** %4
store i8*** %1, i8**** %5
store i8* %2, i8** %6
%7 = load i8***, i8**** %5
%8 = load i8**, i8*** %7
%9 = load i32*, i32** %4
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = mul i64 8, %12
%14 = trunc i64 %13 to i32
%15 = call i64 @realloc(i8** %8, i32 %14)
%16 = inttoptr i64 %15 to i8**
%17 = load i8***, i8**** %5
store i8** %16, i8*** %17
%18 = load i8*, i8** %6
%19 = call i64 @strdup(i8* %18)
%20 = inttoptr i64 %19 to i8*
%21 = load i8***, i8**** %5
%22 = load i8**, i8*** %21
%23 = load i32*, i32** %4
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 1
store i32 %25, i32* %23
%26 = sext i32 %24 to i64
%27 = getelementptr inbounds i8*, i8** %22, i64 %26
store i8* %20, i8** %27
ret void
}

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