#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*/ free(void *);
char *parse_escaped_characters(char *);
char *parson_strndup(char const *, int);
char *skip_string(char const *);
const char *get_string(const char **string) {
  char *quote_contents;
  const char *parsed_string;
  const char *after_closing_quote_ptr = skip_string(*string);
  if (!after_closing_quote_ptr) {
    return NULL;
  }
  quote_contents =
      parson_strndup(*string + 1, after_closing_quote_ptr - *string - 2);
  if (!quote_contents) {
    return NULL;
  }
  *string = after_closing_quote_ptr;
  parsed_string = parse_escaped_characters(quote_contents);
  free((void *)quote_contents);
  return (const char *)parsed_string;
}


x86 assembly (clang, -O0):
<get_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <skip_string@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1174 <get_string+0x34>
movq   $0x0,-0x8(%rbp)
jmp    11dd <get_string+0x9d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
add    $0x1,%rdi
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
sub    $0x2,%rax
mov    %eax,%esi
call   1040 <parson_strndup@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b4 <get_string+0x74>
movq   $0x0,-0x8(%rbp)
jmp    11dd <get_string+0x9d>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdi
call   1060 <parse_escaped_characters@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_string>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    (%rdi),%rdi
call   1050 <skip_string@plt>
test   %rax,%rax
je     118e <get_string+0x4e>
mov    %rax,%rbx
mov    (%r14),%rax
lea    0x1(%rax),%rdi
mov    %ebx,%esi
sub    %eax,%esi
add    $0xfffffffe,%esi
call   1040 <parson_strndup@plt>
test   %rax,%rax
je     118e <get_string+0x4e>
mov    %rax,%r15
mov    %rbx,(%r14)
mov    %rax,%rdi
call   1060 <parse_escaped_characters@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
jmp    1190 <get_string+0x50>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @get_string(i8** %0) {
%2 = alloca i8*
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8** %0, i8*** %3
%7 = load i8**, i8*** %3
%8 = load i8*, i8** %7
%9 = call i8* @skip_string(i8* %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %1
store i8* null, i8** %2
br label %37
13: ; preds = %1
%14 = load i8**, i8*** %3
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8*, i8** %6
%18 = load i8**, i8*** %3
%19 = load i8*, i8** %18
%20 = ptrtoint i8* %17 to i64
%21 = ptrtoint i8* %19 to i64
%22 = sub i64 %20, %21
%23 = sub nsw i64 %22, 2
%24 = trunc i64 %23 to i32
%25 = call i8* @parson_strndup(i8* %16, i32 %24)
store i8* %25, i8** %4
%26 = load i8*, i8** %4
%27 = icmp ne i8* %26, null
br i1 %27, label %29, label %28
28: ; preds = %13
store i8* null, i8** %2
br label %37
29: ; preds = %13
%30 = load i8*, i8** %6
%31 = load i8**, i8*** %3
store i8* %30, i8** %31
%32 = load i8*, i8** %4
%33 = call i8* @parse_escaped_characters(i8* %32)
store i8* %33, i8** %5
%34 = load i8*, i8** %4
%35 = call i32 @free(i8* %34)
%36 = load i8*, i8** %5
store i8* %36, i8** %2
br label %37
37: ; preds = %29, %28, %12
%38 = load i8*, i8** %2
ret i8* %38
}

LLVM IR (-O2):
define i8* @get_string(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = tail call i8* @skip_string(i8* %2)
%4 = icmp eq i8* %3, null
br i1 %4, label %18, label %5
5: ; preds = %1
%6 = load i8*, i8** %0
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = ptrtoint i8* %3 to i64
%9 = ptrtoint i8* %6 to i64
%10 = sub i64 %8, %9
%11 = trunc i64 %10 to i32
%12 = add i32 %11, -2
%13 = tail call i8* @parson_strndup(i8* %7, i32 %12)
%14 = icmp eq i8* %13, null
br i1 %14, label %18, label %15
15: ; preds = %5
store i8* %3, i8** %0
%16 = tail call i8* @parse_escaped_characters(i8* %13)
%17 = tail call i32 @free(i8* %13)
br label %18
18: ; preds = %5, %1, %15
%19 = phi i8* [ %16, %15 ], [ null, %1 ], [ null, %5 ]
ret i8* %19
}