#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(int);
void readahead2() {
  printf("\nCache size of External SDCard:\n");
  int c1;
  FILE *file;
  file = fopen("/sys/block/mmcblk0/queue/read_ahead_kb", "r");
  if (file) {
    while ((c1 = getc(file)) != EOF)
      putchar(c1);
    fclose(file);
  }
}


x86 assembly (clang, -O0):
<readahead2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    0xed6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11bc <readahead2+0x6c>
jmp    118b <readahead2+0x3b>
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e4a(%rip),%rcx
cmp    (%rcx),%eax
je     11b3 <readahead2+0x63>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
jmp    118b <readahead2+0x3b>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readahead2>:
push   %r14
push   %rbx
push   %rax
lea    0xece(%rip),%rdi
call   1040 <puts@plt>
lea    0xe99(%rip),%rdi
lea    0xeb9(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11b3 <readahead2+0x63>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <getc@plt>
mov    0x2e5e(%rip),%r14
cmp    (%r14),%eax
je     11a4 <readahead2+0x54>
nop
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1070 <getc@plt>
cmp    (%r14),%eax
jne    1190 <readahead2+0x40>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [33 x i8] c"\0ACache size of External SDCard:\0A\00"
@.str.1 = [39 x i8] c"/sys/block/mmcblk0/queue/read_ahead_kb\00"
@.str.2 = [2 x i8] c"r\00"
@EOF = global i32 0
define void @readahead2() {
%1 = alloca i32
%2 = alloca i32*
%3 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = call i32* @fopen(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = icmp ne i32* %5, null
br i1 %6, label %7, label %19
7: ; preds = %0
br label %8
8: ; preds = %13, %7
%9 = load i32*, i32** %2
%10 = call i32 @getc(i32* %9)
store i32 %10, i32* %1
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* %1
%15 = call i32 @putchar(i32 %14)
br label %8
16: ; preds = %8
%17 = load i32*, i32** %2
%18 = call i32 @fclose(i32* %17)
br label %19
19: ; preds = %16, %0
ret void
}

LLVM IR (-O2):
@.str.1 = [39 x i8] c"/sys/block/mmcblk0/queue/read_ahead_kb\00"
@.str.2 = [2 x i8] c"r\00"
@EOF = global i32 0
@str = [32 x i8] c"\0ACache size of External SDCard:\00"
define void @readahead2() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %16, label %4
4: ; preds = %0
%5 = tail call i32 @getc(i32* %2)
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %14, label %8
8: ; preds = %4, %8
%9 = phi i32 [ %11, %8 ], [ %5, %4 ]
%10 = tail call i32 @putchar(i32 %9)
%11 = tail call i32 @getc(i32* %2)
%12 = load i32, i32* @EOF
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %8
14: ; preds = %8, %4
%15 = tail call i32 @fclose(i32* %2)
br label %16
16: ; preds = %14, %0
ret void
}