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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char const *, char *);
int /*<<< orphan*/ printf(char *);
int strtol(char *, int /*<<< orphan*/, int);
void GetBitRates(const char *command, int *tx_bitrate, int *rx_bitrate) {
  FILE *fp;
  char line[1035];
  int i = 0;
  fp = popen(command, "r");
  if (fp == NULL) {
    printf("Failed to run command\n");
    exit(1);
  }
  while (fgets(line, sizeof(line) - 1, fp) != NULL) {
    if ((i == 14)) {
      *tx_bitrate = strtol(line + 12, 0, 10);
    }
    if (i == 15) {
      *rx_bitrate = strtol(line + 12, 0, 10);
    }
    i++;
  }
  pclose(fp);
}


x86 assembly (clang, -O0):
<GetBitRates>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x434(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11b6 <GetBitRates+0x56>
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11bb <GetBitRates+0x5b>
lea    -0x430(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x40a,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1246 <GetBitRates+0xe6>
cmpl   $0xe,-0x434(%rbp)
jne    1206 <GetBitRates+0xa6>
lea    -0x430(%rbp),%rdi
add    $0xc,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0xf,-0x434(%rbp)
jne    1232 <GetBitRates+0xd2>
lea    -0x430(%rbp),%rdi
add    $0xc,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x434(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x434(%rbp)
jmp    11bb <GetBitRates+0x5b>
mov    -0x20(%rbp),%rdi
call   1040 <pclose@plt>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetBitRates>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %rdx,0x8(%rsp)
mov    %rsi,%r14
lea    0xe80(%rip),%rsi
call   1070 <popen@plt>
test   %rax,%rax
je     1218 <GetBitRates+0xb8>
mov    %rax,%rbx
lea    0x10(%rsp),%rdi
mov    $0x40a,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11fe <GetBitRates+0x9e>
xor    %ebp,%ebp
lea    0x1c(%rsp),%r12
lea    0x10(%rsp),%r13
jmp    11ef <GetBitRates+0x8f>
cs nopw 0x0(%rax,%rax,1)
mov    0x8(%rsp),%r15
mov    %r12,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,(%r15)
add    $0x1,%ebp
mov    %r13,%rdi
mov    $0x40a,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11fe <GetBitRates+0x9e>
mov    %r14,%r15
cmp    $0xe,%ebp
je     11c5 <GetBitRates+0x65>
cmp    $0xf,%ebp
je     11c0 <GetBitRates+0x60>
jmp    11d7 <GetBitRates+0x77>
mov    %rbx,%rdi
call   1040 <pclose@plt>
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xde3(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [23 x i8] c"Failed to run command\0A\00"
define void @GetBitRates(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [1035 x i8]
%9 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 0, i32* %9
%10 = load i8*, i8** %4
%11 = call i32* @popen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %7
%12 = load i32*, i32** %7
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %3
br label %18
18: ; preds = %39, %17
%19 = getelementptr inbounds [1035 x i8], [1035 x i8]* %8, i64 0, i64 0
%20 = load i32*, i32** %7
%21 = call i32* @fgets(i8* %19, i32 1034, i32* %20)
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %42
23: ; preds = %18
%24 = load i32, i32* %9
%25 = icmp eq i32 %24, 14
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = getelementptr inbounds [1035 x i8], [1035 x i8]* %8, i64 0, i64 0
%28 = getelementptr inbounds i8, i8* %27, i64 12
%29 = call i32 @strtol(i8* %28, i32 0, i32 10)
%30 = load i32*, i32** %5
store i32 %29, i32* %30
br label %31
31: ; preds = %26, %23
%32 = load i32, i32* %9
%33 = icmp eq i32 %32, 15
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = getelementptr inbounds [1035 x i8], [1035 x i8]* %8, i64 0, i64 0
%36 = getelementptr inbounds i8, i8* %35, i64 12
%37 = call i32 @strtol(i8* %36, i32 0, i32 10)
%38 = load i32*, i32** %6
store i32 %37, i32* %38
br label %39
39: ; preds = %34, %31
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %18
42: ; preds = %18
%43 = load i32*, i32** %7
%44 = call i32 @pclose(i32* %43)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@str = [22 x i8] c"Failed to run command\00"
define void @GetBitRates(i8* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = alloca [1035 x i8]
%5 = getelementptr inbounds [1035 x i8], [1035 x i8]* %4, i64 0, i64 0
%6 = tail call i32* @popen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = call i32* @fgets(i8* %5, i32 1034, i32* %6)
%10 = icmp eq i32* %9, null
br i1 %10, label %26, label %11
11: ; preds = %8
%12 = getelementptr inbounds [1035 x i8], [1035 x i8]* %4, i64 0, i64 12
br label %16
13: ; preds = %3
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %11, %22
%17 = phi i32 [ 0, %11 ], [ %23, %22 ]
switch i32 %17, label %22 [
i32 14, label %19
i32 15, label %18
]
18: ; preds = %16
br label %19
19: ; preds = %16, %18
%20 = phi i32* [ %2, %18 ], [ %1, %16 ]
%21 = call i32 @strtol(i8* %12, i32 0, i32 10)
store i32 %21, i32* %20
br label %22
22: ; preds = %19, %16
%23 = add nuw nsw i32 %17, 1
%24 = call i32* @fgets(i8* %5, i32 1034, i32* %6)
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %16
26: ; preds = %22, %8
%27 = call i32 @pclose(i32* %6)
ret void
}