#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *my_file;
  int result;
  if (argc < 3) {
    fprintf(stderr, "Usage: process id, ppout specific\n");
    return 0;
  }
  char addr_specs_chan[256];
  sprintf(addr_specs_chan, "/proc/%s/hw/ioreg/%s_chan", argv[1], argv[2]);
  char my_buffer[1024];
  int i;
  int e;
  for (i = 0; i < 10000; i++) {
    my_file = fopen(addr_specs_chan, "r");
    for (e = 0; e < 16; e++) {
      result = fread(my_buffer, 1, 4, my_file);
    }
    fclose(my_file);
  }
  printf("This program does 10000x16 file reads of addr_specs_chan.");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x530,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11a4 <main+0x44>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
lea    0xe6d(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1270 <main+0x110>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xe61(%rip),%rsi
call   1080 <sprintf@plt>
movl   $0x0,-0x524(%rbp)
cmpl   $0x2710,-0x524(%rbp)
jge    125d <main+0xfd>
lea    -0x120(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x528(%rbp)
cmpl   $0x10,-0x528(%rbp)
jge    1240 <main+0xe0>
lea    -0x520(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x528(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x528(%rbp)
jmp    1202 <main+0xa2>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x524(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x524(%rbp)
jmp    11d1 <main+0x71>
lea    0xddb(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x530,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x500,%rsp
cmp    $0x2,%edi
jg     118e <main+0x2e>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
call   1060 <fprintf@plt>
jmp    133b <main+0x1db>
mov    0x8(%rsi),%rdx
mov    0x10(%rsi),%rcx
lea    0xe86(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1080 <sprintf@plt>
mov    $0x2710,%ebp
lea    0xe89(%rip),%r15
lea    0x100(%rsp),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0xffffffff,%ebp
jne    11c0 <main+0x60>
lea    0xd09(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x500,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"Usage: process id, ppout specific\0A\00"
@.str.1 = [26 x i8] c"/proc/%s/hw/ioreg/%s_chan\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [58 x i8] c"This program does 10000x16 file reads of addr_specs_chan.\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 [256 x i8]
%9 = alloca [1024 x i8]
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %50
17: ; preds = %2
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %24)
store i32 0, i32* %10
br label %26
26: ; preds = %45, %17
%27 = load i32, i32* %10
%28 = icmp slt i32 %27, 10000
br i1 %28, label %29, label %48
29: ; preds = %26
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %31, i32** %6
store i32 0, i32* %11
br label %32
32: ; preds = %39, %29
%33 = load i32, i32* %11
%34 = icmp slt i32 %33, 16
br i1 %34, label %35, label %42
35: ; preds = %32
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%37 = load i32*, i32** %6
%38 = call i32 @fread(i8* %36, i32 1, i32 4, i32* %37)
store i32 %38, i32* %7
br label %39
39: ; preds = %35
%40 = load i32, i32* %11
%41 = add nsw i32 %40, 1
store i32 %41, i32* %11
br label %32
42: ; preds = %32
%43 = load i32*, i32** %6
%44 = call i32 @fclose(i32* %43)
br label %45
45: ; preds = %42
%46 = load i32, i32* %10
%47 = add nsw i32 %46, 1
store i32 %47, i32* %10
br label %26
48: ; preds = %26
%49 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %50
50: ; preds = %48, %14
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"Usage: process id, ppout specific\0A\00"
@.str.1 = [26 x i8] c"/proc/%s/hw/ioreg/%s_chan\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [58 x i8] c"This program does 10000x16 file reads of addr_specs_chan.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [1024 x i8]
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %41
9: ; preds = %2
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* %14)
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
br label %17
17: ; preds = %9, %17
%18 = phi i32 [ 0, %9 ], [ %37, %17 ]
%19 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%21 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%22 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%23 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%24 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%25 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%26 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%27 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%28 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%29 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%30 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%31 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%32 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%33 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%34 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%35 = call i32 @fread(i8* %16, i32 1, i32 4, i32* %19)
%36 = tail call i32 @fclose(i32* %19)
%37 = add nuw nsw i32 %18, 1
%38 = icmp eq i32 %37, 10000
br i1 %38, label %39, label %17
39: ; preds = %17
%40 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39, %6
ret i32 0
}