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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, long long, long long, long long);
void gettcpcounter() {
  FILE *fp;
  long long insegs, outsegs, retranssegs;
  fp = fopen("/proc/net/snmp", "r");
  fscanf(fp, "Ip: %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s "
             "%*s %*s %*s %*s\n");
  fscanf(fp, "Ip: %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s "
             "%*s %*s %*s %*s\n");
  fscanf(fp, "Icmp: %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s "
             "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s\n");
  fscanf(fp, "Icmp: %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s "
             "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s\n");
  fscanf(fp, "Tcp: %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s\n");
  fscanf(fp,
         "Tcp: %*s %*s %*s %*s %*s %*s %*s %*s %*s %lld %lld %lld %*s %*s\n",
         &insegs, &outsegs, &retranssegs);
  printf("insegs %lld, outsegs %lld, retranssegs %lld\n", insegs, outsegs,
         retranssegs);
  fclose(fp);
}


x86 assembly (clang, -O0):
<gettcpcounter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rdi
lea    0xeb9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x8(%rbp),%rdi
lea    0xed4(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x8(%rbp),%rdi
lea    0xec2(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf1f(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf4b(%rip),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x20(%rbp),%r8
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xf66(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gettcpcounter>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xeb2(%rip),%rdi
lea    0xeba(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xead(%rip),%r14
mov    %rax,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
lea    0xedd(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
lea    0xf2b(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
lea    0xf58(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rsp,%r8
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    (%rsp),%rcx
lea    0xf6d(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"/proc/net/snmp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [81 x i8] c"Ip: %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s\0A\00"
@.str.3 = [111 x i8] c"Icmp: %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s\0A\00"
@.str.4 = [62 x i8] c"Tcp: %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s\0A\00"
@.str.5 = [65 x i8] c"Tcp: %*s %*s %*s %*s %*s %*s %*s %*s %*s %lld %lld %lld %*s %*s\0A\00"
@.str.6 = [45 x i8] c"insegs %lld, outsegs %lld, retranssegs %lld\0A\00"
define void @gettcpcounter() {
%1 = alloca i32*
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %1
%6 = load i32*, i32** %1
%7 = call i32 (i32*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32*, i32** %1
%9 = call i32 (i32*, i8*, ...) @fscanf(i32* %8, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32*, i32** %1
%11 = call i32 (i32*, i8*, ...) @fscanf(i32* %10, i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32*, i32** %1
%13 = call i32 (i32*, i8*, ...) @fscanf(i32* %12, i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str.3, i64 0, i64 0))
%14 = load i32*, i32** %1
%15 = call i32 (i32*, i8*, ...) @fscanf(i32* %14, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0))
%16 = load i32*, i32** %1
%17 = call i32 (i32*, i8*, ...) @fscanf(i32* %16, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.5, i64 0, i64 0), i64* %2, i64* %3, i64* %4)
%18 = load i64, i64* %2
%19 = load i64, i64* %3
%20 = load i64, i64* %4
%21 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i64 %18, i64 %19, i64 %20)
%22 = load i32*, i32** %1
%23 = call i32 @fclose(i32* %22)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"/proc/net/snmp\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [81 x i8] c"Ip: %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s\0A\00"
@.str.3 = [111 x i8] c"Icmp: %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s\0A\00"
@.str.4 = [62 x i8] c"Tcp: %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s\0A\00"
@.str.5 = [65 x i8] c"Tcp: %*s %*s %*s %*s %*s %*s %*s %*s %*s %lld %lld %lld %*s %*s\0A\00"
@.str.6 = [45 x i8] c"insegs %lld, outsegs %lld, retranssegs %lld\0A\00"
define void @gettcpcounter() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i64* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 (i32*, i8*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 (i32*, i8*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 (i32*, i8*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 (i32*, i8*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str.3, i64 0, i64 0))
%12 = tail call i32 (i32*, i8*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 (i32*, i8*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.5, i64 0, i64 0), i64* %1, i64* %2, i64* %3)
%14 = load i64, i64* %1
%15 = load i64, i64* %2
%16 = load i64, i64* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i64 %14, i64 %15, i64 %16)
%18 = call i32 @fclose(i32* %7)
ret void
}