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

/* Variables and functions */
scalar_t__ AF_INET;
scalar_t__ AF_INET6;
socklen_t sockaddr_storage_size(struct sockaddr_storage *storage) {
  if (storage->ss_family == AF_INET) {
    return sizeof(struct sockaddr_in);
  } else if (storage->ss_family == AF_INET6) {
    return sizeof(struct sockaddr_in6);
  }
  return 0;
}


x86 assembly (clang, -O0):
<sockaddr_storage_size>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2ed2(%rip),%rcx
cmp    (%rcx),%rax
jne    112b <sockaddr_storage_size+0x2b>
movl   $0x4,-0x4(%rbp)
jmp    115a <sockaddr_storage_size+0x5a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2ea7(%rip),%rcx
cmp    (%rcx),%rax
jne    114e <sockaddr_storage_size+0x4e>
movl   $0x4,-0x4(%rbp)
jmp    115a <sockaddr_storage_size+0x5a>
jmp    1153 <sockaddr_storage_size+0x53>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sockaddr_storage_size>:
mov    (%rdi),%rax
mov    0x2ede(%rip),%rcx
cmp    (%rcx),%rax
sete   %cl
mov    0x2ec9(%rip),%rdx
cmp    (%rdx),%rax
sete   %al
or     %cl,%al
movzbl %al,%eax
shl    $0x2,%eax
ret

LLVM IR (-O0):
%struct.sockaddr_storage = type { i64 }
@AF_INET = global i64 0
@AF_INET6 = global i64 0
define i32 @sockaddr_storage_size(%struct.sockaddr_storage* %0) {
%2 = alloca i32
%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 i64, i64* %5
%7 = load i64, i64* @AF_INET
%8 = icmp eq i64 %6, %7
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 4, i32* %2
br label %19
10: ; preds = %1
%11 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %3
%12 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %11, i32 0, i32 0
%13 = load i64, i64* %12
%14 = load i64, i64* @AF_INET6
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %10
store i32 4, i32* %2
br label %19
17: ; preds = %10
br label %18
18: ; preds = %17
store i32 0, i32* %2
br label %19
19: ; preds = %18, %16, %9
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i64 }
@AF_INET = global i64 0
@AF_INET6 = global i64 0
define i32 @sockaddr_storage_size(%struct.sockaddr_storage* nocapture %0) {
%2 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %0, i64 0, i32 0
%3 = load i64, i64* %2
%4 = load i64, i64* @AF_INET
%5 = icmp eq i64 %3, %4
%6 = load i64, i64* @AF_INET6
%7 = icmp eq i64 %3, %6
%8 = select i1 %5, i1 true, i1 %7
%9 = select i1 %8, i32 4, i32 0
ret i32 %9
}