#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_a[256];
  sprintf(addr_specs_a, "/proc/%s/hw/ioreg/%s_a", argv[1], argv[2]);
  char my_buffer[1024];
  printf("This program does 10000x16 file reads of addr_specs_a.");
  int ii;
  int ee;
  for (ii = 0; ii < 10000; ii++) {
    my_file = fopen(addr_specs_a, "r");
    for (ee = 0; ee < 16; ee++) {
      result = fread(my_buffer, 1, 1024, my_file);
    }
    fclose(my_file);
  }
  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>
lea    0xe6c(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x524(%rbp)
cmpl   $0x2710,-0x524(%rbp)
jge    1269 <main+0x109>
lea    -0x120(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x528(%rbp)
cmpl   $0x10,-0x528(%rbp)
jge    124c <main+0xec>
lea    -0x520(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x528(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x528(%rbp)
jmp    120e <main+0xae>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x524(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x524(%rbp)
jmp    11dd <main+0x7d>
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    133f <main+0x1df>
mov    0x8(%rsi),%rdx
mov    0x10(%rsi),%rcx
lea    0xe86(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1080 <sprintf@plt>
lea    0xe8b(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2710,%ebp
lea    0xeb1(%rip),%r15
lea    0x100(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rax,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0xffffffff,%ebp
jne    11d0 <main+0x70>
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 = [23 x i8] c"/proc/%s/hw/ioreg/%s_a\00"
@.str.2 = [55 x i8] c"This program does 10000x16 file reads of addr_specs_a.\00"
@.str.3 = [2 x i8] c"r\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 ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %10
br label %27
27: ; preds = %46, %17
%28 = load i32, i32* %10
%29 = icmp slt i32 %28, 10000
br i1 %29, label %30, label %49
30: ; preds = %27
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %32, i32** %6
store i32 0, i32* %11
br label %33
33: ; preds = %40, %30
%34 = load i32, i32* %11
%35 = icmp slt i32 %34, 16
br i1 %35, label %36, label %43
36: ; preds = %33
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%38 = load i32*, i32** %6
%39 = call i32 @fread(i8* %37, i32 1, i32 1024, i32* %38)
store i32 %39, i32* %7
br label %40
40: ; preds = %36
%41 = load i32, i32* %11
%42 = add nsw i32 %41, 1
store i32 %42, i32* %11
br label %33
43: ; preds = %33
%44 = load i32*, i32** %6
%45 = call i32 @fclose(i32* %44)
br label %46
46: ; preds = %43
%47 = load i32, i32* %10
%48 = add nsw i32 %47, 1
store i32 %48, i32* %10
br label %27
49: ; preds = %27
store i32 0, i32* %3
br label %50
50: ; preds = %49, %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 = [23 x i8] c"/proc/%s/hw/ioreg/%s_a\00"
@.str.2 = [55 x i8] c"This program does 10000x16 file reads of addr_specs_a.\00"
@.str.3 = [2 x i8] c"r\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 ([23 x i8], [23 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
%17 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %9, %18
%19 = phi i32 [ 0, %9 ], [ %38, %18 ]
%20 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%22 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%23 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%24 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%25 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%26 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%27 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%28 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%29 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%30 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%31 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%32 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%33 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%34 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%35 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%36 = call i32 @fread(i8* %16, i32 1, i32 1024, i32* %20)
%37 = tail call i32 @fclose(i32* %20)
%38 = add nuw nsw i32 %19, 1
%39 = icmp eq i32 %38, 10000
br i1 %39, label %40, label %18
40: ; preds = %18
br label %41
41: ; preds = %40, %6
ret i32 0
}