// File: kiudee[P]VAHD-Projekt/./Subjects1-6.h
// Function: Relay::Relay(Identity*&)
Relay::Relay(Identity* &d)
{
    _home = _activeSubject;
    _setup();
    if (_home != NULL) {    // relay generated within subject?
        if (d == NULL) {
            if (WARNING) {
                std::cout << "-- Warning! Cannot establish connection from " << ID << " to NULL.\n";
            }
        } else {
            if (d->_source == NULL) {
                if (WARNING) {
                    std::cout << "-- Warning! Cannot establish connection from " << ID << " to NULL.\n";
                }
            } else {
                if (d->_base == NULL) {
                    if (WARNING) {
                        std::cout << "-- Warning! Private identity not correctly defined or already used.\n";
                    }
                } else {
                    if (d->_sink != NULL && d->_sink->_home != _home) {
                        if (WARNING) {
                            std::cout << "-- Warning! Identity of " << d->_source->ID << " not meant for " << ID << ".\n";
                        }
                    } else {
                        _oLink = d->_source;        // connect to relay point
                        _oLink->_iLinks->add(this);
                        if (d->_sink == NULL) {
                            _private = 0;
                        }
                        _base = d->_base;        // base = d-base
                        delete d;                // destroy identity
                        d = NULL;
                        if (DEBUG) {
                            std::cout << "-- Creating relay point " << ID << " to " << _oLink->ID << " with base " << _base->ID << ".\n";
                        }
                        if (!(_oLink->_awake)) {
                            _oLink = NULL;
                        }
                    }
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x18(%rbp)
leaq 0x1b371(%rip), %rax     # 0x20c20
addq $0x10, %rax
movq %rax, (%rdi)
leaq 0x1b953(%rip), %rax     # 0x21210
movq (%rax), %rax
movq %rax, 0x18(%rdi)
movq (%rdi), %rax
callq *(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x59dc
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x58e7
jmp 0x59da
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0x58fa
jmp 0x59d8
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x20(%rax)
jne 0x590d
jmp 0x59d6
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x18(%rax)
je 0x5939
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
cmpq 0x18(%rcx), %rax
je 0x5939
jmp 0x59d4
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0x28(%rsi)
movq 0x28(%rsi), %rax
movq 0x20(%rax), %rdi
callq 0x6ef0
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x18(%rax)
jne 0x5972
movq -0x18(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movq 0x20(%rcx), %rcx
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x59ad
movq -0x20(%rbp), %rdi
callq 0x8770
movq -0x20(%rbp), %rdi
movl $0x28, %esi
callq 0x31d0
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq $0x0, (%rcx)
movq 0x28(%rax), %rax
cmpl $0x0, 0x10(%rax)
jne 0x59d2
movq -0x18(%rbp), %rax
movq $0x0, 0x28(%rax)
jmp 0x59d4
jmp 0x59d6
jmp 0x59d8
jmp 0x59da
jmp 0x59dc
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)