#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 */
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int /*<<< orphan*/ *we_wordv;
};
typedef TYPE_1__ wordexp_t;

/* Variables and functions */
scalar_t__ strcmp(int /*<<< orphan*/, char *);
char *strdup(int /*<<< orphan*/);
int /*<<< orphan*/ wordexp(char *, TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ wordfree(TYPE_1__ *);
char *path_attribute(char *line, unsigned int length) {
  (void)length;
  wordexp_t wordexp_buffer;
  wordexp(line, &wordexp_buffer, 0);
  char *expanded = NULL;
  if (strcmp(wordexp_buffer.we_wordv[0], "-")) {
    expanded = strdup(wordexp_buffer.we_wordv[0]);
  }
  wordfree(&wordexp_buffer);
  return expanded;
}


x86 assembly (clang, -O0):
<path_attribute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1050 <wordexp@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1191 <path_attribute+0x51>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1060 <strdup@plt>
mov    %rax,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
call   1040 <wordfree@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<path_attribute>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rsi
xor    %ebx,%ebx
xor    %edx,%edx
call   1050 <wordexp@plt>
mov    0x8(%rsp),%rax
mov    (%rax),%edi
lea    0xe9f(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     117a <path_attribute+0x3a>
mov    0x8(%rsp),%rax
mov    (%rax),%edi
call   1060 <strdup@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
call   1040 <wordfree@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32* }
@.str = [2 x i8] c"-\00"
define i8* @path_attribute(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.TYPE_4__
%6 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = load i8*, i8** %3
%9 = call i32 @wordexp(i8* %8, %struct.TYPE_4__* %5, i32 0)
store i8* null, i8** %6
%10 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %5, i32 0, i32 0
%11 = load i32*, i32** %10
%12 = getelementptr inbounds i32, i32* %11, i64 0
%13 = load i32, i32* %12
%14 = call i64 @strcmp(i32 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %5, i32 0, i32 0
%18 = load i32*, i32** %17
%19 = getelementptr inbounds i32, i32* %18, i64 0
%20 = load i32, i32* %19
%21 = call i8* @strdup(i32 %20)
store i8* %21, i8** %6
br label %22
22: ; preds = %16, %2
%23 = call i32 @wordfree(%struct.TYPE_4__* %5)
%24 = load i8*, i8** %6
ret i8* %24
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32* }
@.str = [2 x i8] c"-\00"
define i8* @path_attribute(i8* %0, i32 %1) {
%3 = alloca %struct.TYPE_4__
%4 = bitcast %struct.TYPE_4__* %3 to i8*
%5 = call i32 @wordexp(i8* %0, %struct.TYPE_4__* %3, i32 0)
%6 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i64 0, i32 0
%7 = load i32*, i32** %6
%8 = load i32, i32* %7
%9 = call i64 @strcmp(i32 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = load i32*, i32** %6
%13 = load i32, i32* %12
%14 = call i8* @strdup(i32 %13)
br label %15
15: ; preds = %11, %2
%16 = phi i8* [ %14, %11 ], [ null, %2 ]
%17 = call i32 @wordfree(%struct.TYPE_4__* %3)
ret i8* %16
}