#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 */

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, unsigned char);
int read(int, unsigned char *, int);
int main() {
  unsigned char buff[100];
  int readed, i, fd = open("/proc/modtimer", O_RDONLY);
  while (readed = read(fd, buff, 100))
    for (i = 0; i < readed; i++)
      printf("%hhu\n", buff[i]);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e8f(%rip),%rax
mov    (%rax),%esi
lea    0xe9e(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x64,%edx
call   1050 <read@plt>
mov    %eax,-0x74(%rbp)
cmp    $0x0,%eax
je     11c2 <main+0x82>
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    11bd <main+0x7d>
movslq -0x78(%rbp),%rax
lea    0xe6a(%rip),%rdi
movzbl -0x70(%rbp,%rax,1),%esi
call   1030 <printf@plt>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    118e <main+0x4e>
jmp    116a <main+0x2a>
mov    -0x7c(%rbp),%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    0x2e95(%rip),%rax
mov    (%rax),%esi
lea    0xea4(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%r15d
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x64,%edx
call   1050 <read@plt>
test   %eax,%eax
je     11c7 <main+0x87>
lea    0xe91(%rip),%r12
mov    %rsp,%r14
jmp    11a4 <main+0x64>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x64,%edx
call   1050 <read@plt>
test   %eax,%eax
je     11c7 <main+0x87>
test   %eax,%eax
jle    1190 <main+0x50>
mov    %eax,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
movzbl (%rsp,%rbx,1),%esi
mov    %r12,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11b0 <main+0x70>
jmp    1190 <main+0x50>
mov    %r15d,%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"/proc/modtimer\00"
@O_RDONLY = global i32 0
@.str.1 = [6 x i8] c"%hhu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = load i32, i32* @O_RDONLY
%7 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 %7, i32* %5
br label %8
8: ; preds = %27, %0
%9 = load i32, i32* %5
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%11 = call i32 @read(i32 %9, i8* %10, i32 100)
store i32 %11, i32* %3
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %28
13: ; preds = %8
store i32 0, i32* %4
br label %14
14: ; preds = %24, %13
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %27
18: ; preds = %14
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %22)
br label %24
24: ; preds = %18
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %14
27: ; preds = %14
br label %8
28: ; preds = %8
%29 = load i32, i32* %5
%30 = call i32 @close(i32 %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"/proc/modtimer\00"
@O_RDONLY = global i32 0
@.str.1 = [6 x i8] c"%hhu\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i32 @read(i32 %4, i8* %2, i32 100)
%6 = icmp eq i32 %5, 0
br i1 %6, label %22, label %10
7: ; preds = %15, %10
%8 = call i32 @read(i32 %4, i8* %2, i32 100)
%9 = icmp eq i32 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %0, %7
%11 = phi i32 [ %8, %7 ], [ %5, %0 ]
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %7
13: ; preds = %10
%14 = zext i32 %11 to i64
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %20, %15 ]
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %18)
%20 = add nuw nsw i64 %16, 1
%21 = icmp eq i64 %20, %14
br i1 %21, label %7, label %15
22: ; preds = %7, %0
%23 = tail call i32 @close(i32 %4)
ret i32 0
}