#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 *dup_str(char *, char *);
char *strdup(char *);
int strlen(char *);
char *d_dup_pathname_str(char *s) {
  char *e = s;
  if (!s)
    return strdup("");
  if (*e == '"') {
    e++;
    while (*e && *e != '"')
      e++;
    return dup_str(s + 1, e);
  } else
    return dup_str(s, s + strlen(s));
}


x86 assembly (clang, -O0):
<d_dup_pathname_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1164 <d_dup_pathname_str+0x34>
lea    0xeaa(%rip),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    120f <d_dup_pathname_str+0xdf>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    11e0 <d_dup_pathname_str+0xb0>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     11a5 <d_dup_pathname_str+0x75>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11b5 <d_dup_pathname_str+0x85>
jmp    11c6 <d_dup_pathname_str+0x96>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1180 <d_dup_pathname_str+0x50>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
call   1030 <dup_str@plt>
mov    %rax,-0x8(%rbp)
jmp    120f <d_dup_pathname_str+0xdf>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdi
cltq
add    %rax,%rsi
call   1030 <dup_str@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<d_dup_pathname_str>:
push   %rbx
test   %rdi,%rdi
je     1166 <d_dup_pathname_str+0x36>
mov    %rdi,%rbx
cmpb   $0x22,(%rdi)
jne    1173 <d_dup_pathname_str+0x43>
mov    %rbx,%rsi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rsi),%eax
add    $0x1,%rsi
cmp    $0x22,%al
je     1160 <d_dup_pathname_str+0x30>
test   %al,%al
jne    1150 <d_dup_pathname_str+0x20>
add    $0x1,%rbx
jmp    1181 <d_dup_pathname_str+0x51>
lea    0xe93(%rip),%rdi
pop    %rbx
jmp    1050 <strdup@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rsi
add    %rbx,%rsi
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <dup_str@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @d_dup_pathname_str(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
store i8* %5, i8** %4
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %2
br label %46
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 34
br i1 %14, label %15, label %38
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %4
br label %18
18: ; preds = %30, %15
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load i8*, i8** %4
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 34
br label %28
28: ; preds = %23, %18
%29 = phi i1 [ false, %18 ], [ %27, %23 ]
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %4
br label %18
33: ; preds = %28
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = load i8*, i8** %4
%37 = call i8* @dup_str(i8* %35, i8* %36)
store i8* %37, i8** %2
br label %46
38: ; preds = %10
%39 = load i8*, i8** %3
%40 = load i8*, i8** %3
%41 = load i8*, i8** %3
%42 = call i32 @strlen(i8* %41)
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %40, i64 %43
%45 = call i8* @dup_str(i8* %39, i8* %44)
store i8* %45, i8** %2
br label %46
46: ; preds = %38, %33, %8
%47 = load i8*, i8** %2
ret i8* %47
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @d_dup_pathname_str(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %20
5: ; preds = %1
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 34
br i1 %7, label %8, label %15
8: ; preds = %5, %8
%9 = phi i8* [ %10, %8 ], [ %0, %5 ]
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = load i8, i8* %10
switch i8 %11, label %8 [
i8 0, label %12
i8 34, label %12
]
12: ; preds = %8, %8
%13 = getelementptr inbounds i8, i8* %0, i64 1
%14 = tail call i8* @dup_str(i8* %13, i8* %10)
br label %20
15: ; preds = %5
%16 = tail call i32 @strlen(i8* %0)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = tail call i8* @dup_str(i8* %0, i8* %18)
br label %20
20: ; preds = %15, %12, %3
%21 = phi i8* [ %14, %12 ], [ %19, %15 ], [ %4, %3 ]
ret i8* %21
}