#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*/ atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usleep(int /*<<< orphan*/);
int main(int argc, char **argv) {
  if (argc < 3) {
    return -1;
  }
  FILE *f = fopen(argv[2], "r");
  char *buffer = malloc(sizeof(char) * 1);
  while (!feof(f)) {
    fread(buffer, 1, 1, f);
    printf("%c", buffer[0]);
    fflush(stdout);
    usleep(atoi(argv[1]));
  }
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11bc <main+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    125e <main+0xce>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe35(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1200 <main+0x70>
jmp    124e <main+0xbe>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    -0x20(%rbp),%rax
lea    0xde3(%rip),%rdi
movsbl (%rax),%esi
call   1050 <printf@plt>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,%edi
call   10b0 <usleep@plt>
jmp    11e2 <main+0x52>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0xffffffff,%eax
cmp    $0x3,%edi
jl     1248 <main+0xb8>
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    0x10(%rsi),%rdi
lea    0xe4b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r15
mov    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    1235 <main+0xa5>
lea    0xe25(%rip),%r12
mov    0x2dfc(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
movsbl (%rbx),%esi
mov    %r12,%rdi
call   1050 <printf@plt>
mov    0x0(%r13),%edi
call   1080 <fflush@plt>
mov    0x8(%r14),%rdi
call   10a0 <atoi@plt>
mov    %eax,%edi
call   10b0 <usleep@plt>
mov    %r15,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11f0 <main+0x60>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%c\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 -1, i32* %3
br label %40
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 2
%14 = load i8*, i8** %13
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %6
%16 = call i8* @malloc(i32 1)
store i8* %16, i8** %7
br label %17
17: ; preds = %22, %11
%18 = load i32*, i32** %6
%19 = call i32 @feof(i32* %18)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br i1 %21, label %22, label %37
22: ; preds = %17
%23 = load i8*, i8** %7
%24 = load i32*, i32** %6
%25 = call i32 @fread(i8* %23, i32 1, i32 1, i32* %24)
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %28)
%30 = load i32, i32* @stdout
%31 = call i32 @fflush(i32 %30)
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
%36 = call i32 @usleep(i32 %35)
br label %17
37: ; preds = %17
%38 = load i32*, i32** %6
%39 = call i32 @fclose(i32* %38)
store i32 0, i32* %3
br label %40
40: ; preds = %37, %10
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%c\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %26, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
%9 = tail call i32 @feof(i32* %7)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %4
%12 = getelementptr inbounds i8*, i8** %1, i64 1
br label %13
13: ; preds = %11, %13
%14 = tail call i32 @fread(i8* %8, i32 1, i32 1, i32* %7)
%15 = load i8, i8* %8
%16 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %15)
%17 = load i32, i32* @stdout
%18 = tail call i32 @fflush(i32 %17)
%19 = load i8*, i8** %12
%20 = tail call i32 @atoi(i8* %19)
%21 = tail call i32 @usleep(i32 %20)
%22 = tail call i32 @feof(i32* %7)
%23 = icmp eq i32 %22, 0
br i1 %23, label %13, label %24
24: ; preds = %13, %4
%25 = tail call i32 @fclose(i32* %7)
br label %26
26: ; preds = %2, %24
%27 = phi i32 [ 0, %24 ], [ -1, %2 ]
ret i32 %27
}