#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 */
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
unsigned long long ULONG_MAX;
int /*<<< orphan*/ err_quit(char *);
int /*<<< orphan*/ err_sys(char *);
scalar_t__ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, int, int, unsigned long, unsigned long);
int /*<<< orphan*/ split_colon(char *, char *, char *);
int strlen(char *);
char *strtok(char *, char *);
scalar_t__ strtol(char *, char **, int);
unsigned long strtoul(char *, char **, int);
unsigned long long strtoull(char *, char **, int /*<<< orphan*/);
void sockq(unsigned long long ino) {
  int i;
  unsigned long txq, rxq;
  int lport, fport;
  char buf[1024], *array[32], *end, ptxq[16], prxq[16], plport[8], pfport[8],
      addrbuf[32];
  FILE *fp;
  unsigned long long procino;
  if ((fp = fopen("/proc/net/tcp", "r")) == NULL)
    err_sys("fopen error");
  while (fgets(buf, sizeof(buf), fp) != NULL) {
    buf[strlen(buf) - 1] = '\0';
    if ((array[0] = strtok(buf, " \t\n")) == NULL)
      err_quit("strtok error");
    for (i = 1; i < 32; i++) {
      if ((array[i] = strtok(NULL, " \t\n")) == NULL)
        break;
    }
    if (i == 12)
      continue;
    end = (char *)NULL;
    if (!array[9] || !*array[9] ||
        (procino = strtoull(array[9], &end, 0)) == ULONG_MAX || !end || *end)
      err_quit("read ino error");
    if (procino == ino) {
      split_colon(array[1], addrbuf, plport);
      end = (char *)NULL;
      if ((lport = (int)strtol(plport, &end, 16)) == ULONG_MAX || !end || *end)
        err_quit("read lport size error");
      split_colon(array[2], addrbuf, pfport);
      end = (char *)NULL;
      if ((fport = (int)strtol(pfport, &end, 16)) == ULONG_MAX || !end || *end)
        err_quit("read fport size error");
      split_colon(array[4], ptxq, prxq);
      end = (char *)NULL;
      if ((txq = strtoul(ptxq, &end, 16)) == ULONG_MAX || !end || *end)
        err_quit("read rcv size error");
      end = (char *)NULL;
      if ((rxq = strtoul(prxq, &end, 16)) == ULONG_MAX || !end || *end)
        err_quit("read snt size error");
      printf("Local-Port: %d; Foreign-Port: %d\n"
             "Recv-Q: %lu; Send-Q: %lu\n",
             lport, fport, rxq, txq);
    }
  }
  if (ferror(fp))
    err_quit("read proc file error");
  if (fclose(fp) == EOF)
    err_sys("fclose error");
  return;
}


