#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 link_detect_ns(char *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int tx_rx_stat(char *, double *, double *);
int tx_rx_stat_fd(char *, double *, double *);
int main(int argc, char *argv[]) {
  char eth_name[100];
  strcpy(eth_name, "eth0");
  if (argc > 1)
    strcpy(eth_name, argv[1]);
  printf("eth name: %s\n", eth_name);
  double recv = 0, send = 0;
  int ret = tx_rx_stat(eth_name, &recv, &send);
  printf("ret: %d, recv = %f, send = %f\n", ret, recv, send);
  int ret1 = tx_rx_stat_fd(eth_name, &recv, &send);
  printf("ret1: %d, recv = %f, send = %f\n", ret1, recv, send);
  int detected;
  int ret2 = link_detect_ns(eth_name, &detected);
  printf("ret2: %d, detected = %d\n", ret2, detected);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe8c(%rip),%rsi
call   1030 <strcpy@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1194 <main+0x44>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x80(%rbp),%rsi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
lea    -0x80(%rbp),%rdi
lea    -0x88(%rbp),%rsi
lea    -0x90(%rbp),%rdx
call   1070 <tx_rx_stat@plt>
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%esi
movsd  -0x88(%rbp),%xmm0
ff
movsd  -0x90(%rbp),%xmm1
ff
lea    0xe1d(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    -0x88(%rbp),%rsi
lea    -0x90(%rbp),%rdx
call   1060 <tx_rx_stat_fd@plt>
mov    %eax,-0x98(%rbp)
mov    -0x98(%rbp),%esi
movsd  -0x88(%rbp),%xmm0
ff
movsd  -0x90(%rbp),%xmm1
ff
lea    0xdfb(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    -0x9c(%rbp),%rsi
call   1050 <link_detect_ns@plt>
mov    %eax,-0xa0(%rbp)
mov    -0xa0(%rbp),%esi
mov    -0x9c(%rbp),%edx
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x90,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe99(%rip),%rsi
lea    0x20(%rsp),%rdi
call   1030 <strcpy@plt>
cmp    $0x2,%ebp
jl     1184 <main+0x34>
mov    0x8(%rbx),%rsi
lea    0x20(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xe7a(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rbp
lea    0x8(%rsp),%r14
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1070 <tx_rx_stat@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
lea    0xe3c(%rip),%rdi
mov    %eax,%esi
mov    $0x2,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1060 <tx_rx_stat_fd@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
lea    0xe31(%rip),%rdi
mov    %eax,%esi
mov    $0x2,%al
call   1040 <printf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <link_detect_ns@plt>
mov    0x1c(%rsp),%edx
lea    0xe30(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"eth0\00"
@.str.1 = [14 x i8] c"eth name: %s\0A\00"
@.str.2 = [31 x i8] c"ret: %d, recv = %f, send = %f\0A\00"
@.str.3 = [32 x i8] c"ret1: %d, recv = %f, send = %f\0A\00"
@.str.4 = [25 x i8] c"ret2: %d, detected = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 1
br i1 %16, label %17, label %23
17: ; preds = %2
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strcpy(i8* %18, i8* %21)
br label %23
23: ; preds = %17, %2
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %24)
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%27 = call i32 @tx_rx_stat(i8* %26, double* %7, double* %8)
store i32 %27, i32* %9
%28 = load i32, i32* %9
%29 = load double, double* %7
%30 = load double, double* %8
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %28, double %29, double %30)
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%33 = call i32 @tx_rx_stat_fd(i8* %32, double* %7, double* %8)
store i32 %33, i32* %10
%34 = load i32, i32* %10
%35 = load double, double* %7
%36 = load double, double* %8
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %34, double %35, double %36)
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%39 = call i32 @link_detect_ns(i8* %38, i32* %11)
store i32 %39, i32* %12
%40 = load i32, i32* %12
%41 = load i32, i32* %11
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %40, i32 %41)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"eth0\00"
@.str.1 = [14 x i8] c"eth name: %s\0A\00"
@.str.2 = [31 x i8] c"ret: %d, recv = %f, send = %f\0A\00"
@.str.3 = [32 x i8] c"ret1: %d, recv = %f, send = %f\0A\00"
@.str.4 = [25 x i8] c"ret2: %d, detected = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @strcpy(i8* %7, i8* %12)
br label %14
14: ; preds = %10, %2
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%16 = bitcast double* %4 to i8*
store double 0.000000e+00, double* %4
%17 = bitcast double* %5 to i8*
store double 0.000000e+00, double* %5
%18 = call i32 @tx_rx_stat(i8* %7, double* %4, double* %5)
%19 = load double, double* %4
%20 = load double, double* %5
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %18, double %19, double %20)
%22 = call i32 @tx_rx_stat_fd(i8* %7, double* %4, double* %5)
%23 = load double, double* %4
%24 = load double, double* %5
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %22, double %23, double %24)
%26 = bitcast i32* %6 to i8*
%27 = call i32 @link_detect_ns(i8* %7, i32* %6)
%28 = load i32, i32* %6
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %27, i32 %28)
ret i32 0
}