#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 */

/* Variables and functions */
int /*<<< orphan*/ ipv4(char *, char *);
int /*<<< orphan*/ ipv6(char *, char *);
int /*<<< orphan*/ printf(char *);
int netstat_main(int argc, char *argv[]) {
  printf("Proto Recv-Q Send-Q Local Address          Foreign Address        "
         "State\n");
  ipv4("/proc/net/tcp", "tcp");
  ipv4("/proc/net/udp", "udp");
  ipv6("/proc/net/tcp6", "tcp6");
  ipv6("/proc/net/udp6", "udp6");
  return 0;
}


x86 assembly (clang, -O0):
<netstat_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
lea    0xefa(%rip),%rsi
call   1040 <ipv4@plt>
lea    0xef2(%rip),%rdi
lea    0xef5(%rip),%rsi
call   1040 <ipv4@plt>
lea    0xeed(%rip),%rdi
lea    0xef0(%rip),%rsi
call   1050 <ipv6@plt>
lea    0xee9(%rip),%rdi
lea    0xeec(%rip),%rsi
call   1050 <ipv6@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<netstat_main>:
push   %rax
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0xebf(%rip),%rsi
call   1040 <ipv4@plt>
lea    0xeb7(%rip),%rdi
lea    0xeba(%rip),%rsi
call   1040 <ipv4@plt>
lea    0xeb2(%rip),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <ipv6@plt>
lea    0xeae(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1050 <ipv6@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [73 x i8] c"Proto Recv-Q Send-Q Local Address Foreign Address State\0A\00"
@.str.1 = [14 x i8] c"/proc/net/tcp\00"
@.str.2 = [4 x i8] c"tcp\00"
@.str.3 = [14 x i8] c"/proc/net/udp\00"
@.str.4 = [4 x i8] c"udp\00"
@.str.5 = [15 x i8] c"/proc/net/tcp6\00"
@.str.6 = [5 x i8] c"tcp6\00"
@.str.7 = [15 x i8] c"/proc/net/udp6\00"
@.str.8 = [5 x i8] c"udp6\00"
define i32 @netstat_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
store i32 %0, i32* %3
store i8** %1, i8*** %4
%5 = call i32 @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @ipv4(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @ipv4(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @ipv6(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%9 = call i32 @ipv6(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"/proc/net/tcp\00"
@.str.2 = [4 x i8] c"tcp\00"
@.str.3 = [14 x i8] c"/proc/net/udp\00"
@.str.4 = [4 x i8] c"udp\00"
@.str.5 = [15 x i8] c"/proc/net/tcp6\00"
@.str.6 = [5 x i8] c"tcp6\00"
@.str.7 = [15 x i8] c"/proc/net/udp6\00"
@.str.8 = [5 x i8] c"udp6\00"
@str = [72 x i8] c"Proto Recv-Q Send-Q Local Address Foreign Address State\00"
define i32 @netstat_main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @ipv4(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @ipv4(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%6 = tail call i32 @ipv6(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%7 = tail call i32 @ipv6(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}