#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 */
struct quoting_options {
  int dummy;
};

/* Variables and functions */
int errno;
int /*<<< orphan*/ quotearg_buffer(char *, size_t, char const *, size_t,
                                   struct quoting_options const *);
char *xmalloc(size_t);
char *quotearg_alloc(char const *arg, size_t argsize,
                     struct quoting_options const *o) {
  int e = errno;
  size_t bufsize = quotearg_buffer(0, 0, arg, argsize, o) + 1;
  char *buf = xmalloc(bufsize);
  quotearg_buffer(buf, bufsize, arg, argsize, o);
  errno = e;
  return buf;
}


x86 assembly (clang, -O0):
<quotearg_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
xor    %eax,%eax
mov    %eax,%esi
mov    %rsi,%rdi
call   1030 <quotearg_buffer@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <xmalloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   1030 <quotearg_buffer@plt>
mov    -0x1c(%rbp),%ecx
mov    0x2e4f(%rip),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quotearg_alloc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    0x2ea5(%rip),%rax
mov    (%rax),%ebp
xor    %edi,%edi
xor    %esi,%esi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <quotearg_buffer@plt>
add    $0x1,%eax
movslq %eax,%rbx
mov    %rbx,%rdi
call   1040 <xmalloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <quotearg_buffer@plt>
mov    0x2e65(%rip),%rax
mov    %ebp,(%rax)
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.quoting_options = type { i32 }
@errno = global i32 0
define i8* @quotearg_alloc(i8* %0, i64 %1, %struct.quoting_options* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca %struct.quoting_options*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i8*
store i8* %0, i8** %4
store i64 %1, i64* %5
store %struct.quoting_options* %2, %struct.quoting_options** %6
%10 = load i32, i32* @errno
store i32 %10, i32* %7
%11 = load i8*, i8** %4
%12 = load i64, i64* %5
%13 = load %struct.quoting_options*, %struct.quoting_options** %6
%14 = call i32 @quotearg_buffer(i8* null, i64 0, i8* %11, i64 %12, %struct.quoting_options* %13)
%15 = add nsw i32 %14, 1
%16 = sext i32 %15 to i64
store i64 %16, i64* %8
%17 = load i64, i64* %8
%18 = call i8* @xmalloc(i64 %17)
store i8* %18, i8** %9
%19 = load i8*, i8** %9
%20 = load i64, i64* %8
%21 = load i8*, i8** %4
%22 = load i64, i64* %5
%23 = load %struct.quoting_options*, %struct.quoting_options** %6
%24 = call i32 @quotearg_buffer(i8* %19, i64 %20, i8* %21, i64 %22, %struct.quoting_options* %23)
%25 = load i32, i32* %7
store i32 %25, i32* @errno
%26 = load i8*, i8** %9
ret i8* %26
}

LLVM IR (-O2):
%struct.quoting_options = type { i32 }
@errno = global i32 0
define i8* @quotearg_alloc(i8* %0, i64 %1, %struct.quoting_options* %2) {
%4 = load i32, i32* @errno
%5 = tail call i32 @quotearg_buffer(i8* null, i64 0, i8* %0, i64 %1, %struct.quoting_options* %2)
%6 = add nsw i32 %5, 1
%7 = sext i32 %6 to i64
%8 = tail call i8* @xmalloc(i64 %7)
%9 = tail call i32 @quotearg_buffer(i8* %8, i64 %7, i8* %0, i64 %1, %struct.quoting_options* %2)
store i32 %4, i32* @errno
ret i8* %8
}