#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
};
struct sockaddr {
  scalar_t__ sa_family;
};
typedef int /*<<< orphan*/ in_addr_t;

/* Variables and functions */
scalar_t__ AF_INET;
int /*<<< orphan*/ exitFatal(char *, int);
in_addr_t sockaddrToInet4(struct sockaddr const *addr) {
  if (addr->sa_family != AF_INET)
    exitFatal("Interface has not IPv4 address",
              sizeof("Interface has not IPv4 address") - 1);
  return (((struct sockaddr_in const *)(addr)))->sin_addr.s_addr;
}


x86 assembly (clang, -O0):
<sockaddrToInet4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x2ebe(%rip),%rcx
cmp    (%rcx),%rax
je     1144 <sockaddrToInet4+0x34>
lea    0xec6(%rip),%rdi
mov    $0x1e,%esi
call   1030 <exitFatal@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sockaddrToInet4>:
push   %rbx
mov    (%rdi),%rax
mov    0x2ecd(%rip),%rcx
cmp    (%rcx),%rax
je     1136 <sockaddrToInet4+0x26>
mov    %rdi,%rbx
lea    0xed6(%rip),%rdi
mov    $0x1e,%esi
call   1030 <exitFatal@plt>
mov    (%rbx),%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.sockaddr = type { i64 }
%struct.sockaddr_in = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i64 0
@.str = [31 x i8] c"Interface has not IPv4 address\00"
define i32 @sockaddrToInet4(%struct.sockaddr* %0) {
%2 = alloca %struct.sockaddr*
store %struct.sockaddr* %0, %struct.sockaddr** %2
%3 = load %struct.sockaddr*, %struct.sockaddr** %2
%4 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %3, i32 0, i32 0
%5 = load i64, i64* %4
%6 = load i64, i64* @AF_INET
%7 = icmp ne i64 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @exitFatal(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 30)
br label %10
10: ; preds = %8, %1
%11 = load %struct.sockaddr*, %struct.sockaddr** %2
%12 = bitcast %struct.sockaddr* %11 to %struct.sockaddr_in*
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
%14 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %13, i32 0, i32 0
%15 = load i32, i32* %14
ret i32 %15
}

LLVM IR (-O2):
%struct.sockaddr = type { i64 }
@AF_INET = global i64 0
@.str = [31 x i8] c"Interface has not IPv4 address\00"
define i32 @sockaddrToInet4(%struct.sockaddr* nocapture %0) {
%2 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %0, i64 0, i32 0
%3 = load i64, i64* %2
%4 = load i64, i64* @AF_INET
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = trunc i64 %3 to i32
br label %12
8: ; preds = %1
%9 = tail call i32 @exitFatal(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 30)
%10 = bitcast %struct.sockaddr* %0 to i32*
%11 = load i32, i32* %10
br label %12
12: ; preds = %6, %8
%13 = phi i32 [ %11, %8 ], [ %7, %6 ]
ret i32 %13
}