// File: /workspace/github_c_makefile_star2_O0/jfriesse[P]omping/msg.c
// Function: msg_response_create
size_t
msg_response_create(char *msg, size_t msg_len, const struct msg_decoded *msg_decoded,
    int mcast_grp, int mcast_prefix, const struct sockaddr_storage *mcast_addr,
    const char *session_id, size_t session_id_len)
{
	size_t pos;

	pos = 0;

	msg[pos++] = (unsigned char)MSG_TYPE_RESPONSE;
	if (tlv_add_version(msg, msg_len, &pos) == -1)
		goto small_buf_err;

	if (msg_decoded->client_id) {
		if (tlv_add(msg, msg_len, &pos, TLV_OPT_TYPE_CLIENT_ID, msg_decoded->client_id_len,
		    msg_decoded->client_id) == -1)
			goto small_buf_err;
	}

	if (msg_decoded->seq_num_isset) {
		if (tlv_add_seq_num(msg, msg_len, &pos, msg_decoded->seq_num) == -1)
			goto small_buf_err;
	}

	if (mcast_grp) {
		if (tlv_add_mcast_grp(msg, msg_len, &pos, mcast_addr) == -1)
			goto small_buf_err;
	}

	if (msg_decoded->request_opt_server_info) {
		if (tlv_add_server_info(msg, msg_len, &pos, PROGRAM_SERVER_INFO) == -1)
			goto small_buf_err;
	}

	if (mcast_prefix) {
		if (tlv_add_mcast_prefix(msg, msg_len, &pos, mcast_addr) == -1)
			goto small_buf_err;
	}

	if (session_id) {
		if (tlv_add(msg, msg_len, &pos, TLV_OPT_TYPE_SES_ID, session_id_len,
		    session_id) == -1) {
			goto small_buf_err;
		}
	}

	return (pos);

small_buf_err:
	return (0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x38(%rbp)
movb $0x53, (%rax,%rcx)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0xc140
cmpl $-0x1, %eax
jne 0x6dc1
jmp 0x6ee2
movq -0x20(%rbp), %rax
cmpq $0x0, 0x70(%rax)
je 0x6e02
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x20(%rbp), %rcx
movq 0x70(%rcx), %r9
leaq -0x38(%rbp), %rdx
movl $0x1, %ecx
movzwl %ax, %r8d
callq 0xbb20
cmpl $-0x1, %eax
jne 0x6e00
jmp 0x6ee2
jmp 0x6e02
movq -0x20(%rbp), %rax
cmpl $0x0, 0x64(%rax)
je 0x6e30
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0x50(%rax), %ecx
leaq -0x38(%rbp), %rdx
callq 0xbfb0
cmpl $-0x1, %eax
jne 0x6e2e
jmp 0x6ee2
jmp 0x6e30
cmpl $0x0, -0x24(%rbp)
je 0x6e57
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rcx
leaq -0x38(%rbp), %rdx
callq 0xbcf0
cmpl $-0x1, %eax
jne 0x6e55
jmp 0x6ee2
jmp 0x6e57
movq -0x20(%rbp), %rax
cmpl $0x0, 0x5c(%rax)
je 0x6e82
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x38(%rbp), %rdx
leaq 0x7ffb(%rip), %rcx      # 0xee6f
callq 0xc000
cmpl $-0x1, %eax
jne 0x6e80
jmp 0x6ee2
jmp 0x6e82
cmpl $0x0, -0x28(%rbp)
je 0x6ea6
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rcx
leaq -0x38(%rbp), %rdx
callq 0xbea0
cmpl $-0x1, %eax
jne 0x6ea4
jmp 0x6ee2
jmp 0x6ea6
cmpq $0x0, 0x10(%rbp)
je 0x6ed8
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %r9
leaq -0x38(%rbp), %rdx
movl $0xb, %ecx
movzwl %ax, %r8d
callq 0xbb20
cmpl $-0x1, %eax
jne 0x6ed6
jmp 0x6ee2
jmp 0x6ed8
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6eea
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)