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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const *, char *);
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ sqlite3_snprintf(int, char *, char *, int /*<<< orphan*/);
scalar_t__ strlen(char const *);
scalar_t__ strncmp(char const *, char *, int);
void displayLinuxIoStats(FILE *out) {
  FILE *in;
  char z[200];
  sqlite3_snprintf(sizeof(z), z, "/proc/%d/io", getpid());
  in = fopen(z, "rb");
  if (in == 0)
    return;
  while (fgets(z, sizeof(z), in) != 0) {
    static const struct {
      const char *zPattern;
      const char *zDesc;
    } aTrans[] = {
        {"rchar: ", "Bytes received by read():"},
        {"wchar: ", "Bytes sent to write():"},
        {"syscr: ", "Read() system calls:"},
        {"syscw: ", "Write() system calls:"},
        {"read_bytes: ", "Bytes read from storage:"},
        {"write_bytes: ", "Bytes written to storage:"},
        {"cancelled_write_bytes: ", "Cancelled write bytes:"},
    };
    int i;
    for (i = 0; i < sizeof(aTrans) / sizeof(aTrans[0]); i++) {
      int n = (int)strlen(aTrans[i].zPattern);
      if (strncmp(aTrans[i].zPattern, z, n) == 0) {
        fprintf(out, "%-36s %s", aTrans[i].zDesc, &z[n]);
        break;
      }
    }
  }
  fclose(in);
}


