#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_in {
  int /*<<< orphan*/ sin_addr;
};
struct sockaddr {
  scalar_t__ sa_family;
};
typedef int /*<<< orphan*/ socklen_t;

/* Variables and functions */
scalar_t__ AF_INET;
char const *inet_ntop(scalar_t__, int /*<<< orphan*/ *, char *,
                      int /*<<< orphan*/);
const char *sockinet_ntop(struct sockaddr *addr, char *dst, socklen_t dstLen) {
  if (addr->sa_family == AF_INET) {
    return inet_ntop(AF_INET, &((struct sockaddr_in *)addr)->sin_addr, dst,
                     dstLen);
  }
  return "UnknownAddressFamily";
}


x86 assembly (clang, -O0):
<sockinet_ntop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2eb7(%rip),%rcx
cmp    (%rcx),%rax
jne    115d <sockinet_ntop+0x4d>
mov    0x2ea7(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1030 <inet_ntop@plt>
mov    %rax,-0x8(%rbp)
jmp    1168 <sockinet_ntop+0x58>
lea    0xe9c(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sockinet_ntop>:
mov    %edx,%ecx
mov    %rsi,%rdx
mov    %rdi,%rsi
mov    (%rdi),%rdi
mov    0x2ec6(%rip),%rax
cmp    (%rax),%rdi
jne    112c <sockinet_ntop+0x1c>
jmp    1030 <inet_ntop@plt>
lea    0xecd(%rip),%rax
ret

LLVM IR (-O0):
%struct.sockaddr = type { i64 }
%struct.sockaddr_in = type { i32 }
@AF_INET = global i64 0
@.str = [21 x i8] c"UnknownAddressFamily\00"
define i8* @sockinet_ntop(%struct.sockaddr* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca %struct.sockaddr*
%6 = alloca i8*
%7 = alloca i32
store %struct.sockaddr* %0, %struct.sockaddr** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load %struct.sockaddr*, %struct.sockaddr** %5
%9 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %8, i32 0, i32 0
%10 = load i64, i64* %9
%11 = load i64, i64* @AF_INET
%12 = icmp eq i64 %10, %11
br i1 %12, label %13, label %21
13: ; preds = %3
%14 = load i64, i64* @AF_INET
%15 = load %struct.sockaddr*, %struct.sockaddr** %5
%16 = bitcast %struct.sockaddr* %15 to %struct.sockaddr_in*
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 0
%18 = load i8*, i8** %6
%19 = load i32, i32* %7
%20 = call i8* @inet_ntop(i64 %14, i32* %17, i8* %18, i32 %19)
store i8* %20, i8** %4
br label %22
21: ; preds = %3
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %4
br label %22
22: ; preds = %21, %13
%23 = load i8*, i8** %4
ret i8* %23
}

LLVM IR (-O2):
%struct.sockaddr = type { i64 }
@AF_INET = global i64 0
@.str = [21 x i8] c"UnknownAddressFamily\00"
define i8* @sockinet_ntop(%struct.sockaddr* %0, i8* %1, i32 %2) {
%4 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %0, i64 0, i32 0
%5 = load i64, i64* %4
%6 = load i64, i64* @AF_INET
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = bitcast %struct.sockaddr* %0 to i32*
%10 = tail call i8* @inet_ntop(i64 %5, i32* %9, i8* %1, i32 %2)
br label %11
11: ; preds = %3, %8
%12 = phi i8* [ %10, %8 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), %3 ]
ret i8* %12
}