#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 obtener_ratio(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sleep(int);
int main() {
  int valor_viejo, valor_nuevo, valor;
  valor_viejo = obtener_ratio("/sys/class/net/eth0/statistics/rx_bytes");
  for (;; sleep(1)) {
    valor_nuevo = obtener_ratio("/sys/class/net/eth0/statistics/rx_bytes");
    valor = valor_nuevo - valor_viejo;
    printf("El valor leido es %d Kbps\n", valor);
    valor_viejo = valor_nuevo;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <obtener_ratio@plt>
mov    %eax,-0x8(%rbp)
lea    0xeab(%rip),%rdi
call   1030 <obtener_ratio@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xeb8(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    $0x1,%edi
call   1050 <sleep@plt>
jmp    114e <main+0x1e>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%r14
mov    %r14,%rdi
call   1030 <obtener_ratio@plt>
mov    %eax,%ebx
lea    0xed9(%rip),%r15
nop
mov    %r14,%rdi
call   1030 <obtener_ratio@plt>
mov    %eax,%ebp
mov    %eax,%esi
sub    %ebx,%esi
mov    %r15,%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %ebp,%ebx
jmp    1150 <main+0x20>

LLVM IR (-O0):
@.str = [40 x i8] c"/sys/class/net/eth0/statistics/rx_bytes\00"
@.str.1 = [27 x i8] c"El valor leido es %d Kbps\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @obtener_ratio(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
store i32 %5, i32* %2
br label %6
6: ; preds = %14, %0
%7 = call i32 @obtener_ratio(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = sub nsw i32 %8, %9
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %3
store i32 %13, i32* %2
br label %14
14: ; preds = %6
%15 = call i32 @sleep(i32 1)
br label %6
}

LLVM IR (-O2):
@.str = [40 x i8] c"/sys/class/net/eth0/statistics/rx_bytes\00"
@.str.1 = [27 x i8] c"El valor leido es %d Kbps\0A\00"
define i32 @main() {
%1 = tail call i32 @obtener_ratio(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %2, %0
%3 = phi i32 [ %1, %0 ], [ %4, %2 ]
%4 = tail call i32 @obtener_ratio(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%5 = sub nsw i32 %4, %3
%6 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i32 @sleep(i32 1)
br label %2
}