#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 prepend_args(char const *, char *, char **);
int strlen(char const *);
char *xmalloc(int);
void prepend_default_options(char const *options, int *pargc, char ***pargv) {
  if (options) {
    char *buf = xmalloc(strlen(options) + 1);
    int prepended = prepend_args(options, buf, (char **)0);
    int argc = *pargc;
    char *const *argv = *pargv;
    char **pp = (char **)xmalloc((prepended + argc + 1) * sizeof *pp);
    *pargc = prepended + argc;
    *pargv = pp;
    *pp++ = *argv++;
    pp += prepend_args(options, buf, pp);
    while ((*pp++ = *argv++))
      continue;
  }
}


x86 assembly (clang, -O0):
<prepend_default_options>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1240 <prepend_default_options+0x110>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   1040 <xmalloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <prepend_args@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <xmalloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%ecx
add    -0x28(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x30(%rbp)
mov    (%rax),%rcx
mov    -0x38(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x38(%rbp)
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1050 <prepend_args@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x30(%rbp)
mov    (%rax),%rax
mov    -0x38(%rbp),%rcx
mov    %rcx,%rdx
add    $0x8,%rdx
mov    %rdx,-0x38(%rbp)
mov    %rax,(%rcx)
cmp    $0x0,%rax
je     123b <prepend_default_options+0x10b>
jmp    1208 <prepend_default_options+0xd8>
jmp    1240 <prepend_default_options+0x110>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prepend_default_options>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11d1 <prepend_default_options+0xa1>
mov    %rdx,%r15
mov    %rdi,%r13
mov    %rsi,%r12
call   1030 <strlen@plt>
lea    0x1(%rax),%edi
call   1040 <xmalloc@plt>
mov    %rax,(%rsp)
mov    %r13,%rdi
mov    %rax,%rsi
xor    %edx,%edx
call   1050 <prepend_args@plt>
mov    %eax,%ebx
mov    (%r15),%r14
add    (%r12),%ebx
lea    0x8(,%rbx,8),%edi
call   1040 <xmalloc@plt>
mov    %rax,%rbp
mov    %ebx,(%r12)
mov    %rax,(%r15)
mov    (%r14),%rax
lea    0x8(%rbp),%rdx
mov    %rax,0x0(%rbp)
mov    %r13,%rdi
mov    (%rsp),%rsi
call   1050 <prepend_args@plt>
cltq
lea    0x0(,%rax,8),%rax
add    %rbp,%rax
mov    $0x8,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14,%rcx,1),%rdx
mov    %rdx,(%rax,%rcx,1)
add    $0x8,%rcx
test   %rdx,%rdx
jne    11c0 <prepend_default_options+0x90>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @prepend_default_options(i8* %0, i32* %1, i8*** %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8***
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i8**
store i8* %0, i8** %4
store i32* %1, i32** %5
store i8*** %2, i8**** %6
%12 = load i8*, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %62
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = call i32 @strlen(i8* %15)
%17 = add nsw i32 %16, 1
%18 = call i8* @xmalloc(i32 %17)
store i8* %18, i8** %7
%19 = load i8*, i8** %4
%20 = load i8*, i8** %7
%21 = call i32 @prepend_args(i8* %19, i8* %20, i8** null)
store i32 %21, i32* %8
%22 = load i32*, i32** %5
%23 = load i32, i32* %22
store i32 %23, i32* %9
%24 = load i8***, i8**** %6
%25 = load i8**, i8*** %24
store i8** %25, i8*** %10
%26 = load i32, i32* %8
%27 = load i32, i32* %9
%28 = add nsw i32 %26, %27
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = mul i64 %30, 8
%32 = trunc i64 %31 to i32
%33 = call i8* @xmalloc(i32 %32)
%34 = bitcast i8* %33 to i8**
store i8** %34, i8*** %11
%35 = load i32, i32* %8
%36 = load i32, i32* %9
%37 = add nsw i32 %35, %36
%38 = load i32*, i32** %5
store i32 %37, i32* %38
%39 = load i8**, i8*** %11
%40 = load i8***, i8**** %6
store i8** %39, i8*** %40
%41 = load i8**, i8*** %10
%42 = getelementptr inbounds i8*, i8** %41, i32 1
store i8** %42, i8*** %10
%43 = load i8*, i8** %41
%44 = load i8**, i8*** %11
%45 = getelementptr inbounds i8*, i8** %44, i32 1
store i8** %45, i8*** %11
store i8* %43, i8** %44
%46 = load i8*, i8** %4
%47 = load i8*, i8** %7
%48 = load i8**, i8*** %11
%49 = call i32 @prepend_args(i8* %46, i8* %47, i8** %48)
%50 = load i8**, i8*** %11
%51 = sext i32 %49 to i64
%52 = getelementptr inbounds i8*, i8** %50, i64 %51
store i8** %52, i8*** %11
br label %53
53: ; preds = %60, %14
%54 = load i8**, i8*** %10
%55 = getelementptr inbounds i8*, i8** %54, i32 1
store i8** %55, i8*** %10
%56 = load i8*, i8** %54
%57 = load i8**, i8*** %11
%58 = getelementptr inbounds i8*, i8** %57, i32 1
store i8** %58, i8*** %11
store i8* %56, i8** %57
%59 = icmp ne i8* %56, null
br i1 %59, label %60, label %61
60: ; preds = %53
br label %53
61: ; preds = %53
br label %62
62: ; preds = %61, %3
ret void
}

LLVM IR (-O2):
define void @prepend_default_options(i8* %0, i32* nocapture %1, i8*** nocapture %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %31, label %5
5: ; preds = %3
%6 = tail call i32 @strlen(i8* %0)
%7 = add nsw i32 %6, 1
%8 = tail call i8* @xmalloc(i32 %7)
%9 = tail call i32 @prepend_args(i8* %0, i8* %8, i8** null)
%10 = load i32, i32* %1
%11 = load i8**, i8*** %2
%12 = add nsw i32 %10, %9
%13 = shl i32 %12, 3
%14 = add i32 %13, 8
%15 = tail call i8* @xmalloc(i32 %14)
%16 = bitcast i8* %15 to i8**
store i32 %12, i32* %1
%17 = bitcast i8*** %2 to i8**
store i8* %15, i8** %17
%18 = load i8*, i8** %11
%19 = getelementptr inbounds i8, i8* %15, i64 8
%20 = bitcast i8* %19 to i8**
store i8* %18, i8** %16
%21 = tail call i32 @prepend_args(i8* %0, i8* %8, i8** %20)
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
br label %24
24: ; preds = %24, %5
%25 = phi i8** [ %11, %5 ], [ %27, %24 ]
%26 = phi i8** [ %23, %5 ], [ %29, %24 ]
%27 = getelementptr inbounds i8*, i8** %25, i64 1
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8*, i8** %26, i64 1
store i8* %28, i8** %26
%30 = icmp eq i8* %28, null
br i1 %30, label %31, label %24
31: ; preds = %24, %3
ret void
}