// File: gliktaras[P]skyperole/skyperole.cpp
// Function: getStringProperty[abi:cxx11](unsigned long, unsigned long)
std::vector<std::string> getStringProperty(Window window, Atom property) {
    Atom actualType;
    int actualFormat;
    unsigned long itemCount;
    unsigned long bytesLeft;
    char *data;

    if (XGetWindowProperty(display, window, property, 0, INFINITY, False,
            AnyPropertyType, &actualType, &actualFormat, &itemCount, &bytesLeft,
            reinterpret_cast<unsigned char**>(&data)) == Success) {
        
        if (itemCount > 0) {
            std::vector<std::string> propertyStrings;
            propertyStrings.push_back(data);

            for (size_t i = 0; i < itemCount - 1; ++i) {
                if (data[i] == 0) {
                    propertyStrings.push_back(data + i + 1);
                }
            }    
            return propertyStrings;
        }
    }

    return std::vector<std::string>();
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x58(%rsp)
movq %rdi, %rax
movq %rax, 0x60(%rsp)
movq %rdi, 0x110(%rsp)
movq %rsi, 0x108(%rsp)
movq %rdx, 0x100(%rsp)
movq 0x619a(%rip), %rdi      # 0x9410
movq 0x108(%rsp), %rsi
movq 0x100(%rsp), %rdx
xorl %eax, %eax
movl %eax, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
xorl %r9d, %r9d
leaq 0xf8(%rsp), %r14
leaq 0xf4(%rsp), %rbx
leaq 0xe8(%rsp), %r11
leaq 0xe0(%rsp), %r10
leaq 0xd8(%rsp), %rax
movq $0x0, (%rsp)
movq %r14, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movq %rax, 0x28(%rsp)
callq 0x2060
cmpl $0x0, %eax
jne 0x34ed
cmpq $0x0, 0xe8(%rsp)
jbe 0x34eb
movq 0x58(%rsp), %rdi
movb $0x0, 0xd7(%rsp)
callq 0x3d30
movq 0xd8(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0xaf(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x2330
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
leaq 0xb0(%rsp), %rdi
callq 0x3bc0
jmp 0x3343
movq 0x58(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x3d40
jmp 0x3357
leaq 0xb0(%rsp), %rdi
callq 0x2378
leaq 0xaf(%rsp), %rdi
callq 0x2250
movq $0x0, 0x90(%rsp)
movq 0x90(%rsp), %rax
movq 0xe8(%rsp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x34c1
movq 0xd8(%rsp), %rax
movq 0x90(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x34a6
movq 0xd8(%rsp), %rax
movq 0x90(%rsp), %rcx
leaq 0x1(%rax,%rcx), %rax
movq %rax, 0x38(%rsp)
leaq 0x6f(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x2330
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
leaq 0x70(%rsp), %rdi
callq 0x3bc0
jmp 0x33f6
movq 0x58(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x3d40
jmp 0x3407
leaq 0x70(%rsp), %rdi
callq 0x2378
leaq 0x6f(%rsp), %rdi
callq 0x2250
jmp 0x34a6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0x3457
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x2378
leaq 0xaf(%rsp), %rdi
callq 0x2250
jmp 0x34df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0x349a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x2378
leaq 0x6f(%rsp), %rdi
callq 0x2250
jmp 0x34df
jmp 0x34a8
movq 0x90(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x90(%rsp)
jmp 0x337d
movb $0x1, 0xd7(%rsp)
testb $0x1, 0xd7(%rsp)
jne 0x34dd
movq 0x58(%rsp), %rdi
callq 0x3d70
jmp 0x3508
movq 0x58(%rsp), %rdi
callq 0x3d70
jmp 0x3518
jmp 0x34ed
movq 0x58(%rsp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2110
movq 0x58(%rsp), %rdi
callq 0x3d30
movq 0x60(%rsp), %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r14
retq
movq 0xa0(%rsp), %rdi
callq 0x2320
nopw %cs:(%rax,%rax)