#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_6__ TYPE_3__;
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  unsigned char s_addr;
};
struct sockaddr_in {
  TYPE_3__ sin_addr;
  int /*<<< orphan*/ sin_port;
  scalar_t__ sin_family;
};
struct sockaddr {
  scalar_t__ sa_family;
};
struct TYPE_5__ {
  int /*<<< orphan*/ sa_data;
};
struct TYPE_4__ {
  scalar_t__ sa_family;
};
struct ifreq {
  int ifc_len;
  char *ifc_buf;
  char *ifr_name;
  TYPE_2__ ifr_hwaddr;
  TYPE_1__ ifr_addr;
  struct ifreq *ifc_req;
};
struct ifconf {
  int ifc_len;
  char *ifc_buf;
  char *ifr_name;
  TYPE_2__ ifr_hwaddr;
  TYPE_1__ ifr_addr;
  struct ifconf *ifc_req;
};
struct hostent {
  int h_length;
  int /*<<< orphan*/ *h_addr_list;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ saddr;
typedef int /*<<< orphan*/ mac;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
scalar_t__ AF_INET;
int /*<<< orphan*/ SIOCGIFCONF;
int /*<<< orphan*/ SIOCGIFHWADDR;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ errx(int, char *, int /*<<< orphan*/);
struct hostent *gethostbyname(char *);
scalar_t__ getsockname(int, struct sockaddr *, int *);
int /*<<< orphan*/ htons(int);
char *inet_ntoa(TYPE_3__);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct ifreq *);
int /*<<< orphan*/ memcpy(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int socket(scalar_t__, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int main(void) {
  struct sockaddr addr;
  struct sockaddr_in *in, *pn, saddr;
  struct ifreq ifr, *it, *ie;
  struct ifconf ifc;
  struct hostent *ent;
  socklen_t addrlen;
  int sfd;
  char buf[1024];
  unsigned char mac[6];
  sfd = socket(AF_INET, SOCK_STREAM, 0);
  if (sfd < 0)
    errx(1, "socket: %s", strerror(errno));
  ent = gethostbyname("google.com");
  if (ent == NULL)
    errx(1, "gethostbyname: %s", strerror(errno));
  memset(&saddr, 0, sizeof(saddr));
  saddr.sin_family = AF_INET;
  memcpy(&saddr.sin_addr.s_addr, ent->h_addr_list[0], ent->h_length);
  saddr.sin_port = htons(80);
  if (connect(sfd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0)
    errx(1, "connect: %s", strerror(errno));
  addrlen = sizeof(addr);
  if (getsockname(sfd, &addr, &addrlen) < 0)
    errx(1, "getsockname: %s", strerror(errno));
  ifc.ifc_len = sizeof(buf);
  ifc.ifc_buf = buf;
  if (ioctl(sfd, SIOCGIFCONF, &ifc) < 0)
    errx(1, "ioctl: %s", strerror(errno));
  it = ifc.ifc_req;
  ie = it + (ifc.ifc_len / sizeof(struct ifreq));
  assert(addr.sa_family == AF_INET);
  in = (struct sockaddr_in *)&addr;
  for (; it != ie; it++) {
    if (it->ifr_addr.sa_family != AF_INET)
      continue;
    pn = (struct sockaddr_in *)&it->ifr_addr;
    if (pn->sin_addr.s_addr == in->sin_addr.s_addr) {
      strcpy(ifr.ifr_name, it->ifr_name);
      if (ioctl(sfd, SIOCGIFHWADDR, &ifr) != 0)
        continue;
      memcpy(mac, ifr.ifr_hwaddr.sa_data, sizeof(mac));
      printf("%s\n", it->ifr_name);
      printf("%s\n", inet_ntoa(pn->sin_addr));
      printf("%02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3],
             mac[4], mac[5]);
    }
  }
  close(sfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ddf(%rip),%rax
mov    (%rax),%rdi
mov    0x2dbd(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0xb0(%rbp)
cmpl   $0x0,-0xb0(%rbp)
jge    1250 <main+0x60>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %eax,%edx
mov    $0x1,%edi
lea    0xdb5(%rip),%rsi
call   1050 <errx@plt>
lea    0xdb4(%rip),%rdi
call   10b0 <gethostbyname@plt>
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0xa8(%rbp)
jne    1292 <main+0xa2>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %eax,%edx
mov    $0x1,%edi
lea    0xd89(%rip),%rsi
call   1050 <errx@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <memset@plt>
mov    0x2d3f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0xa8(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%esi
mov    -0xa8(%rbp),%rax
mov    (%rax),%edx
call   10d0 <memcpy@plt>
mov    $0x50,%edi
call   1060 <htons@plt>
mov    %eax,-0x2c(%rbp)
mov    -0xb0(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x10,%edx
call   10f0 <connect@plt>
cmp    $0x0,%rax
jge    131b <main+0x12b>
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %eax,%edx
mov    $0x1,%edi
lea    0xd12(%rip),%rsi
call   1050 <errx@plt>
movl   $0x8,-0xac(%rbp)
mov    -0xb0(%rbp),%edi
lea    -0x10(%rbp),%rsi
lea    -0xac(%rbp),%rdx
call   10e0 <getsockname@plt>
cmp    $0x0,%rax
jge    1366 <main+0x176>
mov    0x2c7c(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %eax,%edx
mov    $0x1,%edi
lea    0xcd3(%rip),%rsi
call   1050 <errx@plt>
movl   $0x400,-0xa0(%rbp)
lea    -0x4b0(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0xb0(%rbp),%edi
mov    0x2c35(%rip),%rax
mov    (%rax),%esi
lea    -0xa0(%rbp),%rdx
call   1090 <ioctl@plt>
cmp    $0x0,%rax
jge    13c4 <main+0x1d4>
mov    0x2c1e(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %eax,%edx
mov    $0x1,%edi
lea    0xc85(%rip),%rsi
call   1050 <errx@plt>
mov    -0x78(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x4c0(%rbp)
movslq -0xa0(%rbp),%rax
mov    $0x30,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x4c0(%rbp),%rax
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2be0(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x68(%rbp),%rax
cmp    -0x70(%rbp),%rax
je     153f <main+0x34f>
mov    -0x68(%rbp),%rax
mov    0x20(%rax),%rax
mov    0x2bab(%rip),%rcx
cmp    (%rcx),%rax
je     144b <main+0x25b>
jmp    152e <main+0x33e>
mov    -0x68(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1529 <main+0x339>
mov    -0x50(%rbp),%rdi
mov    -0x68(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <strcpy@plt>
mov    -0xb0(%rbp),%edi
mov    0x2b4d(%rip),%rax
mov    (%rax),%esi
lea    -0x60(%rbp),%rdx
call   1090 <ioctl@plt>
cmp    $0x0,%rax
je     14a5 <main+0x2b5>
jmp    152e <main+0x33e>
lea    -0x4b6(%rbp),%rdi
mov    -0x48(%rbp),%esi
mov    $0x6,%edx
call   10d0 <memcpy@plt>
mov    -0x68(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xb86(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rax
movzbl (%rax),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xb69(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movzbl -0x4b6(%rbp),%esi
movzbl -0x4b5(%rbp),%edx
movzbl -0x4b4(%rbp),%ecx
movzbl -0x4b3(%rbp),%r8d
ff
movzbl -0x4b2(%rbp),%r9d
ff
movzbl -0x4b1(%rbp),%eax
lea    0xb33(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1070 <printf@plt>
jmp    152e <main+0x33e>
mov    -0x68(%rbp),%rax
add    $0x30,%rax
mov    %rax,-0x68(%rbp)
jmp    1420 <main+0x230>
mov    -0xb0(%rbp),%edi
call   10a0 <close@plt>
xor    %eax,%eax
add    $0x4d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x498,%rsp
mov    0x2dd0(%rip),%r15
mov    (%r15),%rdi
mov    0x2dae(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,%r13d
test   %eax,%eax
jns    1253 <main+0x53>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xdb9(%rip),%rsi
mov    $0x1,%edi
mov    %eax,%edx
call   1060 <errx@plt>
lea    0xdb1(%rip),%rdi
call   10c0 <gethostbyname@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1288 <main+0x88>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xd9a(%rip),%rsi
mov    $0x1,%edi
mov    %eax,%edx
call   1060 <errx@plt>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1090 <memset@plt>
mov    (%r15),%rax
mov    %rax,0x28(%rsp)
mov    0x8(%rbx),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
mov    %rbp,%rdi
call   10e0 <memcpy@plt>
mov    $0x50,%edi
call   1070 <htons@plt>
mov    %eax,0x24(%rsp)
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x10,%edx
call   1100 <connect@plt>
test   %rax,%rax
jns    12f8 <main+0xf8>
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xd3c(%rip),%rsi
mov    $0x1,%edi
mov    %eax,%edx
call   1060 <errx@plt>
movl   $0x8,0x14(%rsp)
lea    0x18(%rsp),%rsi
lea    0x14(%rsp),%rdx
mov    %r13d,%edi
call   10f0 <getsockname@plt>
test   %rax,%rax
jns    1338 <main+0x138>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xd08(%rip),%rsi
mov    $0x1,%edi
mov    %eax,%edx
call   1060 <errx@plt>
movl   $0x400,0x30(%rsp)
lea    0x90(%rsp),%rax
mov    %rax,0x38(%rsp)
mov    0x2c6c(%rip),%rax
mov    (%rax),%esi
lea    0x30(%rsp),%rdx
mov    %r13d,%edi
call   10a0 <ioctl@plt>
test   %rax,%rax
jns    1389 <main+0x189>
mov    0x2c59(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xcc7(%rip),%rsi
mov    $0x1,%edi
mov    %eax,%edx
call   1060 <errx@plt>
mov    0x58(%rsp),%r12
movslq 0x30(%rsp),%rbp
movabs $0xaaaaaaaaaaaaaaab,%rcx
aa aa aa
mov    %rbp,%rax
mul    %rcx
mov    %rdx,%rbx
mov    0x18(%rsp),%rax
xor    %edi,%edi
cmp    (%r15),%rax
sete   %dil
call   10d0 <assert@plt>
cmp    $0x30,%rbp
jae    13db <main+0x1db>
mov    %r13d,%edi
call   10b0 <close@plt>
xor    %eax,%eax
add    $0x498,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
shr    $0x5,%rbx
shl    $0x4,%rbx
lea    (%rbx,%rbx,2),%rbx
lea    0x60(%rsp),%r14
xor    %ebp,%ebp
jmp    13f9 <main+0x1f9>
add    $0x30,%rbp
cmp    %rbp,%rbx
je     13bf <main+0x1bf>
mov    0x20(%r12,%rbp,1),%rax
cmp    (%r15),%rax
jne    13f0 <main+0x1f0>
cmp    %al,0x18(%rsp)
jne    13f0 <main+0x1f0>
mov    0x70(%rsp),%rdi
mov    0x10(%r12,%rbp,1),%rsi
call   1030 <strcpy@plt>
mov    0x2bb9(%rip),%rax
mov    (%rax),%esi
mov    %r13d,%edi
mov    %r14,%rdx
call   10a0 <ioctl@plt>
test   %rax,%rax
jne    13f0 <main+0x1f0>
mov    0x78(%rsp),%esi
lea    0xe(%rsp),%rdi
mov    $0x6,%edx
call   10e0 <memcpy@plt>
mov    0x10(%r12,%rbp,1),%rdi
call   1040 <puts@plt>
mov    0x20(%r12,%rbp,1),%edi
call   1050 <inet_ntoa@plt>
mov    %rax,%rdi
call   1040 <puts@plt>
movzbl 0xe(%rsp),%esi
movzbl 0xf(%rsp),%edx
movzbl 0x10(%rsp),%ecx
movzbl 0x11(%rsp),%r8d
movzbl 0x12(%rsp),%r9d
movzbl 0x13(%rsp),%eax
mov    %eax,(%rsp)
lea    0xbc4(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    13f0 <main+0x1f0>

LLVM IR (-O0):
%struct.sockaddr = type { i64 }
%struct.sockaddr_in = type { %struct.TYPE_6__, i32, i64 }
%struct.TYPE_6__ = type { i8 }
%struct.ifreq = type { i32, i8*, i8*, %struct.TYPE_5__, %struct.TYPE_4__, %struct.ifreq* }
%struct.TYPE_5__ = type { i32 }
%struct.TYPE_4__ = type { i64 }
%struct.ifconf = type { i32, i8*, i8*, %struct.TYPE_5__, %struct.TYPE_4__, %struct.ifconf* }
%struct.hostent = type { i32, i32* }
@AF_INET = global i64 0
@SOCK_STREAM = global i32 0
@.str = [11 x i8] c"socket: %s\00"
@errno = global i32 0
@.str.1 = [11 x i8] c"google.com\00"
@.str.2 = [18 x i8] c"gethostbyname: %s\00"
@.str.3 = [12 x i8] c"connect: %s\00"
@.str.4 = [16 x i8] c"getsockname: %s\00"
@SIOCGIFCONF = global i32 0
@.str.5 = [10 x i8] c"ioctl: %s\00"
@SIOCGIFHWADDR = global i32 0
@.str.6 = [4 x i8] c"%s\0A\00"
@.str.7 = [31 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sockaddr
%3 = alloca %struct.sockaddr_in*
%4 = alloca %struct.sockaddr_in*
%5 = alloca %struct.sockaddr_in
%6 = alloca %struct.ifreq
%7 = alloca %struct.ifreq*
%8 = alloca %struct.ifreq*
%9 = alloca %struct.ifconf
%10 = alloca %struct.hostent*
%11 = alloca i32
%12 = alloca i32
%13 = alloca [1024 x i8]
%14 = alloca [6 x i8]
store i32 0, i32* %1
%15 = load i64, i64* @AF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = call i32 @socket(i64 %15, i32 %16, i32 0)
store i32 %17, i32* %12
%18 = load i32, i32* %12
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %0
%21 = load i32, i32* @errno
%22 = call i32 @strerror(i32 %21)
%23 = call i32 @errx(i32 1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %20, %0
%25 = call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store %struct.hostent* %25, %struct.hostent** %10
%26 = load %struct.hostent*, %struct.hostent** %10
%27 = icmp eq %struct.hostent* %26, null
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i32, i32* @errno
%30 = call i32 @strerror(i32 %29)
%31 = call i32 @errx(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %28, %24
%33 = call i32 @memset(%struct.sockaddr_in* %5, i32 0, i32 16)
%34 = load i64, i64* @AF_INET
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 2
store i64 %34, i64* %35
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 0
%37 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %36, i32 0, i32 0
%38 = load %struct.hostent*, %struct.hostent** %10
%39 = getelementptr inbounds %struct.hostent, %struct.hostent* %38, i32 0, i32 1
%40 = load i32*, i32** %39
%41 = getelementptr inbounds i32, i32* %40, i64 0
%42 = load i32, i32* %41
%43 = load %struct.hostent*, %struct.hostent** %10
%44 = getelementptr inbounds %struct.hostent, %struct.hostent* %43, i32 0, i32 0
%45 = load i32, i32* %44
%46 = call i32 @memcpy(i8* %37, i32 %42, i32 %45)
%47 = call i32 @htons(i32 80)
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i32 0, i32 1
store i32 %47, i32* %48
%49 = load i32, i32* %12
%50 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%51 = call i64 @connect(i32 %49, %struct.sockaddr* %50, i32 16)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %32
%54 = load i32, i32* @errno
%55 = call i32 @strerror(i32 %54)
%56 = call i32 @errx(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %53, %32
store i32 8, i32* %11
%58 = load i32, i32* %12
%59 = call i64 @getsockname(i32 %58, %struct.sockaddr* %2, i32* %11)
%60 = icmp slt i64 %59, 0
br i1 %60, label %61, label %65
61: ; preds = %57
%62 = load i32, i32* @errno
%63 = call i32 @strerror(i32 %62)
%64 = call i32 @errx(i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %61, %57
%66 = getelementptr inbounds %struct.ifconf, %struct.ifconf* %9, i32 0, i32 0
store i32 1024, i32* %66
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%68 = getelementptr inbounds %struct.ifconf, %struct.ifconf* %9, i32 0, i32 1
store i8* %67, i8** %68
%69 = load i32, i32* %12
%70 = load i32, i32* @SIOCGIFCONF
%71 = bitcast %struct.ifconf* %9 to %struct.ifreq*
%72 = call i64 @ioctl(i32 %69, i32 %70, %struct.ifreq* %71)
%73 = icmp slt i64 %72, 0
br i1 %73, label %74, label %78
74: ; preds = %65
%75 = load i32, i32* @errno
%76 = call i32 @strerror(i32 %75)
%77 = call i32 @errx(i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %74, %65
%79 = getelementptr inbounds %struct.ifconf, %struct.ifconf* %9, i32 0, i32 5
%80 = load %struct.ifconf*, %struct.ifconf** %79
%81 = bitcast %struct.ifconf* %80 to %struct.ifreq*
store %struct.ifreq* %81, %struct.ifreq** %7
%82 = load %struct.ifreq*, %struct.ifreq** %7
%83 = getelementptr inbounds %struct.ifconf, %struct.ifconf* %9, i32 0, i32 0
%84 = load i32, i32* %83
%85 = sext i32 %84 to i64
%86 = udiv i64 %85, 48
%87 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %82, i64 %86
store %struct.ifreq* %87, %struct.ifreq** %8
%88 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %2, i32 0, i32 0
%89 = load i64, i64* %88
%90 = load i64, i64* @AF_INET
%91 = icmp eq i64 %89, %90
%92 = zext i1 %91 to i32
%93 = call i32 @assert(i32 %92)
%94 = bitcast %struct.sockaddr* %2 to %struct.sockaddr_in*
store %struct.sockaddr_in* %94, %struct.sockaddr_in** %3
br label %95
95: ; preds = %170, %78
%96 = load %struct.ifreq*, %struct.ifreq** %7
%97 = load %struct.ifreq*, %struct.ifreq** %8
%98 = icmp ne %struct.ifreq* %96, %97
br i1 %98, label %99, label %173
99: ; preds = %95
%100 = load %struct.ifreq*, %struct.ifreq** %7
%101 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %100, i32 0, i32 4
%102 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %101, i32 0, i32 0
%103 = load i64, i64* %102
%104 = load i64, i64* @AF_INET
%105 = icmp ne i64 %103, %104
br i1 %105, label %106, label %107
106: ; preds = %99
br label %170
107: ; preds = %99
%108 = load %struct.ifreq*, %struct.ifreq** %7
%109 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %108, i32 0, i32 4
%110 = bitcast %struct.TYPE_4__* %109 to %struct.sockaddr_in*
store %struct.sockaddr_in* %110, %struct.sockaddr_in** %4
%111 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%112 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %111, i32 0, i32 0
%113 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %112, i32 0, i32 0
%114 = load i8, i8* %113
%115 = zext i8 %114 to i32
%116 = load %struct.sockaddr_in*, %struct.sockaddr_in** %3
%117 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %116, i32 0, i32 0
%118 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %117, i32 0, i32 0
%119 = load i8, i8* %118
%120 = zext i8 %119 to i32
%121 = icmp eq i32 %115, %120
br i1 %121, label %122, label %169
122: ; preds = %107
%123 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %6, i32 0, i32 2
%124 = load i8*, i8** %123
%125 = load %struct.ifreq*, %struct.ifreq** %7
%126 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %125, i32 0, i32 2
%127 = load i8*, i8** %126
%128 = call i32 @strcpy(i8* %124, i8* %127)
%129 = load i32, i32* %12
%130 = load i32, i32* @SIOCGIFHWADDR
%131 = call i64 @ioctl(i32 %129, i32 %130, %struct.ifreq* %6)
%132 = icmp ne i64 %131, 0
br i1 %132, label %133, label %134
133: ; preds = %122
br label %170
134: ; preds = %122
%135 = getelementptr inbounds [6 x i8], [6 x i8]* %14, i64 0, i64 0
%136 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %6, i32 0, i32 3
%137 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %136, i32 0, i32 0
%138 = load i32, i32* %137
%139 = call i32 @memcpy(i8* %135, i32 %138, i32 6)
%140 = load %struct.ifreq*, %struct.ifreq** %7
%141 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %140, i32 0, i32 2
%142 = load i8*, i8** %141
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %142)
%144 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%145 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %144, i32 0, i32 0
%146 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %145, i32 0, i32 0
%147 = load i8, i8* %146
%148 = call i8* @inet_ntoa(i8 %147)
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %148)
%150 = getelementptr inbounds [6 x i8], [6 x i8]* %14, i64 0, i64 0
%151 = load i8, i8* %150
%152 = zext i8 %151 to i32
%153 = getelementptr inbounds [6 x i8], [6 x i8]* %14, i64 0, i64 1
%154 = load i8, i8* %153
%155 = zext i8 %154 to i32
%156 = getelementptr inbounds [6 x i8], [6 x i8]* %14, i64 0, i64 2
%157 = load i8, i8* %156
%158 = zext i8 %157 to i32
%159 = getelementptr inbounds [6 x i8], [6 x i8]* %14, i64 0, i64 3
%160 = load i8, i8* %159
%161 = zext i8 %160 to i32
%162 = getelementptr inbounds [6 x i8], [6 x i8]* %14, i64 0, i64 4
%163 = load i8, i8* %162
%164 = zext i8 %163 to i32
%165 = getelementptr inbounds [6 x i8], [6 x i8]* %14, i64 0, i64 5
%166 = load i8, i8* %165
%167 = zext i8 %166 to i32
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %152, i32 %155, i32 %158, i32 %161, i32 %164, i32 %167)
br label %169
169: ; preds = %134, %107
br label %170
170: ; preds = %169, %133, %106
%171 = load %struct.ifreq*, %struct.ifreq** %7
%172 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %171, i32 1
store %struct.ifreq* %172, %struct.ifreq** %7
br label %95
173: ; preds = %95
%174 = load i32, i32* %12
%175 = call i32 @close(i32 %174)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr = type { i64 }
%struct.sockaddr_in = type { %struct.TYPE_6__, i32, i64 }
%struct.TYPE_6__ = type { i8 }
%struct.ifreq = type { i32, i8*, i8*, %struct.TYPE_5__, %struct.TYPE_4__, %struct.ifreq* }
%struct.TYPE_5__ = type { i32 }
%struct.TYPE_4__ = type { i64 }
%struct.ifconf = type { i32, i8*, i8*, %struct.TYPE_5__, %struct.TYPE_4__, %struct.ifconf* }
%struct.hostent = type { i32, i32* }
@AF_INET = global i64 0
@SOCK_STREAM = global i32 0
@.str = [11 x i8] c"socket: %s\00"
@errno = global i32 0
@.str.1 = [11 x i8] c"google.com\00"
@.str.2 = [18 x i8] c"gethostbyname: %s\00"
@.str.3 = [12 x i8] c"connect: %s\00"
@.str.4 = [16 x i8] c"getsockname: %s\00"
@SIOCGIFCONF = global i32 0
@.str.5 = [10 x i8] c"ioctl: %s\00"
@SIOCGIFHWADDR = global i32 0
@.str.7 = [31 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x\0A\00"
define i32 @main() {
%1 = alloca %struct.sockaddr
%2 = alloca %struct.sockaddr_in
%3 = alloca %struct.ifreq
%4 = alloca %struct.ifconf
%5 = alloca i32
%6 = alloca [1024 x i8]
%7 = alloca [6 x i8]
%8 = bitcast %struct.sockaddr* %1 to i8*
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0, i32 0
%10 = bitcast %struct.ifreq* %3 to i8*
%11 = bitcast %struct.ifconf* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%15 = load i64, i64* @AF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = tail call i32 @socket(i64 %15, i32 %16, i32 0)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %0
%20 = load i32, i32* @errno
%21 = tail call i32 @strerror(i32 %20)
%22 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %19, %0
%24 = tail call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq %struct.hostent* %24, null
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* @errno
%28 = tail call i32 @strerror(i32 %27)
%29 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %26, %23
%31 = call i32 @memset(%struct.sockaddr_in* %2, i32 0, i32 16)
%32 = load i64, i64* @AF_INET
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i64 %32, i64* %33
%34 = getelementptr inbounds %struct.hostent, %struct.hostent* %24, i64 0, i32 1
%35 = load i32*, i32** %34
%36 = load i32, i32* %35
%37 = getelementptr inbounds %struct.hostent, %struct.hostent* %24, i64 0, i32 0
%38 = load i32, i32* %37
%39 = call i32 @memcpy(i8* %9, i32 %36, i32 %38)
%40 = call i32 @htons(i32 80)
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
store i32 %40, i32* %41
%42 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%43 = call i64 @connect(i32 %17, %struct.sockaddr* %42, i32 16)
%44 = icmp slt i64 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %30
%46 = load i32, i32* @errno
%47 = call i32 @strerror(i32 %46)
%48 = call i32 @errx(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %45, %30
store i32 8, i32* %5
%50 = call i64 @getsockname(i32 %17, %struct.sockaddr* %1, i32* %5)
%51 = icmp slt i64 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %49
%53 = load i32, i32* @errno
%54 = call i32 @strerror(i32 %53)
%55 = call i32 @errx(i32 1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %52, %49
%57 = getelementptr inbounds %struct.ifconf, %struct.ifconf* %4, i64 0, i32 0
store i32 1024, i32* %57
%58 = getelementptr inbounds %struct.ifconf, %struct.ifconf* %4, i64 0, i32 1
store i8* %13, i8** %58
%59 = load i32, i32* @SIOCGIFCONF
%60 = bitcast %struct.ifconf* %4 to %struct.ifreq*
%61 = call i64 @ioctl(i32 %17, i32 %59, %struct.ifreq* %60)
%62 = icmp slt i64 %61, 0
br i1 %62, label %63, label %67
63: ; preds = %56
%64 = load i32, i32* @errno
%65 = call i32 @strerror(i32 %64)
%66 = call i32 @errx(i32 1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %65)
br label %67
67: ; preds = %63, %56
%68 = getelementptr inbounds %struct.ifconf, %struct.ifconf* %4, i64 0, i32 5
%69 = bitcast %struct.ifconf** %68 to %struct.ifreq**
%70 = load %struct.ifreq*, %struct.ifreq** %69
%71 = load i32, i32* %57
%72 = sext i32 %71 to i64
%73 = udiv i64 %72, 48
%74 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %70, i64 %73
%75 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %1, i64 0, i32 0
%76 = load i64, i64* %75
%77 = load i64, i64* @AF_INET
%78 = icmp eq i64 %76, %77
%79 = zext i1 %78 to i32
%80 = call i32 @assert(i32 %79)
%81 = icmp ult i32 %71, 48
br i1 %81, label %134, label %82
82: ; preds = %67
%83 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %3, i64 0, i32 2
%84 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %3, i64 0, i32 3, i32 0
%85 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 1
%86 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 2
%87 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 3
%88 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 4
%89 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 5
br label %90
90: ; preds = %82, %131
%91 = phi %struct.ifreq* [ %70, %82 ], [ %132, %131 ]
%92 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %91, i64 0, i32 4
%93 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %92, i64 0, i32 0
%94 = load i64, i64* %93
%95 = load i64, i64* @AF_INET
%96 = icmp eq i64 %94, %95
br i1 %96, label %97, label %131
97: ; preds = %90
%98 = trunc i64 %94 to i8
%99 = bitcast %struct.TYPE_4__* %92 to i8*
%100 = load i8, i8* %8
%101 = icmp eq i8 %100, %98
br i1 %101, label %102, label %131
102: ; preds = %97
%103 = load i8*, i8** %83
%104 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %91, i64 0, i32 2
%105 = load i8*, i8** %104
%106 = call i32 @strcpy(i8* %103, i8* %105)
%107 = load i32, i32* @SIOCGIFHWADDR
%108 = call i64 @ioctl(i32 %17, i32 %107, %struct.ifreq* %3)
%109 = icmp eq i64 %108, 0
br i1 %109, label %110, label %131
110: ; preds = %102
%111 = load i32, i32* %84
%112 = call i32 @memcpy(i8* %14, i32 %111, i32 6)
%113 = load i8*, i8** %104
%114 = call i32 @puts(i8* dereferenceable(1) %113)
%115 = load i8, i8* %99
%116 = call i8* @inet_ntoa(i8 %115)
%117 = call i32 @puts(i8* dereferenceable(1) %116)
%118 = load i8, i8* %14
%119 = zext i8 %118 to i32
%120 = load i8, i8* %85
%121 = zext i8 %120 to i32
%122 = load i8, i8* %86
%123 = zext i8 %122 to i32
%124 = load i8, i8* %87
%125 = zext i8 %124 to i32
%126 = load i8, i8* %88
%127 = zext i8 %126 to i32
%128 = load i8, i8* %89
%129 = zext i8 %128 to i32
%130 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %119, i32 %121, i32 %123, i32 %125, i32 %127, i32 %129)
br label %131
131: ; preds = %97, %110, %102, %90
%132 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %91, i64 1
%133 = icmp eq %struct.ifreq* %132, %74
br i1 %133, label %134, label %90
134: ; preds = %131, %67
%135 = call i32 @close(i32 %17)
ret i32 0
}