// File: lega911[P]ijson/src/connect.cpp
// Function: Connect::rpc_add()
void Connect::rpc_add() {
    Slice name(this->name);

    while(json.scan()) {
        if(json.key == "name") {
            json.decode_value(this->name);
            name = this->name;
        } else if(json.key == "info") {
            info = json.value;
        } else if(json.key == "option") {
            if(json.value == "no_id") {
                this->noid = true;
                this->fail_on_disconnect = true;
            } else if(json.value == "fail_on_disconnect") this->fail_on_disconnect = true;
            else {
                // TODO: Wrong option!!!
            }
        }
    }

    if(name.empty()) {
        worker_mode = false;
        this->send.status("400 No name")->done(-32602);
        if(server->log & 4) std::cout << ltime() << "No name for worker " << this << std::endl;
        return;
    };

    if(worker_mode) {
        this->noid = true;
        this->fail_on_disconnect = true;
    };

    loop->add_worker(name, this);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0x40(%rbp)
addq $0xb8, %rsi
leaq -0x18(%rbp), %rdi
callq 0x1e9f0
movq -0x40(%rbp), %rdi
addq $0x128, %rdi            # imm = 0x128
callq 0x236d0
testb $0x1, %al
jne 0x1c06d
jmp 0x1c19a
movq -0x40(%rbp), %rdi
addq $0x128, %rdi            # imm = 0x128
leaq 0x1c2f4(%rip), %rsi     # 0x38373
callq 0x1ee30
testb $0x1, %al
jne 0x1c08a
jmp 0x1c0cb
movq -0x40(%rbp), %rsi
movq %rsi, %rdi
addq $0x128, %rdi            # imm = 0x128
addq $0xb8, %rsi
callq 0x23f30
movq -0x40(%rbp), %rsi
addq $0xb8, %rsi
leaq -0x28(%rbp), %rdi
callq 0x1e9f0
movq -0x28(%rbp), %rax
movq %rax, -0x18(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0x1c195
movq -0x40(%rbp), %rdi
addq $0x128, %rdi            # imm = 0x128
leaq 0x1c26a(%rip), %rsi     # 0x38347
callq 0x1ee30
testb $0x1, %al
jne 0x1c0e8
jmp 0x1c10b
movq -0x40(%rbp), %rax
movq 0x138(%rax), %rcx
movq %rcx, 0x168(%rax)
movl 0x140(%rax), %ecx
movl %ecx, 0x170(%rax)
jmp 0x1c193
movq -0x40(%rbp), %rdi
addq $0x128, %rdi            # imm = 0x128
leaq 0x1c22f(%rip), %rsi     # 0x3834c
callq 0x1ee30
testb $0x1, %al
jne 0x1c128
jmp 0x1c191
movq -0x40(%rbp), %rdi
addq $0x128, %rdi            # imm = 0x128
addq $0x10, %rdi
leaq 0x1c215(%rip), %rsi     # 0x38353
callq 0x1ee30
testb $0x1, %al
jne 0x1c149
jmp 0x1c15d
movq -0x40(%rbp), %rax
movb $0x1, 0xf1(%rax)
movb $0x1, 0xf0(%rax)
jmp 0x1c18f
movq -0x40(%rbp), %rdi
addq $0x128, %rdi            # imm = 0x128
addq $0x10, %rdi
leaq 0x1c1e6(%rip), %rsi     # 0x38359
callq 0x1ee30
testb $0x1, %al
jne 0x1c17e
jmp 0x1c18b
movq -0x40(%rbp), %rax
movb $0x1, 0xf0(%rax)
jmp 0x1c18d
jmp 0x1c18d
jmp 0x1c18f
jmp 0x1c191
jmp 0x1c193
jmp 0x1c195
jmp 0x1c054
leaq -0x18(%rbp), %rdi
callq 0x1eb40
testb $0x1, %al
jne 0x1c1a9
jmp 0x1c224
movq -0x40(%rbp), %rdi
movb $0x0, 0xf3(%rdi)
addq $0x18, %rdi
leaq 0x1c1ad(%rip), %rsi     # 0x3836c
callq 0x1b6d0
movq %rax, %rdi
movl $0xffff80a6, %esi       # imm = 0xFFFF80A6
callq 0x1b770
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rax
movl 0x20(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1c222
callq 0x36960
movq %rax, %rsi
movq 0x2addd(%rip), %rdi     # 0x46fd0
callq 0x192e0
movq %rax, %rdi
leaq 0x1c176(%rip), %rsi     # 0x38378
callq 0x192e0
movq -0x40(%rbp), %rsi
movq %rax, %rdi
callq 0x19250
movq %rax, %rdi
movq 0x2ad93(%rip), %rsi     # 0x46fb0
callq 0x19320
jmp 0x1c267
movq -0x40(%rbp), %rax
testb $0x1, 0xf3(%rax)
je 0x1c243
movq -0x40(%rbp), %rax
movb $0x1, 0xf1(%rax)
movb $0x1, 0xf0(%rax)
movq -0x40(%rbp), %rcx
movq 0x30(%rcx), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rsi
movl -0x30(%rbp), %edx
callq 0x2b350
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)