// File: /workspace/github_c_makefile_star2_O0/jfriesse[P]omping/sfset.c
// Function: sfset_ttl
int
sfset_ttl(const struct sockaddr *sa, enum sf_cast_type cast_type, int sock, uint8_t ttl)
{
	int ittl;
	int res;

	ittl = ttl;

	switch (sa->sa_family) {
	case AF_INET:
		if (cast_type == SF_CT_MULTI) {
			res = setsockopt(sock, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl));
			if (res == -1) {
				DEBUG_PRINTF("setsockopt IP_MULTICAST_TTL failed");
				return (-1);
			}
		} else {
			res = setsockopt(sock, IPPROTO_IP, IP_TTL, &ittl, sizeof(ittl));
			if (res == -1) {
				DEBUG_PRINTF("setsockopt IP_TTL failed");
				return (-1);
			}
		}
		break;
	case AF_INET6:
		if (cast_type == SF_CT_MULTI) {
			res = setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &ittl,
			    sizeof(ittl));

			if (res == -1) {
				DEBUG_PRINTF("setsockopt IPV6_MULTICAST_HOPS failed");

				return (-1);
			}
		} else {
			res = setsockopt(sock, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ittl,
			    sizeof(ittl));

			if (res == -1) {
				DEBUG_PRINTF("setsockopt IPV6_UNICAST_HOPS failed");

				return (-1);
			}
		}
		break;
	default:
		DEBUG_PRINTF("Unknown sockaddr family");
		errx(1, "Unknown sockaddr family");
	}

	return (0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %cl, %al
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movb %al, -0x19(%rbp)
movzbl -0x19(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x28(%rbp)
subl $0x2, %eax
je 0xad30
jmp 0xad1f
movl -0x28(%rbp), %eax
subl $0xa, %eax
je 0xadd9
jmp 0xae82
cmpl $0x1, -0x14(%rbp)
jne 0xad85
movl -0x18(%rbp), %edi
xorl %esi, %esi
movl $0x21, %edx
leaq -0x19(%rbp), %rcx
movl $0x1, %r8d
callq 0x20a0
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
jne 0xad83
leaq 0x4ac1(%rip), %rdi      # 0xf820
movl $0x15c, %esi            # imm = 0x15C
movl $0x2, %edx
leaq 0x4cc4(%rip), %rcx      # 0xfa34
movb $0x0, %al
callq 0x5dc0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xaebb
jmp 0xadd4
movl -0x18(%rbp), %edi
xorl %esi, %esi
movl $0x2, %edx
leaq -0x20(%rbp), %rcx
movl $0x4, %r8d
callq 0x20a0
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
jne 0xadd2
leaq 0x4a72(%rip), %rdi      # 0xf820
movl $0x162, %esi            # imm = 0x162
movl $0x2, %edx
leaq 0x4c98(%rip), %rcx      # 0xfa57
movb $0x0, %al
callq 0x5dc0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xaebb
jmp 0xadd4
jmp 0xaeb4
cmpl $0x1, -0x14(%rbp)
jne 0xae31
movl -0x18(%rbp), %edi
movl $0x29, %esi
movl $0x12, %edx
leaq -0x20(%rbp), %rcx
movl $0x4, %r8d
callq 0x20a0
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
jne 0xae2f
leaq 0x4a15(%rip), %rdi      # 0xf820
movl $0x16d, %esi            # imm = 0x16D
movl $0x2, %edx
leaq 0x4c54(%rip), %rcx      # 0xfa70
movb $0x0, %al
callq 0x5dc0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xaebb
jmp 0xae80
movl -0x18(%rbp), %edi
movl $0x29, %esi
movl $0x10, %edx
leaq -0x20(%rbp), %rcx
movl $0x4, %r8d
callq 0x20a0
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
jne 0xae7e
leaq 0x49c3(%rip), %rdi      # 0xf820
movl $0x176, %esi            # imm = 0x176
movl $0x2, %edx
leaq 0x4c28(%rip), %rcx      # 0xfa96
movb $0x0, %al
callq 0x5dc0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xaebb
jmp 0xae80
jmp 0xaeb4
leaq 0x4997(%rip), %rdi      # 0xf820
movl $0x17d, %esi            # imm = 0x17D
movl $0x2, %edx
leaq 0x3227(%rip), %rcx      # 0xe0c1
movb $0x0, %al
callq 0x5dc0
movl $0x1, %edi
leaq 0x3214(%rip), %rsi      # 0xe0c1
movb $0x0, %al
callq 0x20d0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop