#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 /*<<< orphan*/ sprintf(char *, char *, char, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *puesEso(char *buf, char *buf2) {
  int i;
  strcpy(buf2, "");
  for (i = 0; i < strlen(buf); i++) {
    if (buf[i] == '\\')
      sprintf(buf2 + strlen(buf2), "%c%c", buf[i], buf[i]);
    else if (buf[i] == '\"')
      sprintf(buf2 + strlen(buf2), "\\%c", buf[i]);
    else
      sprintf(buf2 + strlen(buf2), "%c", buf[i]);
  }
  return (buf2);
}


x86 assembly (clang, -O0):
<puesEso>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xebd(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    1269 <puesEso+0x139>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    11cf <puesEso+0x9f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
cltq
add    %rax,%rdi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
lea    0xe40(%rip),%rsi
movsbl %al,%edx
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    1256 <puesEso+0x126>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
jne    121d <puesEso+0xed>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
cltq
add    %rax,%rdi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
lea    0xdf8(%rip),%rsi
movsbl (%rax,%rcx,1),%edx
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    1251 <puesEso+0x121>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
cltq
add    %rax,%rdi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
lea    0xdc0(%rip),%rsi
movsbl (%rax,%rcx,1),%edx
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    1256 <puesEso+0x126>
jmp    125b <puesEso+0x12b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1157 <puesEso+0x27>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<puesEso>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r13
lea    0xec2(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11ed <puesEso+0xbd>
lea    0xea0(%rip),%r15
lea    0xe94(%rip),%r12
xor    %ebx,%ebx
jmp    119a <puesEso+0x6a>
call   1040 <strlen@plt>
cltq
movzbl 0x0(%r13,%rbx,1),%ecx
mov    %cl,(%r14,%rax,1)
movb   $0x0,0x1(%r14,%rax,1)
add    $0x1,%rbx
mov    %r13,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11ed <puesEso+0xbd>
movzbl 0x0(%r13,%rbx,1),%eax
mov    %r14,%rdi
cmp    $0x22,%al
je     11d0 <puesEso+0xa0>
cmp    $0x5c,%al
jne    1170 <puesEso+0x40>
call   1040 <strlen@plt>
movslq %eax,%rdi
add    %r14,%rdi
movsbl 0x0(%r13,%rbx,1),%ecx
mov    %r12,%rsi
mov    %ecx,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    1187 <puesEso+0x57>
nopw   0x0(%rax,%rax,1)
call   1040 <strlen@plt>
movslq %eax,%rdi
add    %r14,%rdi
movsbl 0x0(%r13,%rbx,1),%edx
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    1187 <puesEso+0x57>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"%c%c\00"
@.str.2 = [4 x i8] c"\\%c\00"
define i8* @puesEso(i8* %0, i8* returned %1) {
%3 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %34
6: ; preds = %2, %29
%7 = phi i64 [ %30, %29 ], [ 0, %2 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
switch i8 %9, label %23 [
i8 92, label %10
i8 34, label %17
]
10: ; preds = %6
%11 = tail call i32 @strlen(i8* %1)
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = load i8, i8* %8
%15 = sext i8 %14 to i32
%16 = tail call i32 (i8*, i8*, i8, ...) @sprintf(i8* dereferenceable(1) %13, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8 signext %14, i32 %15)
br label %29
17: ; preds = %6
%18 = tail call i32 @strlen(i8* %1)
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %1, i64 %19
%21 = load i8, i8* %8
%22 = tail call i32 (i8*, i8*, i8, ...) @sprintf(i8* dereferenceable(1) %20, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8 signext %21)
br label %29
23: ; preds = %6
%24 = tail call i32 @strlen(i8* %1)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %1, i64 %25
%27 = load i8, i8* %8
store i8 %27, i8* %26
%28 = getelementptr i8, i8* %26, i64 1
store i8 0, i8* %28
br label %29
29: ; preds = %10, %23, %17
%30 = add nuw nsw i64 %7, 1
%31 = tail call i32 @strlen(i8* %0)
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %6, label %34
34: ; preds = %29, %2
ret i8* %1
}