#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_storage {
  int ss_family;
};
struct sockaddr_in6 {
  int dummy;
};
struct sockaddr_in {
  int dummy;
};

/* Variables and functions */
#define AF_INET 130
#define AF_INET6 129
#define AF_UNIX 128
int /*<<< orphan*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
size_t addrsize(const struct sockaddr_storage *ss) {
  switch (ss->ss_family) {
  case AF_INET:
    return sizeof(struct sockaddr_in);
  case AF_INET6:
    return sizeof(struct sockaddr_in6);
  case AF_UNIX:
    return sizeof(struct sockaddr_un);
  }
  fprintf(stderr, "addrsize: unknown address family %d\n", ss->ss_family);
  abort();
}


x86 assembly (clang, -O0):
<addrsize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0x80,%eax
je     1185 <addrsize+0x65>
jmp    1145 <addrsize+0x25>
mov    -0x14(%rbp),%eax
sub    $0x81,%eax
je     1178 <addrsize+0x58>
jmp    1158 <addrsize+0x38>
mov    -0x14(%rbp),%eax
sub    $0x82,%eax
jne    1192 <addrsize+0x72>
jmp    116b <addrsize+0x4b>
movq   $0x4,-0x8(%rbp)
jmp    11b4 <addrsize+0x94>
movq   $0x4,-0x8(%rbp)
jmp    11b4 <addrsize+0x94>
movq   $0x4,-0x8(%rbp)
jmp    11b4 <addrsize+0x94>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xe58(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addrsize>:
push   %rax
mov    (%rdi),%edx
lea    -0x80(%rdx),%eax
cmp    $0x3,%eax
jae    1132 <addrsize+0x12>
mov    $0x4,%eax
pop    %rcx
ret
mov    0x2ea7(%rip),%rax
mov    (%rax),%edi
lea    0xebe(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
@stderr = global i32 0
@.str = [37 x i8] c"addrsize: unknown address family %d\0A\00"
define i64 @addrsize(%struct.sockaddr_storage* %0) {
%2 = alloca i64
%3 = alloca %struct.sockaddr_storage*
store %struct.sockaddr_storage* %0, %struct.sockaddr_storage** %3
%4 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %3
%5 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %4, i32 0, i32 0
%6 = load i32, i32* %5
switch i32 %6, label %10 [
i32 130, label %7
i32 129, label %8
i32 128, label %9
]
7: ; preds = %1
store i64 4, i64* %2
br label %17
8: ; preds = %1
store i64 4, i64* %2
br label %17
9: ; preds = %1
store i64 4, i64* %2
br label %17
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %3
%13 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = call i32 (...) @abort()
unreachable
17: ; preds = %9, %8, %7
%18 = load i64, i64* %2
ret i64 %18
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
@stderr = global i32 0
@.str = [37 x i8] c"addrsize: unknown address family %d\0A\00"
define i64 @addrsize(%struct.sockaddr_storage* nocapture %0) {
%2 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = add i32 %3, -128
%5 = icmp ult i32 %4, 3
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %3)
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %1
ret i64 4
}