#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct sockaddr_un {
  int dummy;
};
struct sockaddr_rose {
  int dummy;
};
struct sockaddr_ll {
  int dummy;
};
struct sockaddr_ipx {
  int dummy;
};
struct sockaddr_in6 {
  int dummy;
};
struct sockaddr_in {
  int dummy;
};
struct sockaddr_ec {
  int dummy;
};
struct sockaddr_ax25 {
  int dummy;
};
struct sockaddr_at {
  int dummy;
};
struct sockaddr_ash {
  int dummy;
};
typedef int sa_family_t;

/* Variables and functions */
#define AF_APPLETALK 137
#define AF_ASH 136
#define AF_AX25 135
#define AF_ECONET 134
#define AF_INET 133
#define AF_INET6 132
#define AF_IPX 131
#define AF_LOCAL 130
#define AF_PACKET 129
#define AF_ROSE 128
int __libc_sa_len(sa_family_t af) {
  switch (af) {
  case AF_APPLETALK:
    return sizeof(struct sockaddr_at);
  case AF_ASH:
    return sizeof(struct sockaddr_ash);
  case AF_AX25:
    return sizeof(struct sockaddr_ax25);
  case AF_ECONET:
    return sizeof(struct sockaddr_ec);
  case AF_INET:
    return sizeof(struct sockaddr_in);
  case AF_INET6:
    return sizeof(struct sockaddr_in6);
  case AF_IPX:
    return sizeof(struct sockaddr_ipx);
  case AF_LOCAL:
    return sizeof(struct sockaddr_un);
  case AF_PACKET:
    return sizeof(struct sockaddr_ll);
  case AF_ROSE:
    return sizeof(struct sockaddr_rose);
  }
  return 0;
}


x86 assembly (clang, -O0):
<__libc_sa_len>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x9,%eax
ja     11a8 <__libc_sa_len+0xa8>
mov    -0x10(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x4,-0x4(%rbp)
jmp    11af <__libc_sa_len+0xaf>
movl   $0x4,-0x4(%rbp)
jmp    11af <__libc_sa_len+0xaf>
movl   $0x4,-0x4(%rbp)
jmp    11af <__libc_sa_len+0xaf>
movl   $0x4,-0x4(%rbp)
jmp    11af <__libc_sa_len+0xaf>
movl   $0x4,-0x4(%rbp)
jmp    11af <__libc_sa_len+0xaf>
movl   $0x4,-0x4(%rbp)
jmp    11af <__libc_sa_len+0xaf>
movl   $0x4,-0x4(%rbp)
jmp    11af <__libc_sa_len+0xaf>
movl   $0x4,-0x4(%rbp)
jmp    11af <__libc_sa_len+0xaf>
movl   $0x4,-0x4(%rbp)
jmp    11af <__libc_sa_len+0xaf>
movl   $0x4,-0x4(%rbp)
jmp    11af <__libc_sa_len+0xaf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__libc_sa_len>:
add    $0xffffff80,%edi
xor    %eax,%eax
cmp    $0xa,%edi
setb   %al
shl    $0x2,%eax
ret

LLVM IR (-O0):
define i32 @__libc_sa_len(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %15 [
i32 137, label %5
i32 136, label %6
i32 135, label %7
i32 134, label %8
i32 133, label %9
i32 132, label %10
i32 131, label %11
i32 130, label %12
i32 129, label %13
i32 128, label %14
]
5: ; preds = %1
store i32 4, i32* %2
br label %16
6: ; preds = %1
store i32 4, i32* %2
br label %16
7: ; preds = %1
store i32 4, i32* %2
br label %16
8: ; preds = %1
store i32 4, i32* %2
br label %16
9: ; preds = %1
store i32 4, i32* %2
br label %16
10: ; preds = %1
store i32 4, i32* %2
br label %16
11: ; preds = %1
store i32 4, i32* %2
br label %16
12: ; preds = %1
store i32 4, i32* %2
br label %16
13: ; preds = %1
store i32 4, i32* %2
br label %16
14: ; preds = %1
store i32 4, i32* %2
br label %16
15: ; preds = %1
store i32 0, i32* %2
br label %16
16: ; preds = %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
define i32 @__libc_sa_len(i32 %0) {
%2 = add i32 %0, -128
%3 = icmp ult i32 %2, 10
%4 = select i1 %3, i32 4, i32 0
ret i32 %4
}