#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 atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main(int argc, char *argv[]) {
  int id = -1;
  int i, n;
  char fname[256], s[8];
  FILE *fp;
  if (argc > 1)
    id = atoi(argv[1]);
  if (id != -1) {
    for (;;) {
      sprintf(fname, "/proc/gdev/vd%d/compute_bandwidth_used", id);
      if (!(fp = fopen(fname, "r")))
        return -1;
      fgets(s, 8, fp);
      printf("Compute %03d %\n", atoi(s));
      fclose(fp);
      sprintf(fname, "/proc/gdev/vd%d/memory_bandwidth_used", id);
      if (!(fp = fopen(fname, "r")))
        return -1;
      fgets(s, 8, fp);
      printf("Memory  %03d %\n", atoi(s));
      fclose(fp);
      sleep(1);
    }
  } else {
    if (!(fp = fopen("/proc/gdev/virtual_device_count", "r")))
      return -1;
    fgets(s, 8, fp);
    n = atoi(s);
    fclose(fp);
    printf("        ");
    for (i = 0; i < n; i++) {
      printf("gdev%d ", i);
    }
    printf("\n");
    for (;;) {
      printf("Compute ");
      for (i = 0; i < n; i++) {
        sprintf(fname, "/proc/gdev/vd%d/compute_bandwidth_used", i);
        if (!(fp = fopen(fname, "r")))
          return -1;
        fgets(s, 8, fp);
        printf("  %03d ", atoi(s));
        fclose(fp);
      }
      printf("%\n");
      printf("Memory  ");
      for (i = 0; i < n; i++) {
        sprintf(fname, "/proc/gdev/vd%d/memory_bandwidth_used", i);
        if (!(fp = fopen(fname, "r")))
          return -1;
        fgets(s, 8, fp);
        printf("  %03d ", atoi(s));
        fclose(fp);
      }
      printf("%\n");
      sleep(1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11aa <main+0x3a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     12d4 <main+0x164>
jmp    11b9 <main+0x49>
lea    -0x120(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe36(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x120(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x130(%rbp)
cmp    $0x0,%rax
jne    11ff <main+0x8f>
movl   $0xffffffff,-0x4(%rbp)
jmp    151a <main+0x3aa>
lea    -0x128(%rbp),%rdi
mov    -0x130(%rbp),%rdx
mov    $0x8,%esi
call   1050 <fgets@plt>
lea    -0x128(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%esi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x130(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x120(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xde9(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x120(%rbp),%rdi
lea    0xdc4(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x130(%rbp)
cmp    $0x0,%rax
jne    1285 <main+0x115>
movl   $0xffffffff,-0x4(%rbp)
jmp    151a <main+0x3aa>
lea    -0x128(%rbp),%rdi
mov    -0x130(%rbp),%rdx
mov    $0x8,%esi
call   1050 <fgets@plt>
lea    -0x128(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%esi
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x130(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
jmp    11b9 <main+0x49>
lea    0xd94(%rip),%rdi
lea    0xd45(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x130(%rbp)
cmp    $0x0,%rax
jne    1304 <main+0x194>
movl   $0xffffffff,-0x4(%rbp)
jmp    151a <main+0x3aa>
lea    -0x128(%rbp),%rdi
mov    -0x130(%rbp),%rdx
mov    $0x8,%esi
call   1050 <fgets@plt>
lea    -0x128(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x130(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1377 <main+0x207>
mov    -0x18(%rbp),%esi
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    134c <main+0x1dc>
lea    0xcef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    143a <main+0x2ca>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xc49(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x120(%rbp),%rdi
lea    0xc5d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x130(%rbp)
cmp    $0x0,%rax
jne    13ec <main+0x27c>
movl   $0xffffffff,-0x4(%rbp)
jmp    151a <main+0x3aa>
lea    -0x128(%rbp),%rdi
mov    -0x130(%rbp),%rdx
mov    $0x8,%esi
call   1050 <fgets@plt>
lea    -0x128(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%esi
lea    0xc90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x130(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    139a <main+0x22a>
lea    0xc2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    14fd <main+0x38d>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xbbf(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x120(%rbp),%rdi
lea    0xb9a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x130(%rbp)
cmp    $0x0,%rax
jne    14af <main+0x33f>
movl   $0xffffffff,-0x4(%rbp)
jmp    151a <main+0x3aa>
lea    -0x128(%rbp),%rdi
mov    -0x130(%rbp),%rdx
mov    $0x8,%esi
call   1050 <fgets@plt>
lea    -0x128(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%esi
lea    0xbcd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x130(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    145d <main+0x2ed>
lea    0xb68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
jmp    1385 <main+0x215>
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
cmp    $0x2,%edi
jl     12c1 <main+0x141>
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
cmp    $0xffffffff,%eax
je     12c1 <main+0x141>
mov    %eax,%r12d
lea    0xe4a(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %eax,%edx
call   1090 <sprintf@plt>
lea    0xe5b(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     14c0 <main+0x340>
mov    %rax,%r15
lea    0x8(%rsp),%r14
lea    0x10(%rsp),%rbx
lea    0xe36(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x8,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
mov    %r14,%rdi
call   1080 <atoi@plt>
lea    0xe0a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
lea    0xdff(%rip),%rsi
mov    %r12d,%edx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     14c0 <main+0x340>
mov    %rax,%rbp
mov    %r14,%rdi
mov    $0x8,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
mov    %r14,%rdi
call   1080 <atoi@plt>
lea    0xde7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    %rbx,%rdi
lea    0xd63(%rip),%rsi
mov    %r12d,%edx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1200 <main+0x80>
jmp    14c0 <main+0x340>
lea    0xda7(%rip),%rdi
lea    0xd58(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     14c0 <main+0x340>
mov    %rax,%rbx
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x8,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
mov    %rbp,%rdi
call   1080 <atoi@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xd80(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r13d,%r13d
jle    1344 <main+0x1c4>
lea    0xd76(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%r13d
jne    1330 <main+0x1b0>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd4b(%rip),%rdi
lea    0x10(%rsp),%r12
lea    0x8(%rsp),%r14
xor    %eax,%eax
call   1050 <printf@plt>
test   %r13d,%r13d
jle    1480 <main+0x300>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
lea    0xc76(%rip),%rsi
mov    %r15d,%edx
call   1090 <sprintf@plt>
mov    %r12,%rdi
lea    0xc8b(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     14c0 <main+0x340>
mov    %rax,%rbp
mov    %r14,%rdi
mov    $0x8,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
mov    %r14,%rdi
call   1080 <atoi@plt>
lea    0xcdd(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
add    $0x1,%r15d
cmp    %r15d,%r13d
jne    1380 <main+0x200>
lea    0xc7f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xcb6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r13d,%r13d
jle    149c <main+0x31c>
xor    %ebp,%ebp
nopl   (%rax)
mov    %r12,%rdi
lea    0xc1f(%rip),%rsi
mov    %ebp,%edx
call   1090 <sprintf@plt>
mov    %r12,%rdi
lea    0xbfc(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     14c0 <main+0x340>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x8,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
mov    %r14,%rdi
call   1080 <atoi@plt>
lea    0xc4e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x1,%ebp
cmp    %ebp,%r13d
jne    1410 <main+0x290>
jmp    149c <main+0x31c>
cs nopw 0x0(%rax,%rax,1)
lea    0xbe5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc1c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xbc9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
lea    0xbe5(%rip),%rdi
jmp    135f <main+0x1df>
mov    $0xffffffff,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"/proc/gdev/vd%d/compute_bandwidth_used\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [16 x i8] c"Compute %03d %\0A\00"
@.str.3 = [38 x i8] c"/proc/gdev/vd%d/memory_bandwidth_used\00"
@.str.4 = [16 x i8] c"Memory %03d %\0A\00"
@.str.5 = [32 x i8] c"/proc/gdev/virtual_device_count\00"
@.str.6 = [9 x i8] c" \00"
@.str.7 = [8 x i8] c"gdev%d \00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [9 x i8] c"Compute \00"
@.str.10 = [8 x i8] c" %03d \00"
@.str.11 = [3 x i8] c"%\0A\00"
@.str.12 = [9 x i8] c"Memory \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [256 x i8]
%10 = alloca [8 x i8]
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 1
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %6
br label %19
19: ; preds = %14, %2
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, -1
br i1 %21, label %22, label %57
22: ; preds = %19
br label %23
23: ; preds = %47, %22
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%25 = load i32, i32* %6
%26 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %11
%29 = icmp ne i32* %28, null
br i1 %29, label %31, label %30
30: ; preds = %23
store i32 -1, i32* %3
br label %138
31: ; preds = %23
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%33 = load i32*, i32** %11
%34 = call i32 @fgets(i8* %32, i32 8, i32* %33)
%35 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%36 = call i32 @atoi(i8* %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = load i32*, i32** %11
%39 = call i32 @fclose(i32* %38)
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%41 = load i32, i32* %6
%42 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%44 = call i32* @fopen(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %44, i32** %11
%45 = icmp ne i32* %44, null
br i1 %45, label %47, label %46
46: ; preds = %31
store i32 -1, i32* %3
br label %138
47: ; preds = %31
%48 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%49 = load i32*, i32** %11
%50 = call i32 @fgets(i8* %48, i32 8, i32* %49)
%51 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%52 = call i32 @atoi(i8* %51)
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %52)
%54 = load i32*, i32** %11
%55 = call i32 @fclose(i32* %54)
%56 = call i32 @sleep(i32 1)
br label %23
57: ; preds = %19
%58 = call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %58, i32** %11
%59 = icmp ne i32* %58, null
br i1 %59, label %61, label %60
60: ; preds = %57
store i32 -1, i32* %3
br label %138
61: ; preds = %57
%62 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%63 = load i32*, i32** %11
%64 = call i32 @fgets(i8* %62, i32 8, i32* %63)
%65 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%66 = call i32 @atoi(i8* %65)
store i32 %66, i32* %8
%67 = load i32*, i32** %11
%68 = call i32 @fclose(i32* %67)
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %7
br label %70
70: ; preds = %77, %61
%71 = load i32, i32* %7
%72 = load i32, i32* %8
%73 = icmp slt i32 %71, %72
br i1 %73, label %74, label %80
74: ; preds = %70
%75 = load i32, i32* %7
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %74
%78 = load i32, i32* %7
%79 = add nsw i32 %78, 1
store i32 %79, i32* %7
br label %70
80: ; preds = %70
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %82
82: ; preds = %135, %80
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %7
br label %84
84: ; preds = %105, %82
%85 = load i32, i32* %7
%86 = load i32, i32* %8
%87 = icmp slt i32 %85, %86
br i1 %87, label %88, label %108
88: ; preds = %84
%89 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%90 = load i32, i32* %7
%91 = call i32 @sprintf(i8* %89, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %90)
%92 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%93 = call i32* @fopen(i8* %92, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %93, i32** %11
%94 = icmp ne i32* %93, null
br i1 %94, label %96, label %95
95: ; preds = %88
store i32 -1, i32* %3
br label %138
96: ; preds = %88
%97 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%98 = load i32*, i32** %11
%99 = call i32 @fgets(i8* %97, i32 8, i32* %98)
%100 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%101 = call i32 @atoi(i8* %100)
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i32 %101)
%103 = load i32*, i32** %11
%104 = call i32 @fclose(i32* %103)
br label %105
105: ; preds = %96
%106 = load i32, i32* %7
%107 = add nsw i32 %106, 1
store i32 %107, i32* %7
br label %84
108: ; preds = %84
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %7
br label %111
111: ; preds = %132, %108
%112 = load i32, i32* %7
%113 = load i32, i32* %8
%114 = icmp slt i32 %112, %113
br i1 %114, label %115, label %135
115: ; preds = %111
%116 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%117 = load i32, i32* %7
%118 = call i32 @sprintf(i8* %116, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %117)
%119 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%120 = call i32* @fopen(i8* %119, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %120, i32** %11
%121 = icmp ne i32* %120, null
br i1 %121, label %123, label %122
122: ; preds = %115
store i32 -1, i32* %3
br label %138
123: ; preds = %115
%124 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%125 = load i32*, i32** %11
%126 = call i32 @fgets(i8* %124, i32 8, i32* %125)
%127 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%128 = call i32 @atoi(i8* %127)
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i32 %128)
%130 = load i32*, i32** %11
%131 = call i32 @fclose(i32* %130)
br label %132
132: ; preds = %123
%133 = load i32, i32* %7
%134 = add nsw i32 %133, 1
store i32 %134, i32* %7
br label %111
135: ; preds = %111
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%137 = call i32 @sleep(i32 1)
br label %82
138: ; preds = %122, %95, %60, %46, %30
%139 = load i32, i32* %3
ret i32 %139
}

LLVM IR (-O2):
@.str = [39 x i8] c"/proc/gdev/vd%d/compute_bandwidth_used\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [16 x i8] c"Compute %03d %\0A\00"
@.str.3 = [38 x i8] c"/proc/gdev/vd%d/memory_bandwidth_used\00"
@.str.4 = [16 x i8] c"Memory %03d %\0A\00"
@.str.5 = [32 x i8] c"/proc/gdev/virtual_device_count\00"
@.str.6 = [9 x i8] c" \00"
@.str.7 = [8 x i8] c"gdev%d \00"
@.str.9 = [9 x i8] c"Compute \00"
@.str.10 = [8 x i8] c" %03d \00"
@.str.11 = [3 x i8] c"%\0A\00"
@.str.12 = [9 x i8] c"Memory \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [8 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %35
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %35, label %13
13: ; preds = %8
%14 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %11)
%15 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %86, label %17
17: ; preds = %13, %26
%18 = phi i32* [ %33, %26 ], [ %15, %13 ]
%19 = call i32 @fgets(i8* %6, i32 8, i32* %18)
%20 = call i32 @atoi(i8* %6)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = call i32 @fclose(i32* %18)
%23 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%24 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %86, label %26
26: ; preds = %17
%27 = call i32 @fgets(i8* %6, i32 8, i32* %24)
%28 = call i32 @atoi(i8* %6)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%30 = call i32 @fclose(i32* %24)
%31 = call i32 @sleep(i32 1)
%32 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %11)
%33 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %86, label %17
35: ; preds = %2, %8
%36 = tail call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp eq i32* %36, null
br i1 %37, label %86, label %38
38: ; preds = %35
%39 = call i32 @fgets(i8* %6, i32 8, i32* %36)
%40 = call i32 @atoi(i8* %6)
%41 = call i32 @fclose(i32* %36)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%43 = icmp sgt i32 %40, 0
br i1 %43, label %44, label %49
44: ; preds = %38, %44
%45 = phi i32 [ %47, %44 ], [ 0, %38 ]
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %45)
%47 = add nuw nsw i32 %45, 1
%48 = icmp eq i32 %47, %40
br i1 %48, label %49, label %44
49: ; preds = %44, %38
%50 = call i32 @putchar(i32 10)
br label %51
51: ; preds = %83, %49
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br i1 %43, label %53, label %80
53: ; preds = %51, %58
%54 = phi i32 [ %63, %58 ], [ 0, %51 ]
%55 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %54)
%56 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%57 = icmp eq i32* %56, null
br i1 %57, label %86, label %58
58: ; preds = %53
%59 = call i32 @fgets(i8* %6, i32 8, i32* %56)
%60 = call i32 @atoi(i8* %6)
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i32 %60)
%62 = call i32 @fclose(i32* %56)
%63 = add nuw nsw i32 %54, 1
%64 = icmp eq i32 %63, %40
br i1 %64, label %65, label %53
65: ; preds = %58
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0))
br i1 %43, label %68, label %83
68: ; preds = %65, %73
%69 = phi i32 [ %78, %73 ], [ 0, %65 ]
%70 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %69)
%71 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%72 = icmp eq i32* %71, null
br i1 %72, label %86, label %73
73: ; preds = %68
%74 = call i32 @fgets(i8* %6, i32 8, i32* %71)
%75 = call i32 @atoi(i8* %6)
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i32 %75)
%77 = call i32 @fclose(i32* %71)
%78 = add nuw nsw i32 %69, 1
%79 = icmp eq i32 %78, %40
br i1 %79, label %83, label %68
80: ; preds = %51
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0))
br label %83
83: ; preds = %73, %80, %65
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%85 = call i32 @sleep(i32 1)
br label %51
86: ; preds = %26, %17, %53, %68, %13, %35
ret i32 -1
}