#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;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ inet_aton(char *, struct in_addr *);
char *inet_ntoa(struct in_addr);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int main() {
  struct in_addr addr;
  char *ip = "127.0.0.1";
  if (inet_aton(ip, &addr) == 0) {
    fprintf(stderr, "Invalid address\n");
    exit(EXIT_FAILURE);
  }
  printf("%s\n", inet_ntoa(addr));
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <inet_aton@plt>
cmp    $0x0,%rax
jne    11a4 <main+0x54>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0xe79(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xea8(%rip),%rdi
mov    %rsp,%rsi
call   1060 <inet_aton@plt>
test   %rax,%rax
jne    1188 <main+0x38>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    (%rsp),%edi
call   1030 <inet_ntoa@plt>
lea    0xe84(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@.str = [10 x i8] c"127.0.0.1\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"Invalid address\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.in_addr
%3 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @inet_aton(i8* %4, %struct.in_addr* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %2, i32 0, i32 0
%14 = load i32, i32* %13
%15 = call i8* @inet_ntoa(i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_SUCCESS
%18 = call i32 @exit(i32 %17)
unreachable
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
@.str = [10 x i8] c"127.0.0.1\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"Invalid address\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca %struct.in_addr
%2 = bitcast %struct.in_addr* %1 to i8*
%3 = call i64 @inet_aton(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %struct.in_addr* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = call i32 @exit(i32 %8)
unreachable
10: ; preds = %0
%11 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %1, i64 0, i32 0
%12 = load i32, i32* %11
%13 = call i8* @inet_ntoa(i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_SUCCESS
%16 = call i32 @exit(i32 %15)
unreachable
}