#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 in_addr {
  int dummy;
};
struct sockaddr_in {
  struct in_addr sin_addr;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ __ipparse(struct sockaddr_in *, int /*<<< orphan*/, char const *);
int inet_aton(const char *cp, struct in_addr *inp) {
  struct sockaddr_in sin;
  if (__ipparse(&sin, AF_INET, cp) < 0)
    return 0;
  *inp = sin.sin_addr;
  return 1;
}


x86 assembly (clang, -O0):
<inet_aton>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2ec1(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
lea    -0x20(%rbp),%rdi
call   1030 <__ipparse@plt>
cmp    $0x0,%rax
jge    114c <inet_aton+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    115c <inet_aton+0x4c>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_aton>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%rdx
mov    0x2ec6(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdi
call   1030 <__ipparse@plt>
test   %rax,%rax
js     1140 <inet_aton+0x30>
mov    0x8(%rsp),%eax
mov    %eax,(%rbx)
mov    $0x1,%eax
jmp    1142 <inet_aton+0x32>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.in_addr = type { i32 }
%struct.sockaddr_in = type { %struct.in_addr }
@AF_INET = global i32 0
define i32 @inet_aton(i8* %0, %struct.in_addr* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.in_addr*
%6 = alloca %struct.sockaddr_in
store i8* %0, i8** %4
store %struct.in_addr* %1, %struct.in_addr** %5
%7 = load i32, i32* @AF_INET
%8 = load i8*, i8** %4
%9 = call i64 @__ipparse(%struct.sockaddr_in* %6, i32 %7, i8* %8)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %17
12: ; preds = %2
%13 = load %struct.in_addr*, %struct.in_addr** %5
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%15 = bitcast %struct.in_addr* %13 to i8*
%16 = bitcast %struct.in_addr* %14 to i8*
store i32 1, i32* %3
br label %17
17: ; preds = %12, %11
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
%struct.sockaddr_in = type { %struct.in_addr }
@AF_INET = global i32 0
define i32 @inet_aton(i8* %0, %struct.in_addr* nocapture writeonly %1) {
%3 = alloca %struct.sockaddr_in
%4 = bitcast %struct.sockaddr_in* %3 to i8*
%5 = load i32, i32* @AF_INET
%6 = call i64 @__ipparse(%struct.sockaddr_in* %3, i32 %5, i8* %0)
%7 = icmp slt i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
%10 = getelementptr %struct.in_addr, %struct.in_addr* %1, i64 0, i32 0
%11 = load i32, i32* %9
store i32 %11, i32* %10
br label %12
12: ; preds = %2, %8
%13 = phi i32 [ 1, %8 ], [ 0, %2 ]
ret i32 %13
}