x86 assembly (clang, -O0):
<sockq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5a0,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe1a(%rip),%rdi
lea    0xeef(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x598(%rbp)
cmp    $0x0,%rax
jne    120f <sockq+0x3f>
lea    0xe04(%rip),%rdi
call   1040 <err_sys@plt>
jmp    1214 <sockq+0x44>
lea    -0x430(%rbp),%rdi
mov    -0x598(%rbp),%rdx
mov    $0x400,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     156f <sockq+0x39f>
lea    -0x430(%rbp),%rdi
call   1060 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x430(%rbp,%rax,1)
lea    -0x430(%rbp),%rdi
lea    0xdbd(%rip),%rsi
call   10e0 <strtok@plt>
mov    %rax,-0x530(%rbp)
cmp    $0x0,%rax
jne    127f <sockq+0xaf>
lea    0xda4(%rip),%rdi
call   1080 <err_quit@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x20,-0xc(%rbp)
jge    12ce <sockq+0xfe>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd7f(%rip),%rsi
call   10e0 <strtok@plt>
movslq -0xc(%rbp),%rcx
mov    %rax,-0x530(%rbp,%rcx,8)
ff
cmp    $0x0,%rax
jne    12bb <sockq+0xeb>
jmp    12ce <sockq+0xfe>
jmp    12c0 <sockq+0xf0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1286 <sockq+0xb6>
cmpl   $0xc,-0xc(%rbp)
jne    12dd <sockq+0x10d>
jmp    1214 <sockq+0x44>
movq   $0x0,-0x538(%rbp)
cmpq   $0x0,-0x4e8(%rbp)
je     1353 <sockq+0x183>
mov    -0x4e8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1353 <sockq+0x183>
mov    -0x4e8(%rbp),%rdi
lea    -0x538(%rbp),%rsi
xor    %edx,%edx
call   10a0 <strtoull@plt>
mov    %rax,-0x5a0(%rbp)
mov    0x2ca7(%rip),%rcx
cmp    (%rcx),%rax
je     1353 <sockq+0x183>
cmpq   $0x0,-0x538(%rbp)
je     1353 <sockq+0x183>
mov    -0x538(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     135f <sockq+0x18f>
lea    0xcd1(%rip),%rdi
call   1080 <err_quit@plt>
mov    -0x5a0(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    156a <sockq+0x39a>
mov    -0x528(%rbp),%rdi
lea    -0x590(%rbp),%rsi
lea    -0x568(%rbp),%rdx
call   10c0 <split_colon@plt>
movq   $0x0,-0x538(%rbp)
lea    -0x568(%rbp),%rdi
lea    -0x538(%rbp),%rsi
mov    $0x10,%edx
call   10b0 <strtol@plt>
mov    %eax,-0x24(%rbp)
cltq
mov    0x2c17(%rip),%rcx
cmp    (%rcx),%rax
je     13e3 <sockq+0x213>
cmpq   $0x0,-0x538(%rbp)
je     13e3 <sockq+0x213>
mov    -0x538(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     13ef <sockq+0x21f>
lea    0xc50(%rip),%rdi
call   1080 <err_quit@plt>
mov    -0x520(%rbp),%rdi
lea    -0x590(%rbp),%rsi
lea    -0x570(%rbp),%rdx
call   10c0 <split_colon@plt>
movq   $0x0,-0x538(%rbp)
lea    -0x570(%rbp),%rdi
lea    -0x538(%rbp),%rsi
mov    $0x10,%edx
call   10b0 <strtol@plt>
mov    %eax,-0x28(%rbp)
cltq
mov    0x2b98(%rip),%rcx
cmp    (%rcx),%rax
je     1462 <sockq+0x292>
cmpq   $0x0,-0x538(%rbp)
je     1462 <sockq+0x292>
mov    -0x538(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     146e <sockq+0x29e>
lea    0xbe7(%rip),%rdi
call   1080 <err_quit@plt>
mov    -0x510(%rbp),%rdi
lea    -0x550(%rbp),%rsi
lea    -0x560(%rbp),%rdx
call   10c0 <split_colon@plt>
movq   $0x0,-0x538(%rbp)
lea    -0x550(%rbp),%rdi
lea    -0x538(%rbp),%rsi
mov    $0x10,%edx
call   10f0 <strtoul@plt>
mov    %rax,-0x18(%rbp)
mov    0x2b1a(%rip),%rcx
cmp    (%rcx),%rax
je     14e0 <sockq+0x310>
cmpq   $0x0,-0x538(%rbp)
je     14e0 <sockq+0x310>
mov    -0x538(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     14ec <sockq+0x31c>
lea    0xb7f(%rip),%rdi
call   1080 <err_quit@plt>
movq   $0x0,-0x538(%rbp)
lea    -0x560(%rbp),%rdi
lea    -0x538(%rbp),%rsi
mov    $0x10,%edx
call   10f0 <strtoul@plt>
mov    %rax,-0x20(%rbp)
mov    0x2ab6(%rip),%rcx
cmp    (%rcx),%rax
je     1544 <sockq+0x374>
cmpq   $0x0,-0x538(%rbp)
je     1544 <sockq+0x374>
mov    -0x538(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1550 <sockq+0x380>
lea    0xb2f(%rip),%rdi
call   1080 <err_quit@plt>
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0xb29(%rip),%rdi
call   1070 <printf@plt>
jmp    1214 <sockq+0x44>
mov    -0x598(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     1591 <sockq+0x3c1>
lea    0xb3d(%rip),%rdi
call   1080 <err_quit@plt>
mov    -0x598(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2a44(%rip),%rcx
cmp    (%rcx),%rax
jne    15b9 <sockq+0x3e9>
lea    0xb2a(%rip),%rdi
call   1040 <err_sys@plt>
add    $0x5a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sockq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x578,%rsp
mov    %rdi,%r15
lea    0xe15(%rip),%rdi
lea    0xeea(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    120b <sockq+0x3b>
lea    0xe08(%rip),%rdi
call   1040 <err_sys@plt>
lea    0x170(%rsp),%r12
lea    0xe00(%rip),%rbx
lea    0x40(%rsp),%r13
mov    %r14,0x10(%rsp)
mov    %r15,0x8(%rsp)
jmp    1235 <sockq+0x65>
nopl   0x0(%rax,%rax,1)
cmp    $0xc,%ebp
jne    129e <sockq+0xce>
mov    %r12,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1486 <sockq+0x2b6>
mov    %r12,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r12,1)
mov    %r12,%rdi
mov    %rbx,%rsi
call   10e0 <strtok@plt>
test   %rax,%rax
jne    127a <sockq+0xaa>
lea    0xda9(%rip),%rdi
call   1080 <err_quit@plt>
mov    $0x1,%ebp
nop
xor    %edi,%edi
mov    %rbx,%rsi
call   10e0 <strtok@plt>
mov    %rax,0x70(%rsp,%rbp,8)
test   %rax,%rax
je     1230 <sockq+0x60>
add    $0x1,%rbp
cmp    $0x20,%rbp
jne    1280 <sockq+0xb0>
movq   $0x0,(%rsp)
mov    0xb8(%rsp),%rdi
test   %rdi,%rdi
je     12f0 <sockq+0x120>
cmpb   $0x0,(%rdi)
je     12f0 <sockq+0x120>
mov    %rsp,%rsi
xor    %edx,%edx
call   10a0 <strtoull@plt>
mov    %rax,%rcx
mov    0x2d04(%rip),%rax
mov    %rcx,0x18(%rsp)
cmp    (%rax),%rcx
je     12f0 <sockq+0x120>
mov    (%rsp),%rax
test   %rax,%rax
je     12f0 <sockq+0x120>
cmpb   $0x0,(%rax)
je     12fc <sockq+0x12c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xd34(%rip),%rdi
call   1080 <err_quit@plt>
cmp    %r15,0x18(%rsp)
jne    1235 <sockq+0x65>
mov    0x78(%rsp),%rdi
mov    %r13,%rsi
lea    0x38(%rsp),%rbp
mov    %rbp,%rdx
call   10c0 <split_colon@plt>
movq   $0x0,(%rsp)
mov    %rbp,%rdi
mov    %rsp,%rsi
mov    $0x10,%edx
call   10b0 <strtol@plt>
mov    %rax,%r14
movslq %r14d,%rax
mov    0x2c8f(%rip),%rcx
cmp    (%rcx),%rax
je     1354 <sockq+0x184>
mov    (%rsp),%rax
test   %rax,%rax
je     1354 <sockq+0x184>
cmpb   $0x0,(%rax)
je     1360 <sockq+0x190>
lea    0xcdf(%rip),%rdi
call   1080 <err_quit@plt>
mov    0x80(%rsp),%rdi
mov    %r13,%rsi
lea    0x30(%rsp),%rbp
mov    %rbp,%rdx
call   10c0 <split_colon@plt>
movq   $0x0,(%rsp)
mov    %rbp,%rdi
mov    %rsp,%rsi
mov    $0x10,%edx
call   10b0 <strtol@plt>
mov    %rax,%r13
movslq %r13d,%rax
mov    0x2c33(%rip),%rcx
cmp    (%rcx),%rax
je     13b0 <sockq+0x1e0>
mov    (%rsp),%rax
test   %rax,%rax
je     13b0 <sockq+0x1e0>
cmpb   $0x0,(%rax)
je     13bc <sockq+0x1ec>
lea    0xc99(%rip),%rdi
call   1080 <err_quit@plt>
mov    0x90(%rsp),%rdi
lea    0x60(%rsp),%rbp
mov    %rbp,%rsi
lea    0x20(%rsp),%rdx
call   10c0 <split_colon@plt>
movq   $0x0,(%rsp)
mov    %rbp,%rdi
mov    %rsp,%rsi
mov    $0x10,%edx
call   10f0 <strtoul@plt>
mov    %rax,%rbp
mov    0x2bd8(%rip),%rax
cmp    (%rax),%rbp
je     140b <sockq+0x23b>
mov    (%rsp),%rax
test   %rax,%rax
je     140b <sockq+0x23b>
cmpb   $0x0,(%rax)
je     1417 <sockq+0x247>
lea    0xc54(%rip),%rdi
call   1080 <err_quit@plt>
movq   $0x0,(%rsp)
lea    0x20(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x10,%edx
call   10f0 <strtoul@plt>
mov    %rax,%r15
mov    0x2b95(%rip),%rax
cmp    (%rax),%r15
je     144e <sockq+0x27e>
mov    (%rsp),%rax
test   %rax,%rax
je     144e <sockq+0x27e>
cmpb   $0x0,(%rax)
je     145a <sockq+0x28a>
lea    0xc25(%rip),%rdi
call   1080 <err_quit@plt>
lea    0xc2d(%rip),%rdi
mov    %r14d,%esi
mov    %r13d,%edx
mov    %r15,%rcx
mov    %rbp,%r8
call   1070 <printf@plt>
mov    0x10(%rsp),%r14
mov    0x8(%rsp),%r15
lea    0x40(%rsp),%r13
jmp    1235 <sockq+0x65>
mov    %r14,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
je     149f <sockq+0x2cf>
lea    0xc2f(%rip),%rdi
call   1080 <err_quit@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    0x2b3a(%rip),%rcx
cmp    (%rcx),%rax
jne    14bf <sockq+0x2ef>
lea    0xc24(%rip),%rdi
call   1040 <err_sys@plt>
add    $0x578,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"/proc/net/tcp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"fopen error\00"
@.str.3 = [4 x i8] c" \09\0A\00"
@.str.4 = [13 x i8] c"strtok error\00"
@ULONG_MAX = global i64 0
@.str.5 = [15 x i8] c"read ino error\00"
@.str.6 = [22 x i8] c"read lport size error\00"
@.str.7 = [22 x i8] c"read fport size error\00"
@.str.8 = [20 x i8] c"read rcv size error\00"
@.str.9 = [20 x i8] c"read snt size error\00"
@.str.10 = [59 x i8] c"Local-Port: %d; Foreign-Port: %d\0ARecv-Q: %lu; Send-Q: %lu\0A\00"
@.str.11 = [21 x i8] c"read proc file error\00"
@EOF = global i64 0
@.str.12 = [13 x i8] c"fclose error\00"
define void @sockq(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1024 x i8]
%9 = alloca [32 x i8*]
%10 = alloca i8*
%11 = alloca [16 x i8]
%12 = alloca [16 x i8]
%13 = alloca [8 x i8]
%14 = alloca [8 x i8]
%15 = alloca [32 x i8]
%16 = alloca i32*
%17 = alloca i64
store i64 %0, i64* %2
%18 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %16
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %1
%21 = call i32 @err_sys(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %1
br label %23
23: ; preds = %173, %58, %22
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%25 = load i32*, i32** %16
%26 = call i32* @fgets(i8* %24, i32 1024, i32* %25)
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %174
28: ; preds = %23
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = sub nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 %32
store i8 0, i8* %33
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%35 = call i8* @strtok(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%36 = getelementptr inbounds [32 x i8*], [32 x i8*]* %9, i64 0, i64 0
store i8* %35, i8** %36
%37 = icmp eq i8* %35, null
br i1 %37, label %38, label %40
38: ; preds = %28
%39 = call i32 @err_quit(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %40
40: ; preds = %38, %28
store i32 1, i32* %3
br label %41
41: ; preds = %52, %40
%42 = load i32, i32* %3
%43 = icmp slt i32 %42, 32
br i1 %43, label %44, label %55
44: ; preds = %41
%45 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%46 = load i32, i32* %3
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [32 x i8*], [32 x i8*]* %9, i64 0, i64 %47
store i8* %45, i8** %48
%49 = icmp eq i8* %45, null
br i1 %49, label %50, label %51
50: ; preds = %44
br label %55
51: ; preds = %44
br label %52
52: ; preds = %51
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 1
store i32 %54, i32* %3
br label %41
55: ; preds = %50, %41
%56 = load i32, i32* %3
%57 = icmp eq i32 %56, 12
br i1 %57, label %58, label %59
58: ; preds = %55
br label %23
59: ; preds = %55
store i8* null, i8** %10
%60 = getelementptr inbounds [32 x i8*], [32 x i8*]* %9, i64 0, i64 9
%61 = load i8*, i8** %60
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %82
63: ; preds = %59
%64 = getelementptr inbounds [32 x i8*], [32 x i8*]* %9, i64 0, i64 9
%65 = load i8*, i8** %64
%66 = load i8, i8* %65
%67 = icmp ne i8 %66, 0
br i1 %67, label %68, label %82
68: ; preds = %63
%69 = getelementptr inbounds [32 x i8*], [32 x i8*]* %9, i64 0, i64 9
%70 = load i8*, i8** %69
%71 = call i64 @strtoull(i8* %70, i8** %10, i32 0)
store i64 %71, i64* %17
%72 = load i64, i64* @ULONG_MAX
%73 = icmp eq i64 %71, %72
br i1 %73, label %82, label %74
74: ; preds = %68
%75 = load i8*, i8** %10
%76 = icmp ne i8* %75, null
br i1 %76, label %77, label %82
77: ; preds = %74
%78 = load i8*, i8** %10
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = icmp ne i32 %80, 0
br i1 %81, label %82, label %84
82: ; preds = %77, %74, %68, %63, %59
%83 = call i32 @err_quit(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %84
84: ; preds = %82, %77
%85 = load i64, i64* %17
%86 = load i64, i64* %2
%87 = icmp eq i64 %85, %86
br i1 %87, label %88, label %173
88: ; preds = %84
%89 = getelementptr inbounds [32 x i8*], [32 x i8*]* %9, i64 0, i64 1
%90 = load i8*, i8** %89
%91 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%92 = getelementptr inbounds [8 x i8], [8 x i8]* %13, i64 0, i64 0
%93 = call i32 @split_colon(i8* %90, i8* %91, i8* %92)
store i8* null, i8** %10
%94 = getelementptr inbounds [8 x i8], [8 x i8]* %13, i64 0, i64 0
%95 = call i64 @strtol(i8* %94, i8** %10, i32 16)
%96 = trunc i64 %95 to i32
store i32 %96, i32* %6
%97 = sext i32 %96 to i64
%98 = load i64, i64* @ULONG_MAX
%99 = icmp eq i64 %97, %98
br i1 %99, label %108, label %100
100: ; preds = %88
%101 = load i8*, i8** %10
%102 = icmp ne i8* %101, null
br i1 %102, label %103, label %108
103: ; preds = %100
%104 = load i8*, i8** %10
%105 = load i8, i8* %104
%106 = sext i8 %105 to i32
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %110
108: ; preds = %103, %100, %88
%109 = call i32 @err_quit(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %110
110: ; preds = %108, %103
%111 = getelementptr inbounds [32 x i8*], [32 x i8*]* %9, i64 0, i64 2
%112 = load i8*, i8** %111
%113 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%114 = getelementptr inbounds [8 x i8], [8 x i8]* %14, i64 0, i64 0
%115 = call i32 @split_colon(i8* %112, i8* %113, i8* %114)
store i8* null, i8** %10
%116 = getelementptr inbounds [8 x i8], [8 x i8]* %14, i64 0, i64 0
%117 = call i64 @strtol(i8* %116, i8** %10, i32 16)
%118 = trunc i64 %117 to i32
store i32 %118, i32* %7
%119 = sext i32 %118 to i64
%120 = load i64, i64* @ULONG_MAX
%121 = icmp eq i64 %119, %120
br i1 %121, label %130, label %122
122: ; preds = %110
%123 = load i8*, i8** %10
%124 = icmp ne i8* %123, null
br i1 %124, label %125, label %130
125: ; preds = %122
%126 = load i8*, i8** %10
%127 = load i8, i8* %126
%128 = sext i8 %127 to i32
%129 = icmp ne i32 %128, 0
br i1 %129, label %130, label %132
130: ; preds = %125, %122, %110
%131 = call i32 @err_quit(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
br label %132
132: ; preds = %130, %125
%133 = getelementptr inbounds [32 x i8*], [32 x i8*]* %9, i64 0, i64 4
%134 = load i8*, i8** %133
%135 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%136 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%137 = call i32 @split_colon(i8* %134, i8* %135, i8* %136)
store i8* null, i8** %10
%138 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%139 = call i64 @strtoul(i8* %138, i8** %10, i32 16)
store i64 %139, i64* %4
%140 = load i64, i64* @ULONG_MAX
%141 = icmp eq i64 %139, %140
br i1 %141, label %150, label %142
142: ; preds = %132
%143 = load i8*, i8** %10
%144 = icmp ne i8* %143, null
br i1 %144, label %145, label %150
145: ; preds = %142
%146 = load i8*, i8** %10
%147 = load i8, i8* %146
%148 = sext i8 %147 to i32
%149 = icmp ne i32 %148, 0
br i1 %149, label %150, label %152
150: ; preds = %145, %142, %132
%151 = call i32 @err_quit(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %152
152: ; preds = %150, %145
store i8* null, i8** %10
%153 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%154 = call i64 @strtoul(i8* %153, i8** %10, i32 16)
store i64 %154, i64* %5
%155 = load i64, i64* @ULONG_MAX
%156 = icmp eq i64 %154, %155
br i1 %156, label %165, label %157
157: ; preds = %152
%158 = load i8*, i8** %10
%159 = icmp ne i8* %158, null
br i1 %159, label %160, label %165
160: ; preds = %157
%161 = load i8*, i8** %10
%162 = load i8, i8* %161
%163 = sext i8 %162 to i32
%164 = icmp ne i32 %163, 0
br i1 %164, label %165, label %167
165: ; preds = %160, %157, %152
%166 = call i32 @err_quit(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %167
167: ; preds = %165, %160
%168 = load i32, i32* %6
%169 = load i32, i32* %7
%170 = load i64, i64* %5
%171 = load i64, i64* %4
%172 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.10, i64 0, i64 0), i32 %168, i32 %169, i64 %170, i64 %171)
br label %173
173: ; preds = %167, %84
br label %23
174: ; preds = %23
%175 = load i32*, i32** %16
%176 = call i64 @ferror(i32* %175)
%177 = icmp ne i64 %176, 0
br i1 %177, label %178, label %180
178: ; preds = %174
%179 = call i32 @err_quit(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
br label %180
180: ; preds = %178, %174
%181 = load i32*, i32** %16
%182 = call i64 @fclose(i32* %181)
%183 = load i64, i64* @EOF
%184 = icmp eq i64 %182, %183
br i1 %184, label %185, label %187
185: ; preds = %180
%186 = call i32 @err_sys(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
br label %187
187: ; preds = %185, %180
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"/proc/net/tcp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"fopen error\00"
@.str.3 = [4 x i8] c" \09\0A\00"
@.str.4 = [13 x i8] c"strtok error\00"
@ULONG_MAX = global i64 0
@.str.5 = [15 x i8] c"read ino error\00"
@.str.6 = [22 x i8] c"read lport size error\00"
@.str.7 = [22 x i8] c"read fport size error\00"
@.str.8 = [20 x i8] c"read rcv size error\00"
@.str.9 = [20 x i8] c"read snt size error\00"
@.str.10 = [59 x i8] c"Local-Port: %d; Foreign-Port: %d\0ARecv-Q: %lu; Send-Q: %lu\0A\00"
@.str.11 = [21 x i8] c"read proc file error\00"
@EOF = global i64 0
@.str.12 = [13 x i8] c"fclose error\00"
define void @sockq(i64 %0) {
%2 = alloca [1024 x i8]
%3 = alloca [32 x i8*]
%4 = alloca i8*
%5 = alloca [16 x i8]
%6 = alloca [16 x i8]
%7 = alloca [8 x i8]
%8 = alloca [8 x i8]
%9 = alloca [32 x i8]
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%11 = bitcast [32 x i8*]* %3 to i8*
%12 = bitcast i8** %4 to i8*
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%18 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %1
%21 = tail call i32 @err_sys(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %1
%23 = getelementptr inbounds [32 x i8*], [32 x i8*]* %3, i64 0, i64 9
%24 = getelementptr inbounds [32 x i8*], [32 x i8*]* %3, i64 0, i64 1
%25 = getelementptr inbounds [32 x i8*], [32 x i8*]* %3, i64 0, i64 2
%26 = getelementptr inbounds [32 x i8*], [32 x i8*]* %3, i64 0, i64 4
br label %27
27: ; preds = %137, %22
%28 = phi i64 [ undef, %22 ], [ %73, %137 ]
br label %29
29: ; preds = %27, %50
%30 = call i32* @fgets(i8* %10, i32 1024, i32* %18)
%31 = icmp eq i32* %30, null
br i1 %31, label %138, label %32
32: ; preds = %29
%33 = call i32 @strlen(i8* %10)
%34 = add nsw i32 %33, -1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %35
store i8 0, i8* %36
%37 = call i8* @strtok(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %41
39: ; preds = %32
%40 = call i32 @err_quit(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %41
41: ; preds = %39, %32
br label %42
42: ; preds = %41, %47
%43 = phi i64 [ %48, %47 ], [ 1, %41 ]
%44 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%45 = getelementptr inbounds [32 x i8*], [32 x i8*]* %3, i64 0, i64 %43
store i8* %44, i8** %45
%46 = icmp eq i8* %44, null
br i1 %46, label %50, label %47
47: ; preds = %42
%48 = add nuw nsw i64 %43, 1
%49 = icmp eq i64 %48, 32
br i1 %49, label %53, label %42
50: ; preds = %42
%51 = trunc i64 %43 to i32
%52 = icmp eq i32 %51, 12
br i1 %52, label %29, label %53
53: ; preds = %50, %47
store i8* null, i8** %4
%54 = load i8*, i8** %23
%55 = icmp eq i8* %54, null
br i1 %55, label %69, label %56
56: ; preds = %53
%57 = load i8, i8* %54
%58 = icmp eq i8 %57, 0
br i1 %58, label %69, label %59
59: ; preds = %56
%60 = call i64 @strtoull(i8* %54, i8** %4, i32 0)
%61 = load i64, i64* @ULONG_MAX
%62 = icmp ne i64 %60, %61
%63 = load i8*, i8** %4
%64 = icmp ne i8* %63, null
%65 = select i1 %62, i1 %64, i1 false
br i1 %65, label %66, label %69
66: ; preds = %59
%67 = load i8, i8* %63
%68 = icmp eq i8 %67, 0
br i1 %68, label %72, label %69
69: ; preds = %66, %59, %56, %53
%70 = phi i64 [ %60, %66 ], [ %60, %59 ], [ %28, %56 ], [ %28, %53 ]
%71 = call i32 @err_quit(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %72
72: ; preds = %69, %66
%73 = phi i64 [ %70, %69 ], [ %60, %66 ]
%74 = icmp eq i64 %73, %0
br i1 %74, label %75, label %137
75: ; preds = %72
%76 = load i8*, i8** %24
%77 = call i32 @split_colon(i8* %76, i8* %17, i8* %15)
store i8* null, i8** %4
%78 = call i64 @strtol(i8* %15, i8** %4, i32 16)
%79 = trunc i64 %78 to i32
%80 = shl i64 %78, 32
%81 = ashr exact i64 %80, 32
%82 = load i64, i64* @ULONG_MAX
%83 = icmp ne i64 %81, %82
%84 = load i8*, i8** %4
%85 = icmp ne i8* %84, null
%86 = select i1 %83, i1 %85, i1 false
br i1 %86, label %87, label %90
87: ; preds = %75
%88 = load i8, i8* %84
%89 = icmp eq i8 %88, 0
br i1 %89, label %92, label %90
90: ; preds = %87, %75
%91 = call i32 @err_quit(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %92
92: ; preds = %90, %87
%93 = load i8*, i8** %25
%94 = call i32 @split_colon(i8* %93, i8* %17, i8* %16)
store i8* null, i8** %4
%95 = call i64 @strtol(i8* %16, i8** %4, i32 16)
%96 = trunc i64 %95 to i32
%97 = shl i64 %95, 32
%98 = ashr exact i64 %97, 32
%99 = load i64, i64* @ULONG_MAX
%100 = icmp ne i64 %98, %99
%101 = load i8*, i8** %4
%102 = icmp ne i8* %101, null
%103 = select i1 %100, i1 %102, i1 false
br i1 %103, label %104, label %107
104: ; preds = %92
%105 = load i8, i8* %101
%106 = icmp eq i8 %105, 0
br i1 %106, label %109, label %107
107: ; preds = %104, %92
%108 = call i32 @err_quit(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
br label %109
109: ; preds = %107, %104
%110 = load i8*, i8** %26
%111 = call i32 @split_colon(i8* %110, i8* %13, i8* %14)
store i8* null, i8** %4
%112 = call i64 @strtoul(i8* %13, i8** %4, i32 16)
%113 = load i64, i64* @ULONG_MAX
%114 = icmp ne i64 %112, %113
%115 = load i8*, i8** %4
%116 = icmp ne i8* %115, null
%117 = select i1 %114, i1 %116, i1 false
br i1 %117, label %118, label %121
118: ; preds = %109
%119 = load i8, i8* %115
%120 = icmp eq i8 %119, 0
br i1 %120, label %123, label %121
121: ; preds = %118, %109
%122 = call i32 @err_quit(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
br label %123
123: ; preds = %121, %118
store i8* null, i8** %4
%124 = call i64 @strtoul(i8* %14, i8** %4, i32 16)
%125 = load i64, i64* @ULONG_MAX
%126 = icmp ne i64 %124, %125
%127 = load i8*, i8** %4
%128 = icmp ne i8* %127, null
%129 = select i1 %126, i1 %128, i1 false
br i1 %129, label %130, label %133
130: ; preds = %123
%131 = load i8, i8* %127
%132 = icmp eq i8 %131, 0
br i1 %132, label %135, label %133
133: ; preds = %130, %123
%134 = call i32 @err_quit(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %135
135: ; preds = %133, %130
%136 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.10, i64 0, i64 0), i32 %79, i32 %96, i64 %124, i64 %112)
br label %137
137: ; preds = %135, %72
br label %27
138: ; preds = %29
%139 = call i64 @ferror(i32* %18)
%140 = icmp eq i64 %139, 0
br i1 %140, label %143, label %141
141: ; preds = %138
%142 = call i32 @err_quit(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
br label %143
143: ; preds = %141, %138
%144 = call i64 @fclose(i32* %18)
%145 = load i64, i64* @EOF
%146 = icmp eq i64 %144, %145
br i1 %146, label %147, label %149
147: ; preds = %143
%148 = call i32 @err_sys(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
br label %149
149: ; preds = %147, %143
ret void
}