// File: /workspace/github_c_makefile_star2_O0/jech[P]shncpd/dhcpv4.c
// Function: dhcpv4_send
static int
dhcpv4_send(int s, struct sockaddr_in *to, int dontroute,
            int type, const unsigned char *xid,
            const unsigned char *chaddr, const unsigned char *myaddr,
            const unsigned char *ip, int ifindex,
            const unsigned char *netmask, struct prefix_list *dns,
            int lease_time)
{
    int buflen = 1024;
    unsigned char buf[buflen];
    int i = 0;
    int rc;
    struct ifreq ifr;

    debugf("-> DHCPv4 (type %d) on interface %d\n", type, ifindex);

    MEM_UNDEFINED(buf, buflen);

    CHECK(236);
    BYTE(2);
    BYTE(1);
    BYTE(6);
    BYTE(0);
    BYTES(xid, 4);
    SHORT(0);
    SHORT(0);

    ZEROS(4);                   /* ciaddr */
    if(ip && lease_time >= 20) {
        BYTES(ip, 4);           /* yiaddr */
    } else {
        ZEROS(4);
    }
    BYTES(myaddr, 4);           /* siaddr */
    ZEROS(4);                   /* giaddr */
    BYTES(chaddr, 16);          /* chaddr */
    ZEROS(64);                  /* sname */
    ZEROS(128);                 /* file */

    CHECK(4);
    BYTES(cookie, 4);

    CHECK(3);
    BYTE(53);                   /* DHCP Message Type */
    BYTE(1);
    BYTE(type);

    CHECK(6);
    BYTE(54);                   /* Server Identifier */
    BYTE(4);
    BYTES(myaddr, 4);

    if(lease_time >= 20) {
        CHECK(6);
        BYTE(51);               /* IP Address Lease Time */
        BYTE(4);
        LONG(lease_time);

        CHECK(6);
        BYTE(58);               /* T1 */
        BYTE(4);
        LONG(min(RENEW_TIME, lease_time - 10));

        CHECK(6);
        BYTE(59);               /* T2 */
        BYTE(4);
        LONG(min(REBIND_TIME, lease_time - 15));
    }

    if(netmask) {
        CHECK(6);
        BYTE(1);
        BYTE(4);
        BYTES(netmask, 4);
    }

    CHECK(6);
    BYTE(3);
    BYTE(4);
    BYTES(myaddr, 4);

    if(dns && dns->numprefixes > 0) {
        int j;
        CHECK(2 + 4 * dns->numprefixes);
        BYTE(6);
        BYTE(4 * dns->numprefixes);
        for(j = 0; j < dns->numprefixes; j++) {
            BYTES((char*)&dns->prefixes[j].p + 12, 4);
        }
    }

    CHECK(1);
    BYTE(255);

    memset(&ifr, 0, sizeof(ifr));
    if_indextoname(ifindex, ifr.ifr_name);
    rc = setsockopt(dhcpv4_socket, SOL_SOCKET, SO_BINDTODEVICE,
                    &ifr, sizeof(ifr));
    if(rc < 0)
        return -1;

    rc = sendto(dhcpv4_socket, buf, i, dontroute ? MSG_DONTROUTE : 0,
                (struct sockaddr*)to, sizeof(*to));

    setsockopt(dhcpv4_socket, SOL_SOCKET, SO_BINDTODEVICE, NULL, 0);
    return rc;

 fail:
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movl 0x38(%rbp), %eax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movl 0x20(%rbp), %eax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movl $0x400, -0x2c(%rbp)     # imm = 0x400
movl -0x2c(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x38(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x90(%rbp)
movq %rcx, %rsp
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
leaq 0xaca4(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0xb5e2
movl -0x18(%rbp), %edx
movl 0x20(%rbp), %ecx
movl $0x2, %edi
leaq 0x7a61(%rip), %rsi      # 0x1303c
movb $0x0, %al
callq 0xfda0
jmp 0xb5e4
jmp 0xb5e6
jmp 0xb5e8
jmp 0xb5ea
jmp 0xb5ec
movl -0x2c(%rbp), %eax
movl -0x44(%rbp), %ecx
addl $0xec, %ecx
cmpl %ecx, %eax
jge 0xb601
jmp 0xbc4d
movq -0x90(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x2, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movslq -0x44(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movslq -0x44(%rbp), %rcx
movb $0x6, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movslq -0x44(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movslq -0x44(%rbp), %rcx
movq -0x20(%rbp), %rdx
movl (%rdx), %edx
movl %edx, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x44(%rbp)
xorl %edi, %edi
callq 0x2100
movw %ax, %cx
movq -0x90(%rbp), %rax
movw %cx, -0x72(%rbp)
movslq -0x44(%rbp), %rcx
movw -0x72(%rbp), %dx
movw %dx, (%rax,%rcx)
jmp 0xb685
movl -0x44(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x44(%rbp)
xorl %edi, %edi
callq 0x2100
movw %ax, %cx
movq -0x90(%rbp), %rax
movw %cx, -0x74(%rbp)
movslq -0x44(%rbp), %rcx
movw -0x74(%rbp), %dx
movw %dx, (%rax,%rcx)
jmp 0xb6b1
movq -0x90(%rbp), %rdi
movl -0x44(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x44(%rbp)
movslq -0x44(%rbp), %rax
addq %rax, %rdi
xorl %esi, %esi
movl $0x4, %edx
callq 0x2170
movl -0x44(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x44(%rbp)
cmpq $0x0, 0x18(%rbp)
je 0xb709
cmpl $0x14, 0x38(%rbp)
jl 0xb709
movq -0x90(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq 0x18(%rbp), %rdx
movl (%rdx), %edx
movl %edx, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x44(%rbp)
jmp 0xb72c
movq -0x90(%rbp), %rdi
movslq -0x44(%rbp), %rax
addq %rax, %rdi
xorl %esi, %esi
movl $0x4, %edx
callq 0x2170
movl -0x44(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x44(%rbp)
movq -0x90(%rbp), %rdi
movslq -0x44(%rbp), %rax
movq 0x10(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, (%rdi,%rax)
movl -0x44(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x44(%rbp)
movslq -0x44(%rbp), %rax
addq %rax, %rdi
xorl %esi, %esi
movl $0x4, %edx
callq 0x2170
movq -0x90(%rbp), %rdi
movl -0x44(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x44(%rbp)
movslq -0x44(%rbp), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rdi,%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rdi,%rax)
movl -0x44(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x44(%rbp)
movslq -0x44(%rbp), %rax
addq %rax, %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2170
movq -0x90(%rbp), %rdi
movl -0x44(%rbp), %eax
addl $0x40, %eax
movl %eax, -0x44(%rbp)
movslq -0x44(%rbp), %rax
addq %rax, %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0x2170
movl -0x44(%rbp), %eax
addl $0x80, %eax
movl %eax, -0x44(%rbp)
movl -0x2c(%rbp), %eax
movl -0x44(%rbp), %ecx
addl $0x4, %ecx
cmpl %ecx, %eax
jge 0xb7e0
jmp 0xbc4d
movq -0x90(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl 0x76eb(%rip), %edx      # 0x12edc
movl %edx, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x44(%rbp)
movl -0x2c(%rbp), %eax
movl -0x44(%rbp), %ecx
addl $0x3, %ecx
cmpl %ecx, %eax
jge 0xb80f
jmp 0xbc4d
movq -0x90(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x35, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movslq -0x44(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movl -0x18(%rbp), %ecx
movb %cl, %dl
movslq -0x44(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x2c(%rbp), %eax
movl -0x44(%rbp), %ecx
addl $0x6, %ecx
cmpl %ecx, %eax
jge 0xb85f
jmp 0xbc4d
movq -0x90(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x36, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movslq -0x44(%rbp), %rcx
movb $0x4, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movslq -0x44(%rbp), %rcx
movq 0x10(%rbp), %rdx
movl (%rdx), %edx
movl %edx, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x44(%rbp)
cmpl $0x14, 0x38(%rbp)
jl 0xb9f2
movl -0x2c(%rbp), %eax
movl -0x44(%rbp), %ecx
addl $0x6, %ecx
cmpl %ecx, %eax
jge 0xb8ba
jmp 0xbc4d
movq -0x90(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x33, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movslq -0x44(%rbp), %rcx
movb $0x4, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl 0x38(%rbp), %edi
callq 0x2160
movl %eax, %ecx
movq -0x90(%rbp), %rax
movl %ecx, -0x78(%rbp)
movslq -0x44(%rbp), %rcx
movl -0x78(%rbp), %edx
movl %edx, (%rax,%rcx)
jmp 0xb903
movl -0x44(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x44(%rbp)
movl -0x2c(%rbp), %eax
movl -0x44(%rbp), %ecx
addl $0x6, %ecx
cmpl %ecx, %eax
jge 0xb91e
jmp 0xbc4d
movq -0x90(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x3a, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movslq -0x44(%rbp), %rcx
movb $0x4, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl 0x38(%rbp), %esi
subl $0xa, %esi
movl $0xf0, %edi
callq 0xbc70
movl %eax, %edi
callq 0x2160
movl %eax, %ecx
movq -0x90(%rbp), %rax
movl %ecx, -0x7c(%rbp)
movslq -0x44(%rbp), %rcx
movl -0x7c(%rbp), %edx
movl %edx, (%rax,%rcx)
jmp 0xb976
movl -0x44(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x44(%rbp)
movl -0x2c(%rbp), %eax
movl -0x44(%rbp), %ecx
addl $0x6, %ecx
cmpl %ecx, %eax
jge 0xb991
jmp 0xbc4d
movq -0x90(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x3b, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movslq -0x44(%rbp), %rcx
movb $0x4, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl 0x38(%rbp), %esi
subl $0xf, %esi
movl $0x12c, %edi            # imm = 0x12C
callq 0xbc70
movl %eax, %edi
callq 0x2160
movl %eax, %ecx
movq -0x90(%rbp), %rax
movl %ecx, -0x80(%rbp)
movslq -0x44(%rbp), %rcx
movl -0x80(%rbp), %edx
movl %edx, (%rax,%rcx)
jmp 0xb9e9
movl -0x44(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x44(%rbp)
cmpq $0x0, 0x28(%rbp)
je 0xba4a
movl -0x2c(%rbp), %eax
movl -0x44(%rbp), %ecx
addl $0x6, %ecx
cmpl %ecx, %eax
jge 0xba0b
jmp 0xbc4d
movq -0x90(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movslq -0x44(%rbp), %rcx
movb $0x4, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movslq -0x44(%rbp), %rcx
movq 0x28(%rbp), %rdx
movl (%rdx), %edx
movl %edx, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x44(%rbp)
movl -0x2c(%rbp), %eax
movl -0x44(%rbp), %ecx
addl $0x6, %ecx
cmpl %ecx, %eax
jge 0xba5c
jmp 0xbc4d
movq -0x90(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x3, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movslq -0x44(%rbp), %rcx
movb $0x4, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movslq -0x44(%rbp), %rcx
movq 0x10(%rbp), %rdx
movl (%rdx), %edx
movl %edx, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x44(%rbp)
cmpq $0x0, 0x30(%rbp)
je 0xbb69
movq 0x30(%rbp), %rax
movswl 0x8(%rax), %eax
cmpl $0x0, %eax
jle 0xbb69
movl -0x2c(%rbp), %eax
movl -0x44(%rbp), %ecx
movq 0x30(%rbp), %rdx
movswl 0x8(%rdx), %edx
shll $0x2, %edx
addl $0x2, %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0xbad6
jmp 0xbc4d
movq -0x90(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x6, (%rax,%rcx)
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x44(%rbp)
movq 0x30(%rbp), %rcx
movswl 0x8(%rcx), %ecx
shll $0x2, %ecx
movb %cl, %dl
movslq -0x44(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
movq 0x30(%rbp), %rcx
movswl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jge 0xbb67
movq -0x90(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq 0x30(%rbp), %rdx
movq (%rdx), %rdx
movslq -0x84(%rbp), %rsi
imulq $0x1c, %rsi, %rsi
addq %rsi, %rdx
movl 0xc(%rdx), %edx
movl %edx, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x44(%rbp)
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0xbb15
jmp 0xbb69
movl -0x2c(%rbp), %eax
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0xbb7b
jmp 0xbc4d
movq -0x90(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $-0x1, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x2170
movl 0x20(%rbp), %edi
leaq -0x70(%rbp), %rsi
callq 0x2280
movl 0xa64b(%rip), %edi      # 0x16200
movl $0x1, %esi
movl $0x19, %edx
leaq -0x70(%rbp), %rcx
movl $0x28, %r8d
callq 0x2090
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jge 0xbbea
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x88(%rbp)
jmp 0xbc5e
movq -0x90(%rbp), %rsi
movl 0xa609(%rip), %edi      # 0x16200
movslq -0x44(%rbp), %rdx
movl -0x14(%rbp), %r8d
xorl %ecx, %ecx
movl $0x4, %eax
cmpl $0x0, %r8d
cmovnel %eax, %ecx
movq -0x10(%rbp), %r8
movl $0x10, %r9d
callq 0x2180
movl %eax, -0x48(%rbp)
movl 0xa5db(%rip), %edi      # 0x16200
movl $0x1, %esi
movl $0x19, %edx
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
callq 0x2090
movl -0x48(%rbp), %eax
movl %eax, -0x4(%rbp)
movl $0x1, -0x88(%rbp)
jmp 0xbc5e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x88(%rbp)
movq -0x38(%rbp), %rax
movq %rax, %rsp
movl -0x4(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq
nopl (%rax)