#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 strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
char *quote(const char *val) {
  static char buf[1024];
  int len = strlen(val);
  buf[0] = '"';
  strncpy(buf + 1, val, 1000);
  buf[len + 1] = '"';
  buf[len + 2] = '\0';
  return buf;
}


x86 assembly (clang, -O0):
<quote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
movb   $0x22,0x2f01(%rip)
mov    -0x8(%rbp),%rsi
lea    0x2ef6(%rip),%rdi
add    $0x1,%rdi
mov    $0x3e8,%edx
call   1030 <strncpy@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2ed8(%rip),%rax
movb   $0x22,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x2,%eax
movslq %eax,%rcx
lea    0x2ec4(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2eb9(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quote>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%ebp
movb   $0x22,0x2f0b(%rip)
lea    0x2f04(%rip),%r14
lea    0x2efe(%rip),%rdi
mov    %rbx,%rsi
mov    $0x3e8,%edx
call   1030 <strncpy@plt>
movslq %ebp,%rax
movw   $0x22,0x1(%rax,%r14,1)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@quote.buf = internal global [1024 x i8] zeroinitializer
define i8* @quote(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
store i32 %5, i32* %3
store i8 34, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @quote.buf, i64 0, i64 0)
%6 = load i8*, i8** %2
%7 = call i32 @strncpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @quote.buf, i64 0, i64 1), i8* %6, i32 1000)
%8 = load i32, i32* %3
%9 = add nsw i32 %8, 1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* @quote.buf, i64 0, i64 %10
store i8 34, i8* %11
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* @quote.buf, i64 0, i64 %14
store i8 0, i8* %15
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @quote.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@quote.buf = internal global [1024 x i8] zeroinitializer
define i8* @quote(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
store i8 34, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @quote.buf, i64 0, i64 0)
%3 = tail call i32 @strncpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @quote.buf, i64 0, i64 1), i8* %0, i32 1000)
%4 = add nsw i32 %2, 1
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* @quote.buf, i64 0, i64 %5
store i8 34, i8* %6
%7 = add nsw i32 %2, 2
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* @quote.buf, i64 0, i64 %8
store i8 0, i8* %9
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @quote.buf, i64 0, i64 0)
}