#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 s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ inet_aton(char *, TYPE_1__ *);
int /*<<< orphan*/ stderr;
int ip_mkip(char *ip) {
  struct sockaddr_in temp;
  if (inet_aton(ip, &temp.sin_addr) == 0) {
    fprintf(stderr, "inet_aton: failed\n");
    exit(1);
  }
  return temp.sin_addr.s_addr;
}


x86 assembly (clang, -O0):
<ip_mkip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <inet_aton@plt>
cmp    $0x0,%rax
jne    1172 <ip_mkip+0x42>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ip_mkip>:
push   %rax
mov    %rsp,%rsi
call   1040 <inet_aton@plt>
test   %rax,%rax
je     1143 <ip_mkip+0x13>
mov    (%rsp),%eax
pop    %rcx
ret
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
lea    0xead(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@stderr = global i32 0
@.str = [19 x i8] c"inet_aton: failed\0A\00"
define i32 @ip_mkip(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.sockaddr_in
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%6 = call i64 @inet_aton(i8* %4, %struct.TYPE_2__* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %1
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, 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_in = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@stderr = global i32 0
@.str = [19 x i8] c"inet_aton: failed\0A\00"
define i32 @ip_mkip(i8* %0) {
%2 = alloca %struct.sockaddr_in
%3 = bitcast %struct.sockaddr_in* %2 to i8*
%4 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
%5 = call i64 @inet_aton(i8* %0, %struct.TYPE_2__* %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %1
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0, i32 0
%13 = load i32, i32* %12
ret i32 %13
}