// File: /workspace/github_cpp_makefile_star2_O1/blakewford[P]kab/main.cpp
// Function: main
int main(int argc, char **argv)
{
    FILE* cache = fopen("cache.json", "r");
    if(cache != nullptr)
    {
        fclose(cache);

        std::ifstream sample("cache.json");

        set_target t;
        std::string line;
        std::getline(sample, line);
        std::istringstream iss(line);
        parse(line.c_str(), &t);
        addCachedTarget(t);
        while(std::getline(sample, line))
        {
            std::istringstream iss(line);
            parse(line.c_str(), &t);
            addCachedTarget(t);
        }

        if(argc > 1)
        {
            loop();
            return 0;
        }

        int32_t selection = -1;
        printTargets(false);
        printf("[%zu] \u001b[31mCancel\u001b[0m\n", gFound.size());
        printf("\nChoose device:\n");
        std::cin >> selection;

        if(selection >=0 && selection < gFound.size())
        {
            size_t ndx = selection;
            printf("\nSwitch \u001b[34m%s\u001b[0m:\n", gFound.at(ndx).name);
            printf("[0] OFF\n");
            printf("[1] ON\n");
            printf("[2] Listen\n");
            printf("[3] \u001b[31mCancel\u001b[0m\n");
            std::cin >> selection;
            if(selection >=0 && selection < 3)
            {
                switch(selection)
                {
                    case 0:
                    case 1:
                        toggle(ndx, selection ? true: false);
                        break;
                    case 2:
                        loop();
                        break;
                    default:
                        break;
                }
            }
        }
    }
    else
    {
        printf("Starting discovery...\n");
        discover();
    }
 
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5f8, %rsp            # imm = 0x5F8
movl %edi, 0x4(%rsp)
leaq 0x1f3e(%rip), %rdi      # 0x501a
leaq 0x21f2(%rip), %rsi      # 0x52d5
callq 0x2250
testq %rax, %rax
je 0x3391
movq %rax, %rdi
callq 0x2210
leaq 0x1f1a(%rip), %rsi      # 0x501a
leaq 0x3f0(%rsp), %rbx
movq %rbx, %rdi
movl $0x8, %edx
callq 0x23a0
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rsp)
movups %xmm0, 0x50(%rsp)
movups %xmm0, 0x40(%rsp)
movups %xmm0, 0x30(%rsp)
leaq 0x4b75(%rip), %rax      # 0x7ca8
addq $0x10, %rax
movq %rax, 0x28(%rsp)
movups %xmm0, 0x70(%rsp)
movups %xmm0, 0x80(%rsp)
movups %xmm0, 0x90(%rsp)
movups %xmm0, 0xa0(%rsp)
movups %xmm0, 0xb0(%rsp)
movups %xmm0, 0xc0(%rsp)
movups %xmm0, 0xd0(%rsp)
movups %xmm0, 0xe0(%rsp)
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %edx
leaq 0x3f0(%rsp), %r14
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x23b0
leaq 0x270(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0x8, %edx
callq 0x2350
movq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x3910
leaq 0x28(%rsp), %rdi
callq 0x2ee4
leaq 0x168(%rsp), %r15
leaq 0x8(%rsp), %r12
leaq 0xf0(%rsp), %r13
leaq 0x28(%rsp), %rbp
movq 0x4dc6(%rip), %rbx      # 0x7fd0
movq 0x3f0(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x23b0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3279
movq %r13, %rdi
movq %r12, %rsi
movl $0x8, %edx
callq 0x2350
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x3910
movq %rbp, %rdi
callq 0x2ee4
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2290
movq %r15, %rdi
callq 0x20a0
jmp 0x320a
cmpl $0x2, 0x4(%rsp)
jge 0x33a4
leaq 0xf0(%rsp), %rbx
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
xorl %edi, %edi
callq 0x2760
movq 0x5050(%rip), %rsi      # 0x82f0
subq 0x5041(%rip), %rsi      # 0x82e8
sarq $0x3, %rsi
movabsq $-0x505050505050505, %r14 # imm = 0xFAFAFAFAFAFAFAFB
imulq %r14, %rsi
leaq 0x2017(%rip), %rdi      # 0x52d7
xorl %eax, %eax
callq 0x2030
leaq 0x20da(%rip), %rdi      # 0x53a8
callq 0x2300
movq 0x4d06(%rip), %rdi      # 0x7fe0
movq %rbx, %rsi
callq 0x2110
movslq 0xf0(%rsp), %rbx
testq %rbx, %rbx
js 0x33a9
movq 0x4ff6(%rip), %rdx      # 0x82f0
movq 0x4fe7(%rip), %rax      # 0x82e8
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rbx, %rdx
jbe 0x33a9
jbe 0x3411
imulq $0x198, %rbx, %rcx      # imm = 0x198
leaq (%rax,%rcx), %rsi
addq $0x2a, %rsi
leaq 0x1fbd(%rip), %rdi      # 0x52ee
xorl %eax, %eax
callq 0x2030
leaq 0x2079(%rip), %rdi      # 0x53b8
callq 0x2300
leaq 0x2075(%rip), %rdi      # 0x53c0
callq 0x2300
leaq 0x2070(%rip), %rdi      # 0x53c7
callq 0x2300
leaq 0x206f(%rip), %rdi      # 0x53d2
callq 0x2300
movq 0x4c71(%rip), %rdi      # 0x7fe0
leaq 0xf0(%rsp), %rsi
callq 0x2110
movl 0xf0(%rsp), %eax
cmpl $0x2, %eax
ja 0x33a9
jne 0x33ff
callq 0x2fba
jmp 0x33a9
leaq 0x1ffa(%rip), %rdi      # 0x5392
callq 0x2300
callq 0x29c9
jmp 0x33eb
callq 0x2fba
movq 0x4c20(%rip), %rsi      # 0x7fd0
leaq 0x270(%rsp), %rdi
callq 0x2290
leaq 0x2e8(%rsp), %rdi
callq 0x20a0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x33de
callq 0x21e0
leaq 0x3f0(%rsp), %rdi
callq 0x2070
xorl %eax, %eax
addq $0x5f8, %rsp            # imm = 0x5F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %esi, %esi
testl %eax, %eax
setne %sil
movq %rbx, %rdi
callq 0x2618
jmp 0x33a9
leaq 0x1eec(%rip), %rdi      # 0x5304
movq %rbx, %rsi
xorl %eax, %eax
callq 0x22e0
jmp 0x3457
jmp 0x3457
jmp 0x3428
movq %rax, %rbx
jmp 0x347b
jmp 0x3457
jmp 0x3457
movq %rax, %rbx
movq 0x4b95(%rip), %rsi      # 0x7fd0
leaq 0xf0(%rsp), %rdi
callq 0x2290
leaq 0x168(%rsp), %rdi
callq 0x20a0
jmp 0x345a
movq %rax, %rbx
movq 0x4b6f(%rip), %rsi      # 0x7fd0
leaq 0x270(%rsp), %rdi
callq 0x2290
leaq 0x2e8(%rsp), %rdi
callq 0x20a0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x348f
callq 0x21e0
leaq 0x3f0(%rsp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x2360