#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 iosched() {
  printf("\nCurrent I/O Schedulder:\n");
  int c;
  FILE *file;
  file = fopen("/sys/block/mmcblk0/queue/scheduler", "r");
  if (file) {
    while ((c = getc(file)) != EOF)
      putchar(c);
    fclose(file);
  }
}


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

x86 assembly (clang, -O2):
<iosched>:
push   %r14
push   %rbx
push   %rax
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
lea    0xe99(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11b3 <iosched+0x63>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <getc@plt>
mov    0x2e5e(%rip),%r14
cmp    (%r14),%eax
je     11a4 <iosched+0x54>
nop
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1070 <getc@plt>
cmp    (%r14),%eax
jne    1190 <iosched+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 = [26 x i8] c"\0ACurrent I/O Schedulder:\0A\00"
@.str.1 = [35 x i8] c"/sys/block/mmcblk0/queue/scheduler\00"
@.str.2 = [2 x i8] c"r\00"
@EOF = global i32 0
define void @iosched() {
%1 = alloca i32
%2 = alloca i32*
%3 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%4 = call i32* @fopen(i8* getelementptr inbounds ([35 x i8], [35 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 = [35 x i8] c"/sys/block/mmcblk0/queue/scheduler\00"
@.str.2 = [2 x i8] c"r\00"
@EOF = global i32 0
@str = [25 x i8] c"\0ACurrent I/O Schedulder:\00"
define void @iosched() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([35 x i8], [35 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
}