#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*/ strcspn(char *, char *);
char *x_strdup(char *);
int _cfg_read_string(char **buf, char **val) {
  char *ptr;
  if (**buf == '"') {
    ptr = ++(*buf);
    while (1) {
      *buf += strcspn(*buf, "\"");
      if (**buf != '"') {
        return -1;
      } else if (*(*buf - 1) == '\\') {
        (*buf)++;
        continue;
      } else {
        break;
      }
    }
  } else {
    ptr = *buf;
    *buf += strcspn(*buf, " \t\r\n");
  }
  *((*buf)++) = 0;
  *val = x_strdup(ptr);
  return 0;
}


x86 assembly (clang, -O0):
<_cfg_read_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    11ca <_cfg_read_string+0xaa>
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rax
add    $0x1,%rax
mov    %rax,(%rcx)
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe9d(%rip),%rsi
call   1030 <strcspn@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     1199 <_cfg_read_string+0x79>
movl   $0xffffffff,-0x4(%rbp)
jmp    1228 <_cfg_read_string+0x108>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl -0x1(%rax),%eax
cmp    $0x5c,%eax
jne    11c0 <_cfg_read_string+0xa0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    1155 <_cfg_read_string+0x35>
jmp    11c5 <_cfg_read_string+0xa5>
jmp    11fa <_cfg_read_string+0xda>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe1f(%rip),%rsi
call   1030 <strcspn@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
call   1040 <x_strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_cfg_read_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %rdi,%r15
mov    (%rdi),%r13
cmpb   $0x22,0x0(%r13)
jne    11ac <_cfg_read_string+0x8c>
lea    0x1(%r13),%r12
mov    %r12,(%r15)
lea    0xeb7(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcspn@plt>
cltq
lea    (%rax,%r13,1),%rbx
add    $0x1,%rbx
mov    %rbx,(%r15)
mov    $0xffffffff,%r14d
cmpb   $0x22,0x1(%r13,%rax,1)
jne    11e3 <_cfg_read_string+0xc3>
mov    %rbp,(%rsp)
lea    0xe89(%rip),%rbp
nopw   0x0(%rax,%rax,1)
cmpb   $0x5c,-0x1(%rbx)
jne    11c3 <_cfg_read_string+0xa3>
add    $0x1,%rbx
mov    %rbx,(%r15)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcspn@plt>
cltq
lea    (%rbx,%rax,1),%rcx
mov    %rcx,(%r15)
cmpb   $0x22,(%rbx,%rax,1)
mov    %rcx,%rbx
je     1180 <_cfg_read_string+0x60>
jmp    11e3 <_cfg_read_string+0xc3>
lea    0xe4f(%rip),%rsi
mov    %r13,%rdi
call   1030 <strcspn@plt>
movslq %eax,%rbx
add    %r13,%rbx
jmp    11ca <_cfg_read_string+0xaa>
mov    %r12,%r13
mov    (%rsp),%rbp
lea    0x1(%rbx),%rax
mov    %rax,(%r15)
movb   $0x0,(%rbx)
mov    %r13,%rdi
call   1040 <x_strdup@plt>
mov    %rax,0x0(%rbp)
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\22\00"
@.str.1 = [5 x i8] c" \09\0D\0A\00"
define i32 @_cfg_read_string(i8** %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8**
%6 = alloca i8*
store i8** %0, i8*** %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %4
%8 = load i8*, i8** %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 34
br i1 %11, label %12, label %43
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %13
store i8* %15, i8** %6
br label %16
16: ; preds = %12, %37
%17 = load i8**, i8*** %4
%18 = load i8*, i8** %17
%19 = call i32 @strcspn(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = load i8**, i8*** %4
%21 = load i8*, i8** %20
%22 = sext i32 %19 to i64
%23 = getelementptr inbounds i8, i8* %21, i64 %22
store i8* %23, i8** %20
%24 = load i8**, i8*** %4
%25 = load i8*, i8** %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 34
br i1 %28, label %29, label %30
29: ; preds = %16
store i32 -1, i32* %3
br label %60
30: ; preds = %16
%31 = load i8**, i8*** %4
%32 = load i8*, i8** %31
%33 = getelementptr inbounds i8, i8* %32, i64 -1
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 92
br i1 %36, label %37, label %41
37: ; preds = %30
%38 = load i8**, i8*** %4
%39 = load i8*, i8** %38
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %38
br label %16
41: ; preds = %30
br label %42
42: ; preds = %41
br label %53
43: ; preds = %2
%44 = load i8**, i8*** %4
%45 = load i8*, i8** %44
store i8* %45, i8** %6
%46 = load i8**, i8*** %4
%47 = load i8*, i8** %46
%48 = call i32 @strcspn(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%49 = load i8**, i8*** %4
%50 = load i8*, i8** %49
%51 = sext i32 %48 to i64
%52 = getelementptr inbounds i8, i8* %50, i64 %51
store i8* %52, i8** %49
br label %53
53: ; preds = %43, %42
%54 = load i8**, i8*** %4
%55 = load i8*, i8** %54
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %54
store i8 0, i8* %55
%57 = load i8*, i8** %6
%58 = call i8* @x_strdup(i8* %57)
%59 = load i8**, i8*** %5
store i8* %58, i8** %59
store i32 0, i32* %3
br label %60
60: ; preds = %53, %29
%61 = load i32, i32* %3
ret i32 %61
}

LLVM IR (-O2):
@.str = [2 x i8] c"\22\00"
@.str.1 = [5 x i8] c" \09\0D\0A\00"
define i32 @_cfg_read_string(i8** nocapture %0, i8** nocapture writeonly %1) {
%3 = load i8*, i8** %0
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 34
br i1 %5, label %6, label %25
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %3, i64 1
store i8* %7, i8** %0
%8 = tail call i32 @strcspn(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
store i8* %10, i8** %0
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 34
br i1 %12, label %19, label %34
13: ; preds = %19
store i8* %24, i8** %0
%14 = tail call i32 @strcspn(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %24, i64 %15
store i8* %16, i8** %0
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 34
br i1 %18, label %19, label %34
19: ; preds = %6, %13
%20 = phi i8* [ %16, %13 ], [ %10, %6 ]
%21 = getelementptr inbounds i8, i8* %20, i64 -1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 92
%24 = getelementptr inbounds i8, i8* %20, i64 1
br i1 %23, label %13, label %29
25: ; preds = %2
%26 = tail call i32 @strcspn(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %3, i64 %27
br label %29
29: ; preds = %19, %25
%30 = phi i8* [ %28, %25 ], [ %20, %19 ]
%31 = phi i8* [ %3, %25 ], [ %7, %19 ]
%32 = getelementptr inbounds i8, i8* %30, i64 1
store i8* %32, i8** %0
store i8 0, i8* %30
%33 = tail call i8* @x_strdup(i8* %31)
store i8* %33, i8** %1
br label %34
34: ; preds = %13, %6, %29
%35 = phi i32 [ 0, %29 ], [ -1, %6 ], [ -1, %13 ]
ret i32 %35
}