x86 assembly (clang, -O0):
<displayLinuxIoStats>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xe0(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0xf0(%rbp),%rsi
mov    %eax,%ecx
mov    $0xc8,%edi
lea    0xe47(%rip),%rdx
call   1090 <sqlite3_snprintf@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11e5 <displayLinuxIoStats+0x65>
jmp    12e1 <displayLinuxIoStats+0x161>
jmp    11ea <displayLinuxIoStats+0x6a>
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xc8,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     12d8 <displayLinuxIoStats+0x158>
movl   $0x0,-0xe4(%rbp)
movslq -0xe4(%rbp),%rax
cmp    $0x7,%rax
jae    12d3 <displayLinuxIoStats+0x153>
movslq -0xe4(%rbp),%rcx
lea    0x2b7e(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rdi
call   1060 <strlen@plt>
mov    %eax,-0xe8(%rbp)
movslq -0xe4(%rbp),%rcx
lea    0x2b5b(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rdi
lea    -0xe0(%rbp),%rsi
mov    -0xe8(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12ba <displayLinuxIoStats+0x13a>
mov    -0x8(%rbp),%rdi
movslq -0xe4(%rbp),%rcx
lea    0x2b23(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rdx
movslq -0xe8(%rbp),%rax
lea    -0xe0(%rbp),%rcx
add    %rax,%rcx
lea    0xe4a(%rip),%rsi
call   1080 <fprintf@plt>
jmp    12d3 <displayLinuxIoStats+0x153>
jmp    12bf <displayLinuxIoStats+0x13f>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1213 <displayLinuxIoStats+0x93>
jmp    11ea <displayLinuxIoStats+0x6a>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<displayLinuxIoStats>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    %rdi,%r14
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe6e(%rip),%rdx
mov    %rsp,%rbx
mov    $0xc8,%edi
mov    %rbx,%rsi
mov    %eax,%ecx
call   1080 <sqlite3_snprintf@plt>
lea    0xe61(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1340 <displayLinuxIoStats+0x1d0>
mov    %rax,%r12
mov    %rsp,%rdi
mov    $0xc8,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1338 <displayLinuxIoStats+0x1c8>
lea    0xe30(%rip),%r15
mov    %rsp,%rbx
lea    0xf11(%rip),%r13
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
mov    $0x7,%ebp
test   %rax,%rax
je     12c0 <displayLinuxIoStats+0x150>
lea    0xe1c(%rip),%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12d0 <displayLinuxIoStats+0x160>
lea    0xe1e(%rip),%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12d7 <displayLinuxIoStats+0x167>
lea    0xe1e(%rip),%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12de <displayLinuxIoStats+0x16e>
lea    0xe23(%rip),%rdi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12e5 <displayLinuxIoStats+0x175>
lea    0xe54(%rip),%rdi
mov    %rbx,%rsi
mov    $0xd,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12f1 <displayLinuxIoStats+0x181>
lea    0xe31(%rip),%rdi
mov    %rbx,%rsi
mov    $0x17,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    131f <displayLinuxIoStats+0x1af>
mov    $0x17,%ebp
mov    $0x6,%eax
jmp    1300 <displayLinuxIoStats+0x190>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
jmp    1300 <displayLinuxIoStats+0x190>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x1,%eax
jmp    1300 <displayLinuxIoStats+0x190>
mov    $0x2,%eax
jmp    1300 <displayLinuxIoStats+0x190>
mov    $0x3,%eax
jmp    1300 <displayLinuxIoStats+0x190>
mov    $0xc,%ebp
mov    $0x4,%eax
jmp    1300 <displayLinuxIoStats+0x190>
mov    $0xd,%ebp
mov    $0x5,%eax
nopl   0x0(%rax,%rax,1)
shl    $0x4,%rax
lea    0x2aa5(%rip),%rcx
mov    0x8(%rax,%rcx,1),%rdx
lea    (%rsp,%rbp,1),%rcx
mov    %r14,%rdi
mov    %r13,%rsi
call   1070 <fprintf@plt>
mov    %rbx,%rdi
mov    $0xc8,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    11f0 <displayLinuxIoStats+0x80>
mov    %r12,%rdi
call   1050 <fclose@plt>
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.anon = type { i8*, i8* }
@.str = [12 x i8] c"/proc/%d/io\00"
@.str.1 = [3 x i8] c"rb\00"
@displayLinuxIoStats.aTrans = internal constant [7 x %struct.anon] [%struct.anon { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i32 0, i32 0) }, %struct.anon { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i32 0, i32 0) }, %struct.anon { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i32 0, i32 0) }, %struct.anon { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i32 0, i32 0) }, %struct.anon { i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i32 0, i32 0) }, %struct.anon { i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i32 0, i32 0) }, %struct.anon { i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i32 0, i32 0) }]
@.str.2 = [8 x i8] c"rchar: \00"
@.str.3 = [26 x i8] c"Bytes received by read():\00"
@.str.4 = [8 x i8] c"wchar: \00"
@.str.5 = [23 x i8] c"Bytes sent to write():\00"
@.str.6 = [8 x i8] c"syscr: \00"
@.str.7 = [21 x i8] c"Read() system calls:\00"
@.str.8 = [8 x i8] c"syscw: \00"
@.str.9 = [22 x i8] c"Write() system calls:\00"
@.str.10 = [13 x i8] c"read_bytes: \00"
@.str.11 = [25 x i8] c"Bytes read from storage:\00"
@.str.12 = [14 x i8] c"write_bytes: \00"
@.str.13 = [26 x i8] c"Bytes written to storage:\00"
@.str.14 = [24 x i8] c"cancelled_write_bytes: \00"
@.str.15 = [23 x i8] c"Cancelled write bytes:\00"
@.str.16 = [9 x i8] c"%-36s %s\00"
define void @displayLinuxIoStats(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [200 x i8]
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %2
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%8 = call i32 (...) @getpid()
%9 = call i32 @sqlite3_snprintf(i32 200, i8* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %3
%12 = load i32*, i32** %3
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %1
br label %62
15: ; preds = %1
br label %16
16: ; preds = %58, %15
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%18 = load i32*, i32** %3
%19 = call i64 @fgets(i8* %17, i32 200, i32* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %59
21: ; preds = %16
store i32 0, i32* %5
br label %22
22: ; preds = %55, %21
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = icmp ult i64 %24, 7
br i1 %25, label %26, label %58
26: ; preds = %22
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [7 x %struct.anon], [7 x %struct.anon]* @displayLinuxIoStats.aTrans, i64 0, i64 %28
%30 = getelementptr inbounds %struct.anon, %struct.anon* %29, i32 0, i32 0
%31 = load i8*, i8** %30
%32 = call i64 @strlen(i8* %31)
%33 = trunc i64 %32 to i32
store i32 %33, i32* %6
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [7 x %struct.anon], [7 x %struct.anon]* @displayLinuxIoStats.aTrans, i64 0, i64 %35
%37 = getelementptr inbounds %struct.anon, %struct.anon* %36, i32 0, i32 0
%38 = load i8*, i8** %37
%39 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%40 = load i32, i32* %6
%41 = call i64 @strncmp(i8* %38, i8* %39, i32 %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %54
43: ; preds = %26
%44 = load i32*, i32** %2
%45 = load i32, i32* %5
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [7 x %struct.anon], [7 x %struct.anon]* @displayLinuxIoStats.aTrans, i64 0, i64 %46
%48 = getelementptr inbounds %struct.anon, %struct.anon* %47, i32 0, i32 1
%49 = load i8*, i8** %48
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 %51
%53 = call i32 @fprintf(i32* %44, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.16, i64 0, i64 0), i8* %49, i8* %52)
br label %58
54: ; preds = %26
br label %55
55: ; preds = %54
%56 = load i32, i32* %5
%57 = add nsw i32 %56, 1
store i32 %57, i32* %5
br label %22
58: ; preds = %43, %22
br label %16
59: ; preds = %16
%60 = load i32*, i32** %3
%61 = call i32 @fclose(i32* %60)
br label %62
62: ; preds = %59, %14
ret void
}

LLVM IR (-O2):
%struct.anon = type { i8*, i8* }
@.str = [12 x i8] c"/proc/%d/io\00"
@.str.1 = [3 x i8] c"rb\00"
@displayLinuxIoStats.aTrans = internal unnamed_addr constant [7 x %struct.anon] [%struct.anon { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i32 0, i32 0) }, %struct.anon { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i32 0, i32 0) }, %struct.anon { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i32 0, i32 0) }, %struct.anon { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i32 0, i32 0) }, %struct.anon { i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i32 0, i32 0) }, %struct.anon { i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.13, i32 0, i32 0) }, %struct.anon { i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.15, i32 0, i32 0) }]
@.str.2 = [8 x i8] c"rchar: \00"
@.str.3 = [26 x i8] c"Bytes received by read():\00"
@.str.4 = [8 x i8] c"wchar: \00"
@.str.5 = [23 x i8] c"Bytes sent to write():\00"
@.str.6 = [8 x i8] c"syscr: \00"
@.str.7 = [21 x i8] c"Read() system calls:\00"
@.str.8 = [8 x i8] c"syscw: \00"
@.str.9 = [22 x i8] c"Write() system calls:\00"
@.str.10 = [13 x i8] c"read_bytes: \00"
@.str.11 = [25 x i8] c"Bytes read from storage:\00"
@.str.12 = [14 x i8] c"write_bytes: \00"
@.str.13 = [26 x i8] c"Bytes written to storage:\00"
@.str.14 = [24 x i8] c"cancelled_write_bytes: \00"
@.str.15 = [23 x i8] c"Cancelled write bytes:\00"
@.str.16 = [9 x i8] c"%-36s %s\00"
define void @displayLinuxIoStats(i32* nocapture %0) {
%2 = alloca [200 x i8]
%3 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (...) @getpid()
%5 = call i32 @sqlite3_snprintf(i32 200, i8* %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %44, label %8
8: ; preds = %1
%9 = call i64 @fgets(i8* %3, i32 200, i32* %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %42, label %11
11: ; preds = %8, %39
%12 = call i64 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %3, i32 7)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %36, %33, %30, %27, %24, %21, %11
%15 = phi i64 [ 0, %11 ], [ 1, %21 ], [ 2, %24 ], [ 3, %27 ], [ 4, %30 ], [ 5, %33 ], [ 6, %36 ]
%16 = phi i64 [ 7, %11 ], [ 7, %21 ], [ 7, %24 ], [ 7, %27 ], [ 12, %30 ], [ 13, %33 ], [ 23, %36 ]
%17 = getelementptr inbounds [7 x %struct.anon], [7 x %struct.anon]* @displayLinuxIoStats.aTrans, i64 0, i64 %15, i32 1
%18 = load i8*, i8** %17
%19 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 %16
%20 = call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.16, i64 0, i64 0), i8* %18, i8* %19)
br label %39
21: ; preds = %11
%22 = call i64 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %3, i32 7)
%23 = icmp eq i64 %22, 0
br i1 %23, label %14, label %24
24: ; preds = %21
%25 = call i64 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %3, i32 7)
%26 = icmp eq i64 %25, 0
br i1 %26, label %14, label %27
27: ; preds = %24
%28 = call i64 @strncmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %3, i32 7)
%29 = icmp eq i64 %28, 0
br i1 %29, label %14, label %30
30: ; preds = %27
%31 = call i64 @strncmp(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i8* %3, i32 12)
%32 = icmp eq i64 %31, 0
br i1 %32, label %14, label %33
33: ; preds = %30
%34 = call i64 @strncmp(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* %3, i32 13)
%35 = icmp eq i64 %34, 0
br i1 %35, label %14, label %36
36: ; preds = %33
%37 = call i64 @strncmp(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), i8* %3, i32 23)
%38 = icmp eq i64 %37, 0
br i1 %38, label %14, label %39
39: ; preds = %36, %14
%40 = call i64 @fgets(i8* %3, i32 200, i32* %6)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %11
42: ; preds = %39, %8
%43 = call i32 @fclose(i32* %6)
br label %44
44: ; preds = %1, %42
ret void
}