#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*/ printf(char *, char *);
char *print_json_string(char *j) {
  char buf[1024];
  int i = 0;
  while (*j != '"') {
    if (*j == '\\')
      j++;
    buf[i] = *j;
    i++;
    j++;
  }
  buf[i] = '\0';
  printf("%s", buf);
  j++;
  return j;
}


x86 assembly (clang, -O0):
<print_json_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x414(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     1189 <print_json_string+0x79>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1155 <print_json_string+0x45>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
movslq -0x414(%rbp),%rax
mov    %cl,-0x410(%rbp,%rax,1)
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1129 <print_json_string+0x19>
movslq -0x414(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rsi
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_json_string>:
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
jmp    1133 <print_json_string+0x23>
nop
movzbl 0x1(%rbx),%ecx
add    $0x1,%rbx
mov    %cl,(%rsp,%rax,1)
add    $0x1,%rax
add    $0x1,%rbx
movzbl (%rbx),%ecx
cmp    $0x5c,%cl
je     1120 <print_json_string+0x10>
cmp    $0x22,%cl
jne    1128 <print_json_string+0x18>
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xeb3(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
add    $0x1,%rbx
mov    %rbx,%rax
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i8* @print_json_string(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
br label %5
5: ; preds = %18, %1
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 34
br i1 %9, label %10, label %28
10: ; preds = %5
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 92
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %2
br label %18
18: ; preds = %15, %10
%19 = load i8*, i8** %2
%20 = load i8, i8* %19
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %22
store i8 %20, i8* %23
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
%26 = load i8*, i8** %2
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %2
br label %5
28: ; preds = %5
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %30
store i8 0, i8* %31
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %2
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %2
%36 = load i8*, i8** %2
ret i8* %36
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i8* @print_json_string(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %11, %1
%5 = phi i64 [ %15, %11 ], [ 0, %1 ]
%6 = phi i8* [ %16, %11 ], [ %0, %1 ]
%7 = load i8, i8* %6
switch i8 %7, label %11 [
i8 34, label %17
i8 92, label %8
]
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = load i8, i8* %9
br label %11
11: ; preds = %4, %8
%12 = phi i8 [ %10, %8 ], [ %7, %4 ]
%13 = phi i8* [ %9, %8 ], [ %6, %4 ]
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %5
store i8 %12, i8* %14
%15 = add nuw i64 %5, 1
%16 = getelementptr inbounds i8, i8* %13, i64 1
br label %4
17: ; preds = %4
%18 = and i64 %5, 4294967295
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %18
store i8 0, i8* %19
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%21 = getelementptr inbounds i8, i8* %6, i64 1
ret i8* %21
}