// File: /workspace/github_c_makefile_star2_O0/jfriesse[P]omping/msgsend.c
// Function: ms_answer
int
ms_answer(int ucast_socket, const struct sockaddr_storage *mcast_addr, const char *orig_msg,
    size_t orig_msg_len, const struct msg_decoded *decoded, const struct sockaddr_storage *to,
    uint8_t ttl, enum ms_answer_type answer_type)
{
	char addr_str[INET6_ADDRSTRLEN];
	char new_msg[MAX_MSG_SIZE];
	struct sockaddr_storage to_mcast;
	size_t new_msg_len;
	ssize_t sent;

	new_msg_len = msg_answer_create(orig_msg, orig_msg_len, new_msg, sizeof(new_msg),
	    ttl, decoded->request_opt_server_tstamp);

	if (new_msg_len == 0) {
		return (-4);
	}

	if (answer_type == MS_ANSWER_UCAST || answer_type == MS_ANSWER_BOTH) {
		af_sa_to_str(AF_CAST_SA(to), addr_str);
		DEBUG_PRINTF("Sending unicast answer msg to %s", addr_str);

		msg_update_server_tstamp(new_msg, new_msg_len);

		sent = rs_sendto(ucast_socket, new_msg, new_msg_len, to);

		if (sent < 0) {
			return (sent);
		}
	}

	if (answer_type == MS_ANSWER_MCAST || answer_type == MS_ANSWER_BOTH) {
		af_copy_addr(mcast_addr, to, 1, 2, &to_mcast);

		af_sa_to_str(AF_CAST_SA(&to_mcast), addr_str);
		DEBUG_PRINTF("Sending multicast answer msg to %s", addr_str);

		msg_update_server_tstamp(new_msg, new_msg_len);

		sent = rs_sendto(ucast_socket, new_msg, new_msg_len, &to_mcast);

		if (sent < 0) {
			return (sent);
		}
	}

	return (0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100f0, %rsp          # imm = 0x100F0
movl 0x18(%rbp), %eax
movb 0x10(%rbp), %al
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq -0x10060(%rbp), %rdx
movb 0x10(%rbp), %al
movq -0x28(%rbp), %rcx
movl 0x60(%rcx), %r9d
movl $0xffff, %ecx           # imm = 0xFFFF
movzbl %al, %r8d
callq 0x5ef0
movq %rax, -0x100e8(%rbp)
cmpq $0x0, -0x100e8(%rbp)
jne 0x6ffd
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0x713f
cmpl $0x1, 0x18(%rbp)
je 0x7009
cmpl $0x3, 0x18(%rbp)
jne 0x7088
movq -0x30(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3360
leaq -0x60(%rbp), %r8
leaq 0x7e5b(%rip), %rdi      # 0xee7c
movl $0x43, %esi
movl $0x2, %edx
leaq 0x7e54(%rip), %rcx      # 0xee86
movb $0x0, %al
callq 0x5dc0
leaq -0x10060(%rbp), %rdi
movq -0x100e8(%rbp), %rsi
callq 0x6f00
movl -0x8(%rbp), %edi
leaq -0x10060(%rbp), %rsi
movq -0x100e8(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0xa430
movq %rax, -0x100f0(%rbp)
cmpq $0x0, -0x100f0(%rbp)
jge 0x7086
movq -0x100f0(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x713f
jmp 0x7088
cmpl $0x2, 0x18(%rbp)
je 0x7098
cmpl $0x3, 0x18(%rbp)
jne 0x7138
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl $0x1, %edx
movl $0x2, %ecx
leaq -0x100e0(%rbp), %r8
callq 0x2a90
leaq -0x60(%rbp), %rsi
leaq -0x100e0(%rbp), %rdi
callq 0x3360
leaq -0x60(%rbp), %r8
leaq 0x7dab(%rip), %rdi      # 0xee7c
movl $0x52, %esi
movl $0x2, %edx
leaq 0x7dc5(%rip), %rcx      # 0xeea7
movb $0x0, %al
callq 0x5dc0
leaq -0x10060(%rbp), %rdi
movq -0x100e8(%rbp), %rsi
callq 0x6f00
movl -0x8(%rbp), %edi
leaq -0x10060(%rbp), %rsi
movq -0x100e8(%rbp), %rdx
leaq -0x100e0(%rbp), %rcx
callq 0xa430
movq %rax, -0x100f0(%rbp)
cmpq $0x0, -0x100f0(%rbp)
jge 0x7136
movq -0x100f0(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x713f
jmp 0x7138
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x100f0, %rsp          # imm = 0x100F0
popq %rbp
retq
nopl (%rax,%rax)