#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 sockaddr_in {
  int /*<<< orphan*/ sin_addr;
};
struct ifreq {
  int ifc_len;
  char *ifc_buf;
  char *ifr_name;
  int ifr_flags;
  int /*<<< orphan*/ ifr_addr;
  struct ifreq *ifc_req;
};
struct ifconf {
  int ifc_len;
  char *ifc_buf;
  char *ifr_name;
  int ifr_flags;
  int /*<<< orphan*/ ifr_addr;
  struct ifconf *ifc_req;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int IFF_UP;
int IFNAMSIZ;
int /*<<< orphan*/ SIOCGIFCONF;
int /*<<< orphan*/ SIOCGIFFLAGS;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *inet_ntoa(int /*<<< orphan*/);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct ifreq *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char **argv) {
  char buf[1024];
  struct ifconf ifc;
  struct ifreq *ifr;
  int i, n, sock, just_up = 0, print_addr = 0, just_addr = 0;
  char ifnam[32];
  ifnam[0] = '\0';
  for (i = 1; i < argc; i++) {
    if (!strcmp(argv[i], "up")) {
      just_up = 1;
    } else if (!strcmp(argv[i], "addr")) {
      print_addr = 1;
    } else if (!strcmp(argv[i], "justaddr")) {
      just_addr = 1;
    } else if (!strcmp(argv[i], "--help")) {
      fprintf(stderr, "Usage: %s [up | addr | justaddr] [ifnames]\n", argv[0]);
    } else {
      strncpy(ifnam, argv[i], 32);
    }
  }
  if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    perror("socket");
    return 1;
  }
  ifc.ifc_len = 1024;
  ifc.ifc_buf = buf;
  if (ioctl(sock, SIOCGIFCONF, &ifc) < 0) {
    perror("ioctl(SIOCGIFCONF)");
    return 1;
  }
  ifr = ifc.ifc_req;
  n = ifc.ifc_len / sizeof(struct ifreq);
  for (i = 0; i < n; i++) {
    struct ifreq *item = &ifr[i];
    if (*ifnam && strcmp(item->ifr_name, ifnam))
      continue;
    struct sockaddr_in *sin = (struct sockaddr_in *)&item->ifr_addr;
    if (just_up) {
      struct ifreq upreq;
      strncpy(upreq.ifr_name, item->ifr_name, IFNAMSIZ);
      ioctl(sock, SIOCGIFFLAGS, &upreq);
      if (!(upreq.ifr_flags & IFF_UP))
        continue;
    }
    if (!just_addr)
      printf("%s", item->ifr_name);
    if (!just_addr && print_addr)
      printf("\t");
    if (print_addr || just_addr)
      printf("%s", inet_ntoa(sin->sin_addr));
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x450(%rbp)
movl   $0x0,-0x454(%rbp)
movl   $0x0,-0x458(%rbp)
movb   $0x0,-0x480(%rbp)
movl   $0x1,-0x444(%rbp)
mov    -0x444(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1301 <main+0x181>
mov    -0x10(%rbp),%rax
movslq -0x444(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe13(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    120b <main+0x8b>
movl   $0x1,-0x450(%rbp)
jmp    12e8 <main+0x168>
mov    -0x10(%rbp),%rax
movslq -0x444(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xde6(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    123f <main+0xbf>
movl   $0x1,-0x454(%rbp)
jmp    12e3 <main+0x163>
mov    -0x10(%rbp),%rax
movslq -0x444(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdae(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1273 <main+0xf3>
movl   $0x1,-0x458(%rbp)
jmp    12de <main+0x15e>
mov    -0x10(%rbp),%rax
movslq -0x444(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd83(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12b9 <main+0x139>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd64(%rip),%rsi
call   1080 <fprintf@plt>
jmp    12d9 <main+0x159>
lea    -0x480(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x444(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    $0x20,%edx
call   1030 <strncpy@plt>
jmp    12de <main+0x15e>
jmp    12e3 <main+0x163>
jmp    12e8 <main+0x168>
jmp    12ed <main+0x16d>
mov    -0x444(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x444(%rbp)
jmp    11c8 <main+0x48>
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
mov    0x2cc7(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10a0 <socket@plt>
mov    %eax,-0x44c(%rbp)
cmp    $0x0,%eax
jge    1341 <main+0x1c1>
lea    0xd0f(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1555 <main+0x3d5>
movl   $0x400,-0x438(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x430(%rbp)
mov    -0x44c(%rbp),%edi
mov    0x2c4a(%rip),%rax
mov    (%rax),%esi
lea    -0x438(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1396 <main+0x216>
lea    0xcc1(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1555 <main+0x3d5>
mov    -0x418(%rbp),%rax
mov    %rax,-0x440(%rbp)
movslq -0x438(%rbp),%rax
mov    $0x28,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x448(%rbp)
movl   $0x0,-0x444(%rbp)
mov    -0x444(%rbp),%eax
cmp    -0x448(%rbp),%eax
jge    154e <main+0x3ce>
mov    -0x440(%rbp),%rax
movslq -0x444(%rbp),%rcx
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
mov    %rax,-0x488(%rbp)
movsbl -0x480(%rbp),%eax
cmp    $0x0,%eax
je     1429 <main+0x2a9>
mov    -0x488(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x480(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1429 <main+0x2a9>
jmp    153a <main+0x3ba>
mov    -0x488(%rbp),%rax
add    $0x1c,%rax
mov    %rax,-0x490(%rbp)
cmpl   $0x0,-0x450(%rbp)
je     14a5 <main+0x325>
mov    -0x4a8(%rbp),%rdi
mov    -0x488(%rbp),%rax
mov    0x10(%rax),%rsi
mov    0x2b57(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    -0x44c(%rbp),%edi
mov    0x2b5b(%rip),%rax
mov    (%rax),%esi
lea    -0x4b8(%rbp),%rdx
call   1060 <ioctl@plt>
mov    -0x4a0(%rbp),%eax
mov    0x2b50(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    14a0 <main+0x320>
jmp    153a <main+0x3ba>
jmp    14a5 <main+0x325>
cmpl   $0x0,-0x458(%rbp)
jne    14cb <main+0x34b>
mov    -0x488(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xb95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x458(%rbp)
jne    14f3 <main+0x373>
cmpl   $0x0,-0x454(%rbp)
je     14f3 <main+0x373>
lea    0xb70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x454(%rbp)
jne    150d <main+0x38d>
cmpl   $0x0,-0x458(%rbp)
je     152c <main+0x3ac>
mov    -0x490(%rbp),%rax
mov    (%rax),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xb34(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xb0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x444(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x444(%rbp)
jmp    13c5 <main+0x245>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x488,%rsp
movb   $0x0,0x10(%rsp)
xor    %r12d,%r12d
mov    $0x0,%r13d
movl   $0x0,0x8(%rsp)
cmp    $0x2,%edi
jl     12a5 <main+0x115>
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0x8(%rsp)
mov    $0x1,%r15d
lea    0xe26(%rip),%r14
xor    %r13d,%r13d
xor    %r12d,%r12d
jmp    1203 <main+0x73>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x1,%r12d
add    $0x1,%r15
cmp    %r15,%rbp
je     12a5 <main+0x115>
mov    (%rbx,%r15,8),%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     11f0 <main+0x60>
mov    (%rbx,%r15,8),%rdi
lea    0xde8(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1270 <main+0xe0>
mov    (%rbx,%r15,8),%rdi
lea    0xdcf(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     127b <main+0xeb>
mov    (%rbx,%r15,8),%rdi
lea    0xdc3(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1288 <main+0xf8>
mov    (%rbx,%r15,8),%rsi
lea    0x10(%rsp),%rdi
mov    $0x20,%edx
call   1040 <strncpy@plt>
jmp    11f6 <main+0x66>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%r13d
jmp    11f6 <main+0x66>
movl   $0x1,0x8(%rsp)
jmp    11f6 <main+0x66>
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd78(%rip),%rsi
call   1090 <fprintf@plt>
jmp    11f6 <main+0x66>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
mov    0x2d23(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
test   %eax,%eax
js     1418 <main+0x288>
mov    %eax,%ebx
movl   $0x400,0x30(%rsp)
lea    0x80(%rsp),%rax
mov    %rax,0x38(%rsp)
mov    0x2ccc(%rip),%rax
mov    (%rax),%esi
lea    0x30(%rsp),%rdx
mov    %ebx,%edi
call   1070 <ioctl@plt>
test   %rax,%rax
js     1421 <main+0x291>
movslq 0x30(%rsp),%rax
movabs $0xcccccccccccccccd,%rcx
cc cc cc
mul    %rcx
shr    $0x5,%rdx
test   %edx,%edx
jle    1404 <main+0x274>
mov    %r13d,0xc(%rsp)
mov    0x50(%rsp),%r14
mov    %edx,%eax
shl    $0x3,%rax
lea    (%rax,%rax,4),%r13
lea    0x10(%rsp),%rbp
xor    %r15d,%r15d
jmp    1372 <main+0x1e2>
nopw   0x0(%rax,%rax,1)
mov    0x1c(%r14,%r15,1),%edi
call   1050 <inet_ntoa@plt>
lea    0xd08(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x28,%r15
cmp    %r15,%r13
je     1404 <main+0x274>
cmpb   $0x0,0x10(%rsp)
je     138b <main+0x1fb>
mov    0x10(%r14,%r15,1),%rdi
mov    %rbp,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1365 <main+0x1d5>
test   %r12d,%r12d
je     13cc <main+0x23c>
mov    0x68(%rsp),%rdi
mov    0x10(%r14,%r15,1),%rsi
mov    0x2c17(%rip),%rax
mov    (%rax),%edx
call   1040 <strncpy@plt>
mov    0x2c21(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
lea    0x58(%rsp),%rdx
call   1070 <ioctl@plt>
mov    0x2c1c(%rip),%rax
mov    (%rax),%eax
and    0x70(%rsp),%eax
je     1365 <main+0x1d5>
cmpl   $0x0,0x8(%rsp)
jne    1340 <main+0x1b0>
mov    0x10(%r14,%r15,1),%rsi
lea    0xc76(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,0xc(%rsp)
je     135b <main+0x1cb>
mov    $0x9,%edi
call   1030 <putchar@plt>
jmp    1340 <main+0x1b0>
xor    %eax,%eax
add    $0x488,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc20(%rip),%rdi
jmp    1428 <main+0x298>
lea    0xc1e(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%eax
jmp    1406 <main+0x276>

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

LLVM IR (-O2):
%struct.ifconf = type { i32, i8*, i8*, i32, i32, %struct.ifconf* }
%struct.ifreq = type { i32, i8*, i8*, i32, i32, %struct.ifreq* }
@.str = [3 x i8] c"up\00"
@.str.1 = [5 x i8] c"addr\00"
@.str.2 = [9 x i8] c"justaddr\00"
@.str.3 = [7 x i8] c"--help\00"
@stderr = global i32 0
@.str.4 = [44 x i8] c"Usage: %s [up | addr | justaddr] [ifnames]\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.5 = [7 x i8] c"socket\00"
@SIOCGIFCONF = global i32 0
@.str.6 = [19 x i8] c"ioctl(SIOCGIFCONF)\00"
@IFNAMSIZ = global i32 0
@SIOCGIFFLAGS = global i32 0
@IFF_UP = global i32 0
@.str.7 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca %struct.ifconf
%5 = alloca [32 x i8]
%6 = alloca %struct.ifreq
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = bitcast %struct.ifconf* %4 to i8*
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
store i8 0, i8* %9
%10 = icmp sgt i32 %0, 1
br i1 %10, label %11, label %47
11: ; preds = %2
%12 = zext i32 %0 to i64
br label %13
13: ; preds = %11, %41
%14 = phi i64 [ 1, %11 ], [ %45, %41 ]
%15 = phi i32 [ 0, %11 ], [ %44, %41 ]
%16 = phi i32 [ 0, %11 ], [ %43, %41 ]
%17 = phi i32 [ 0, %11 ], [ %42, %41 ]
%18 = getelementptr inbounds i8*, i8** %1, i64 %14
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %41, label %22
22: ; preds = %13
%23 = load i8*, i8** %18
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %41, label %26
26: ; preds = %22
%27 = load i8*, i8** %18
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %41, label %30
30: ; preds = %26
%31 = load i8*, i8** %18
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %1
%37 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i8* %36)
br label %41
38: ; preds = %30
%39 = load i8*, i8** %18
%40 = call i32 @strncpy(i8* %9, i8* %39, i32 32)
br label %41
41: ; preds = %26, %22, %13, %38, %34
%42 = phi i32 [ %17, %38 ], [ %17, %34 ], [ 1, %13 ], [ %17, %22 ], [ %17, %26 ]
%43 = phi i32 [ %16, %38 ], [ %16, %34 ], [ %16, %13 ], [ 1, %22 ], [ %16, %26 ]
%44 = phi i32 [ %15, %38 ], [ %15, %34 ], [ %15, %13 ], [ %15, %22 ], [ 1, %26 ]
%45 = add nuw nsw i64 %14, 1
%46 = icmp eq i64 %45, %12
br i1 %46, label %47, label %13
47: ; preds = %41, %2
%48 = phi i32 [ 0, %2 ], [ %42, %41 ]
%49 = phi i32 [ 0, %2 ], [ %43, %41 ]
%50 = phi i32 [ 0, %2 ], [ %44, %41 ]
%51 = load i32, i32* @AF_INET
%52 = load i32, i32* @SOCK_DGRAM
%53 = call i32 @socket(i32 %51, i32 %52, i32 0)
%54 = icmp slt i32 %53, 0
br i1 %54, label %118, label %55
55: ; preds = %47
%56 = getelementptr inbounds %struct.ifconf, %struct.ifconf* %4, i64 0, i32 0
store i32 1024, i32* %56
%57 = getelementptr inbounds %struct.ifconf, %struct.ifconf* %4, i64 0, i32 1
store i8* %7, i8** %57
%58 = load i32, i32* @SIOCGIFCONF
%59 = bitcast %struct.ifconf* %4 to %struct.ifreq*
%60 = call i64 @ioctl(i32 %53, i32 %58, %struct.ifreq* %59)
%61 = icmp slt i64 %60, 0
br i1 %61, label %118, label %62
62: ; preds = %55
%63 = getelementptr inbounds %struct.ifconf, %struct.ifconf* %4, i64 0, i32 5
%64 = bitcast %struct.ifconf** %63 to %struct.ifreq**
%65 = load %struct.ifreq*, %struct.ifreq** %64
%66 = load i32, i32* %56
%67 = sext i32 %66 to i64
%68 = udiv i64 %67, 40
%69 = trunc i64 %68 to i32
%70 = icmp sgt i32 %69, 0
br i1 %70, label %71, label %121
71: ; preds = %62
%72 = icmp eq i32 %48, 0
%73 = bitcast %struct.ifreq* %6 to i8*
%74 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %6, i64 0, i32 2
%75 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %6, i64 0, i32 3
%76 = icmp eq i32 %50, 0
%77 = icmp eq i32 %49, 0
%78 = and i64 %68, 4294967295
br label %79
79: ; preds = %71, %115
%80 = phi i64 [ 0, %71 ], [ %116, %115 ]
%81 = load i8, i8* %9
%82 = icmp eq i8 %81, 0
br i1 %82, label %88, label %83
83: ; preds = %79
%84 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %65, i64 %80, i32 2
%85 = load i8*, i8** %84
%86 = call i64 @strcmp(i8* %85, i8* %9)
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %115
88: ; preds = %83, %79
%89 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %65, i64 %80, i32 4
br i1 %72, label %102, label %90
90: ; preds = %88
%91 = load i8*, i8** %74
%92 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %65, i64 %80, i32 2
%93 = load i8*, i8** %92
%94 = load i32, i32* @IFNAMSIZ
%95 = call i32 @strncpy(i8* %91, i8* %93, i32 %94)
%96 = load i32, i32* @SIOCGIFFLAGS
%97 = call i64 @ioctl(i32 %53, i32 %96, %struct.ifreq* %6)
%98 = load i32, i32* %75
%99 = load i32, i32* @IFF_UP
%100 = and i32 %99, %98
%101 = icmp eq i32 %100, 0
br i1 %101, label %115, label %102
102: ; preds = %90, %88
br i1 %76, label %103, label %109
103: ; preds = %102
%104 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %65, i64 %80, i32 2
%105 = load i8*, i8** %104
%106 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %105)
br i1 %77, label %113, label %107
107: ; preds = %103
%108 = call i32 @putchar(i32 9)
br label %109
109: ; preds = %107, %102
%110 = load i32, i32* %89
%111 = call i8* @inet_ntoa(i32 %110)
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %111)
br label %113
113: ; preds = %103, %109
%114 = call i32 @putchar(i32 10)
br label %115
115: ; preds = %113, %90, %83
%116 = add nuw nsw i64 %80, 1
%117 = icmp eq i64 %116, %78
br i1 %117, label %121, label %79
118: ; preds = %55, %47
%119 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), %47 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), %55 ]
%120 = call i32 @perror(i8* %119)
br label %121
121: ; preds = %115, %118, %62
%122 = phi i32 [ 0, %62 ], [ 1, %118 ], [ 0, %115 ]
ret i32 %122
}