#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 {
  void *s_addr;
};
typedef void *in_addr_t;

/* Variables and functions */
int /*<<< orphan*/ inet_aton(char *, struct in_addr *);
void *inet_lnaof(struct in_addr);
void *inet_netof(struct in_addr);
char *inet_ntoa(struct in_addr);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char *ip = "10.18.17.3";
  struct in_addr addr;
  in_addr_t net;
  in_addr_t host;
  struct in_addr tmp;
  inet_aton(ip, &addr);
  net = inet_lnaof(addr);
  host = inet_netof(addr);
  tmp.s_addr = net;
  printf("%s\n", inet_ntoa(tmp));
  tmp.s_addr = host;
  printf("%s\n", inet_ntoa(tmp));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <inet_aton@plt>
mov    -0x18(%rbp),%rdi
call   1050 <inet_lnaof@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <inet_netof@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rdi
mov    %rsp,%rsi
call   1060 <inet_aton@plt>
mov    (%rsp),%rdi
call   1050 <inet_lnaof@plt>
mov    %rax,%rbx
mov    (%rsp),%rdi
call   1070 <inet_netof@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <inet_ntoa@plt>
lea    0xe81(%rip),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <inet_ntoa@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.in_addr = type { i8* }
@.str = [11 x i8] c"10.18.17.3\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca %struct.in_addr
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.in_addr
store i32 0, i32* %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @inet_aton(i8* %7, %struct.in_addr* %3)
%9 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
%10 = load i8*, i8** %9
%11 = call i8* @inet_lnaof(i8* %10)
store i8* %11, i8** %4
%12 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
%13 = load i8*, i8** %12
%14 = call i8* @inet_netof(i8* %13)
store i8* %14, i8** %5
%15 = load i8*, i8** %4
%16 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
store i8* %15, i8** %16
%17 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
%18 = load i8*, i8** %17
%19 = call i8* @inet_ntoa(i8* %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %5
%22 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
store i8* %21, i8** %22
%23 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i32 0, i32 0
%24 = load i8*, i8** %23
%25 = call i8* @inet_ntoa(i8* %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %25)
ret i32 0
}

LLVM IR (-O2):
%struct.in_addr = type { i8* }
@.str = [11 x i8] c"10.18.17.3\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca %struct.in_addr
%2 = bitcast %struct.in_addr* %1 to i8*
%3 = call i32 @inet_aton(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %struct.in_addr* %1)
%4 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %1, i64 0, i32 0
%5 = load i8*, i8** %4
%6 = call i8* @inet_lnaof(i8* %5)
%7 = load i8*, i8** %4
%8 = call i8* @inet_netof(i8* %7)
%9 = call i8* @inet_ntoa(i8* %6)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = call i8* @inet_ntoa(i8* %8)
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
ret i32 0
}