#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 ip {
  int /*<<< orphan*/ ip_src;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ INET_ADDRSTRLEN;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/ *, char *,
                     int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
void get_ip_src_addr(struct ip *self, char *val) {
  if (inet_ntop(AF_INET, &(self->ip_src), val, INET_ADDRSTRLEN)) {
    perror("inet_pton()");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<get_ip_src_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    0x2e80(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
cmp    $0x0,%rax
je     1183 <get_ip_src_addr+0x53>
lea    0xe90(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_ip_src_addr>:
push   %rax
mov    %rsi,%rdx
mov    %rdi,%rsi
mov    0x2eaa(%rip),%rax
mov    (%rax),%edi
mov    0x2e91(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
test   %rax,%rax
jne    1155 <get_ip_src_addr+0x25>
pop    %rax
ret
lea    0xea4(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.ip = type { i32 }
@AF_INET = global i32 0
@INET_ADDRSTRLEN = global i32 0
@.str = [12 x i8] c"inet_pton()\00"
@EXIT_FAILURE = global i32 0
define void @get_ip_src_addr(%struct.ip* %0, i8* %1) {
%3 = alloca %struct.ip*
%4 = alloca i8*
store %struct.ip* %0, %struct.ip** %3
store i8* %1, i8** %4
%5 = load i32, i32* @AF_INET
%6 = load %struct.ip*, %struct.ip** %3
%7 = getelementptr inbounds %struct.ip, %struct.ip* %6, i32 0, i32 0
%8 = load i8*, i8** %4
%9 = load i32, i32* @INET_ADDRSTRLEN
%10 = call i64 @inet_ntop(i32 %5, i32* %7, i8* %8, i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
ret void
}

LLVM IR (-O2):
%struct.ip = type { i32 }
@AF_INET = global i32 0
@INET_ADDRSTRLEN = global i32 0
@.str = [12 x i8] c"inet_pton()\00"
@EXIT_FAILURE = global i32 0
define void @get_ip_src_addr(%struct.ip* %0, i8* %1) {
%3 = load i32, i32* @AF_INET
%4 = getelementptr inbounds %struct.ip, %struct.ip* %0, i64 0, i32 0
%5 = load i32, i32* @INET_ADDRSTRLEN
%6 = tail call i64 @inet_ntop(i32 %3, i32* %4, i8* %1, i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
ret void
}