#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 */
char *_blts_params_mempool_alloc(unsigned int);
int /*<<< orphan*/ strncpy(char *, char *, unsigned int);
char *strrchr(char *, char);
char *_blts_conf_unquote_string_lit(char *str) {
  char *p, *tail;
  unsigned len;
  if (!str)
    return 0;
  if (str[0] != '"')
    return 0;
  tail = strrchr(str, '"');
  len = tail - str;
  if (!len)
    return 0;
  p = _blts_params_mempool_alloc(len);
  strncpy(p, &str[1], len);
  p[len - 1] = '\0';
  return p;
}


x86 assembly (clang, -O0):
<_blts_conf_unquote_string_lit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1154 <_blts_conf_unquote_string_lit+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11e0 <_blts_conf_unquote_string_lit+0xb0>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     1171 <_blts_conf_unquote_string_lit+0x41>
movq   $0x0,-0x8(%rbp)
jmp    11e0 <_blts_conf_unquote_string_lit+0xb0>
mov    -0x10(%rbp),%rdi
mov    $0x22,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11a8 <_blts_conf_unquote_string_lit+0x78>
movq   $0x0,-0x8(%rbp)
jmp    11e0 <_blts_conf_unquote_string_lit+0xb0>
mov    -0x24(%rbp),%edi
call   1050 <_blts_params_mempool_alloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
mov    %ecx,%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_blts_conf_unquote_string_lit>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     1182 <_blts_conf_unquote_string_lit+0x52>
mov    %rdi,%rbx
cmpb   $0x22,(%rdi)
jne    1182 <_blts_conf_unquote_string_lit+0x52>
mov    %rbx,%rdi
mov    $0x22,%esi
call   1040 <strrchr@plt>
mov    %rax,%r15
sub    %rbx,%r15
test   %r15d,%r15d
je     1182 <_blts_conf_unquote_string_lit+0x52>
mov    %r15d,%edi
call   1050 <_blts_params_mempool_alloc@plt>
mov    %rax,%r14
add    $0x1,%rbx
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <strncpy@plt>
add    $0xffffffff,%r15d
movb   $0x0,(%r14,%r15,1)
jmp    1185 <_blts_conf_unquote_string_lit+0x55>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @_blts_conf_unquote_string_lit(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %20, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 34
br i1 %5, label %6, label %20
6: ; preds = %3
%7 = tail call i8* @strrchr(i8* %0, i8 signext 34)
%8 = ptrtoint i8* %7 to i64
%9 = ptrtoint i8* %0 to i64
%10 = sub i64 %8, %9
%11 = trunc i64 %10 to i32
%12 = icmp eq i32 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %6
%14 = tail call i8* @_blts_params_mempool_alloc(i32 %11)
%15 = getelementptr inbounds i8, i8* %0, i64 1
%16 = tail call i32 @strncpy(i8* %14, i8* %15, i32 %11)
%17 = add i64 %10, 4294967295
%18 = and i64 %17, 4294967295
%19 = getelementptr inbounds i8, i8* %14, i64 %18
store i8 0, i8* %19
br label %20
20: ; preds = %6, %3, %1, %13
%21 = phi i8* [ %14, %13 ], [ null, %1 ], [ null, %3 ], [ null, %6 ]
ret i8* %21
}