// File: merelin[P]mediasmartserverd/src/mediasmartserverd.cpp
// Function: GetUdevDeviceAttribute(char const*, char const*, char const*)
const char *GetUdevDeviceAttribute(const char *subsystem, const char *sysname, const char *sysattr) {
	struct udev *udev;
	struct udev_device *device;
	std::string value;

	udev = udev_new();
	if (!udev) throw ErrnoException("udev_new");

	device = udev_device_new_from_subsystem_sysname(udev, subsystem, sysname);
	value = udev_device_get_sysattr_value(device, sysattr);
	value.erase(value.begin(), std::find_if(value.begin(), value.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
	value.erase(std::find_if(value.rbegin(), value.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), value.end());
	//free
	udev_device_unref(device);
	udev_unref(udev);
	
	return strdup(value.c_str());
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5560
callq 0x54e0
movq %rax, -0x120(%rbp)
jmp 0x95ce
movq -0x120(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x96b4
movb $0x1, -0x7a(%rbp)
movl $0x10, %edi
callq 0x51b0
movq %rax, -0x130(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x56c0
movq -0x128(%rbp), %rdx
leaq 0x89ed(%rip), %rsi      # 0x12004
leaq -0x78(%rbp), %rdi
callq 0x7600
jmp 0x9622
callq 0x5030
movq -0x130(%rbp), %rdi
movl (%rax), %edx
leaq -0x78(%rbp), %rsi
callq 0x76b0
jmp 0x963b
movq -0x130(%rbp), %rdi
movb $0x0, -0x7a(%rbp)
leaq 0xdfb3(%rip), %rsi      # 0x17600
leaq -0x1ed4(%rip), %rdx     # 0x7780
callq 0x5680
jmp 0x9986
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x9974
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x9692
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5230
leaq -0x79(%rbp), %rdi
callq 0x53f0
testb $0x1, -0x7a(%rbp)
jne 0x96a3
jmp 0x96af
movq -0x130(%rbp), %rdi
callq 0x52a0
jmp 0x9974
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x55b0
movq %rax, -0x138(%rbp)
jmp 0x96ce
movq -0x138(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5550
movq %rax, -0x140(%rbp)
jmp 0x96ef
movq -0x140(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x5540
jmp 0x9701
leaq -0x48(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x5310
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xb0f0
movq -0x150(%rbp), %rdi
callq 0x5310
movq -0x150(%rbp), %rdi
movq %rax, -0xa8(%rbp)
callq 0x5200
movq %rax, -0xb0(%rbp)
movq 0xe828(%rip), %rdi      # 0x17f80
callq 0xb1c0
movq %rax, -0x148(%rbp)
jmp 0x9766
movq -0x148(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0xb190
movq %rax, -0x158(%rbp)
jmp 0x9789
movq -0x158(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xa8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
callq 0xb130
movq %rax, -0x160(%rbp)
jmp 0x97ba
movq -0x160(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0xb0f0
movq -0x88(%rbp), %rsi
movq -0x98(%rbp), %rdx
leaq -0x48(%rbp), %rdi
callq 0x5070
movq %rax, -0x168(%rbp)
jmp 0x97fb
movq -0x168(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0xe8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movq %rsi, -0x178(%rbp)
callq 0x56a0
movq -0x178(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x5480
movq 0xe746(%rip), %rdi      # 0x17f80
callq 0xb1c0
movq %rax, -0x170(%rbp)
jmp 0x9848
movq -0x170(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq -0x100(%rbp), %rdi
callq 0xb190
movq %rax, -0x180(%rbp)
jmp 0x986b
movq -0x180(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rcx
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
leaq -0xf0(%rbp), %rdx
callq 0xb1f0
jmp 0x989c
leaq -0xe0(%rbp), %rdi
callq 0xb270
movq %rax, -0x188(%rbp)
jmp 0x98b1
movq -0x188(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xb0f0
leaq -0x48(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x5200
movq %rax, -0x110(%rbp)
leaq -0x108(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0xb0f0
movq -0x198(%rbp), %rdi
movq -0xd0(%rbp), %rsi
movq -0x108(%rbp), %rdx
callq 0x5070
movq %rax, -0x190(%rbp)
jmp 0x991f
movq -0x190(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x28(%rbp), %rdi
callq 0x57a8
jmp 0x9938
movq -0x20(%rbp), %rdi
callq 0x54b0
jmp 0x9943
leaq -0x48(%rbp), %rdi
callq 0x5170
movq %rax, %rdi
callq 0x5720
movq %rax, -0x1a0(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5230
movq -0x1a0(%rbp), %rax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x5230
movq -0x50(%rbp), %rdi
callq 0x56b0
nopw %cs:(%rax,%rax)