#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 argcv_quote_char(char const);
scalar_t__ isprint(char const);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned char);
void argcv_quote_copy(char *dst, const char *src) {
  for (; *src; src++) {
    if (*src == '"' || *src == '\'') {
      *dst++ = '\\';
      *dst++ = *src;
    } else if (*src != '\t' && *src != '\\' && isprint(*src))
      *dst++ = *src;
    else {
      int c = argcv_quote_char(*src);
      *dst++ = '\\';
      if (c != -1)
        *dst++ = c;
      else {
        char tmp[4];
        snprintf(tmp, sizeof tmp, "%03o", *(unsigned char *)src);
        memcpy(dst, tmp, 3);
        dst += 3;
      }
    }
  }
}


x86 assembly (clang, -O0):
<argcv_quote_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     129d <argcv_quote_copy+0x15d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     117d <argcv_quote_copy+0x3d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
jne    11ab <argcv_quote_copy+0x6b>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x5c,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    1287 <argcv_quote_copy+0x147>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
je     11fd <argcv_quote_copy+0xbd>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
je     11fd <argcv_quote_copy+0xbd>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isprint@plt>
cmp    $0x0,%rax
je     11fd <argcv_quote_copy+0xbd>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    1282 <argcv_quote_copy+0x142>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1050 <argcv_quote_char@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x5c,(%rax)
cmpl   $0xffffffff,-0x14(%rbp)
je     1243 <argcv_quote_copy+0x103>
mov    -0x14(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    127d <argcv_quote_copy+0x13d>
lea    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    $0x4,%esi
lea    0xda9(%rip),%rdx
movzbl (%rax),%ecx
call   1030 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x3,%edx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x8(%rbp)
jmp    1282 <argcv_quote_copy+0x142>
jmp    1287 <argcv_quote_copy+0x147>
jmp    128c <argcv_quote_copy+0x14c>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1150 <argcv_quote_copy+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<argcv_quote_copy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xf48(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe9c(%rip),%rbp
jmp    1182 <argcv_quote_copy+0x42>
cs nopw 0x0(%rax,%rax,1)
movb   $0x5c,(%rbx)
movzbl (%r14),%eax
mov    %al,0x1(%rbx)
add    $0x2,%rbx
add    $0x1,%r14
movzbl (%r14),%ecx
cmp    $0x27,%rcx
ja     11a0 <argcv_quote_copy+0x60>
movslq 0x0(%rbp,%rcx,4),%rax
add    %rbp,%rax
jmp    *%rax
cs nopw 0x0(%rax,%rax,1)
cmp    $0x5c,%cl
je     11d0 <argcv_quote_copy+0x90>
movsbl %cl,%edi
call   1060 <isprint@plt>
movzbl (%r14),%ecx
test   %rax,%rax
je     11d0 <argcv_quote_copy+0x90>
mov    %cl,(%rbx)
add    $0x1,%rbx
add    $0x1,%r14
jmp    1182 <argcv_quote_copy+0x42>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %cl,%edi
call   1050 <argcv_quote_char@plt>
movb   $0x5c,(%rbx)
cmp    $0xffffffff,%eax
je     11e5 <argcv_quote_copy+0xa5>
mov    %al,0x1(%rbx)
jmp    117a <argcv_quote_copy+0x3a>
lea    0x1(%rbx),%r13
movzbl (%r14),%ecx
mov    %r12,%rdi
mov    $0x4,%esi
mov    %r15,%rdx
call   1030 <snprintf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0x3,%edx
call   1040 <memcpy@plt>
add    $0x4,%rbx
add    $0x1,%r14
jmp    1182 <argcv_quote_copy+0x42>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%03o\00"
define void @argcv_quote_copy(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [4 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %7
7: ; preds = %74, %2
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %77
11: ; preds = %7
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 34
br i1 %15, label %21, label %16
16: ; preds = %11
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 39
br i1 %20, label %21, label %28
21: ; preds = %16, %11
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %3
store i8 92, i8* %22
%24 = load i8*, i8** %4
%25 = load i8, i8* %24
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %3
store i8 %25, i8* %26
br label %73
28: ; preds = %16
%29 = load i8*, i8** %4
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 9
br i1 %32, label %33, label %48
33: ; preds = %28
%34 = load i8*, i8** %4
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 92
br i1 %37, label %38, label %48
38: ; preds = %33
%39 = load i8*, i8** %4
%40 = load i8, i8* %39
%41 = call i64 @isprint(i8 signext %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %38
%44 = load i8*, i8** %4
%45 = load i8, i8* %44
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %3
store i8 %45, i8* %46
br label %72
48: ; preds = %38, %33, %28
%49 = load i8*, i8** %4
%50 = load i8, i8* %49
%51 = call i32 @argcv_quote_char(i8 signext %50)
store i32 %51, i32* %5
%52 = load i8*, i8** %3
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %3
store i8 92, i8* %52
%54 = load i32, i32* %5
%55 = icmp ne i32 %54, -1
br i1 %55, label %56, label %61
56: ; preds = %48
%57 = load i32, i32* %5
%58 = trunc i32 %57 to i8
%59 = load i8*, i8** %3
%60 = getelementptr inbounds i8, i8* %59, i32 1
store i8* %60, i8** %3
store i8 %58, i8* %59
br label %71
61: ; preds = %48
%62 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%63 = load i8*, i8** %4
%64 = load i8, i8* %63
%65 = call i32 @snprintf(i8* %62, i32 4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %64)
%66 = load i8*, i8** %3
%67 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%68 = call i32 @memcpy(i8* %66, i8* %67, i32 3)
%69 = load i8*, i8** %3
%70 = getelementptr inbounds i8, i8* %69, i64 3
store i8* %70, i8** %3
br label %71
71: ; preds = %61, %56
br label %72
72: ; preds = %71, %43
br label %73
73: ; preds = %72, %21
br label %74
74: ; preds = %73
%75 = load i8*, i8** %4
%76 = getelementptr inbounds i8, i8* %75, i32 1
store i8* %76, i8** %4
br label %7
77: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%03o\00"
define void @argcv_quote_copy(i8* %0, i8* nocapture %1) {
%3 = alloca [4 x i8]
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %32, %2
%6 = phi i8* [ %1, %2 ], [ %34, %32 ]
%7 = phi i8* [ %0, %2 ], [ %33, %32 ]
%8 = load i8, i8* %6
switch i8 %8, label %13 [
i8 0, label %35
i8 34, label %9
i8 39, label %9
i8 9, label %19
i8 92, label %19
]
9: ; preds = %5, %5
%10 = getelementptr inbounds i8, i8* %7, i64 1
store i8 92, i8* %7
%11 = load i8, i8* %6
%12 = getelementptr inbounds i8, i8* %7, i64 2
store i8 %11, i8* %10
br label %32
13: ; preds = %5
%14 = call i64 @isprint(i8 signext %8)
%15 = icmp eq i64 %14, 0
%16 = load i8, i8* %6
br i1 %15, label %19, label %17
17: ; preds = %13
%18 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %16, i8* %7
br label %32
19: ; preds = %13, %5, %5
%20 = phi i8 [ %8, %5 ], [ %8, %5 ], [ %16, %13 ]
%21 = call i32 @argcv_quote_char(i8 signext %20)
%22 = getelementptr inbounds i8, i8* %7, i64 1
store i8 92, i8* %7
%23 = icmp eq i32 %21, -1
br i1 %23, label %27, label %24
24: ; preds = %19
%25 = trunc i32 %21 to i8
%26 = getelementptr inbounds i8, i8* %7, i64 2
store i8 %25, i8* %22
br label %32
27: ; preds = %19
%28 = load i8, i8* %6
%29 = call i32 @snprintf(i8* %4, i32 4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %28)
%30 = call i32 @memcpy(i8* %22, i8* %4, i32 3)
%31 = getelementptr inbounds i8, i8* %7, i64 4
br label %32
32: ; preds = %24, %27, %9, %17
%33 = phi i8* [ %12, %9 ], [ %18, %17 ], [ %26, %24 ], [ %31, %27 ]
%34 = getelementptr inbounds i8, i8* %6, i64 1
br label %5
35: ; preds = %5
ret void
}