#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*/ _IONBF;
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int /*<<< orphan*/ ferror(int /*<<< orphan*/);
double now();
int /*<<< orphan*/ print_command();
int /*<<< orphan*/ print_status();
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int main() {
  double start = now();
  setvbuf(stdout, NULL, _IONBF, 0);
  while (!feof(stdin) && !ferror(stdin)) {
    char callname[16];
    scanf("%[^(](%*[^\"]\"", callname);
    printf("%8.3f ", now() - start);
    if (strcmp(callname, "read") == 0) {
      print_status();
    } else if (strcmp(callname, "write") == 0) {
      print_command();
    }
    scanf("%*[^\n]\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   10b0 <now@plt>
movsd  %xmm0,-0x10(%rbp)
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
mov    0x2e25(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1090 <setvbuf@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
call   1080 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
jne    11ff <main+0x6f>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    120f <main+0x7f>
jmp    1298 <main+0x108>
lea    -0x20(%rbp),%rsi
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   10a0 <scanf@plt>
mov    $0x0,%al
call   10b0 <now@plt>
subsd  -0x10(%rbp),%xmm0
lea    0xdda(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xdd1(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    125f <main+0xcf>
mov    $0x0,%al
call   1060 <print_status@plt>
jmp    1285 <main+0xf5>
lea    -0x20(%rbp),%rdi
lea    0xdb0(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1280 <main+0xf0>
mov    $0x0,%al
call   1050 <print_command@plt>
jmp    1285 <main+0xf5>
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   10a0 <scanf@plt>
jmp    11c8 <main+0x38>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xor    %eax,%eax
call   10b0 <now@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
mov    0x2e25(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1090 <setvbuf@plt>
mov    0x2e1b(%rip),%rbp
mov    0x0(%rbp),%edi
call   1080 <feof@plt>
test   %eax,%eax
je     11ea <main+0x5a>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe0f(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xe11(%rip),%r15
lea    0xe11(%rip),%r12
lea    0xe15(%rip),%r13
jmp    122d <main+0x9d>
nopl   (%rax)
xor    %eax,%eax
call   1060 <print_status@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   10a0 <scanf@plt>
mov    0x0(%rbp),%edi
call   1080 <feof@plt>
test   %eax,%eax
jne    11d9 <main+0x49>
mov    0x0(%rbp),%edi
call   1030 <ferror@plt>
test   %eax,%eax
jne    11d9 <main+0x49>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
xor    %eax,%eax
call   10b0 <now@plt>
subsd  0x8(%rsp),%xmm0
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1210 <main+0x80>
mov    %rbx,%rdi
lea    0xda5(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1217 <main+0x87>
xor    %eax,%eax
call   1050 <print_command@plt>
jmp    1217 <main+0x87>

LLVM IR (-O0):
@stdout = global i32 0
@_IONBF = global i32 0
@stdin = global i32 0
@.str = [14 x i8] c"%[^(](%*[^\22]\22\00"
@.str.1 = [7 x i8] c"%8.3f \00"
@.str.2 = [5 x i8] c"read\00"
@.str.3 = [6 x i8] c"write\00"
@.str.4 = [8 x i8] c"%*[^\0A]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca [16 x i8]
store i32 0, i32* %1
%4 = call double (...) @now()
store double %4, double* %2
%5 = load i32, i32* @stdout
%6 = load i32, i32* @_IONBF
%7 = call i32 @setvbuf(i32 %5, i32* null, i32 %6, i32 0)
br label %8
8: ; preds = %38, %0
%9 = load i32, i32* @stdin
%10 = call i32 @feof(i32 %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %8
%13 = load i32, i32* @stdin
%14 = call i32 @ferror(i32 %13)
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
br label %17
17: ; preds = %12, %8
%18 = phi i1 [ false, %8 ], [ %16, %12 ]
br i1 %18, label %19, label %40
19: ; preds = %17
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call double (...) @now()
%23 = load double, double* %2
%24 = fsub double %22, %23
%25 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %24)
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %19
%30 = call i32 (...) @print_status()
br label %38
31: ; preds = %19
%32 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 (...) @print_command()
br label %37
37: ; preds = %35, %31
br label %38
38: ; preds = %37, %29
%39 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %8
40: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@_IONBF = global i32 0
@stdin = global i32 0
@.str = [14 x i8] c"%[^(](%*[^\22]\22\00"
@.str.1 = [7 x i8] c"%8.3f \00"
@.str.2 = [5 x i8] c"read\00"
@.str.3 = [6 x i8] c"write\00"
@.str.4 = [8 x i8] c"%*[^\0A]\0A\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = tail call double (...) @now()
%3 = load i32, i32* @stdout
%4 = load i32, i32* @_IONBF
%5 = tail call i32 @setvbuf(i32 %3, i32* null, i32 %4, i32 0)
%6 = load i32, i32* @stdin
%7 = call i32 @feof(i32 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %34
9: ; preds = %0
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
br label %11
11: ; preds = %9, %29
%12 = load i32, i32* @stdin
%13 = call i32 @ferror(i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %34
15: ; preds = %11
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %10)
%17 = call double (...) @now()
%18 = fsub double %17, %2
%19 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %18)
%20 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = call i32 (...) @print_status()
br label %29
24: ; preds = %15
%25 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 (...) @print_command()
br label %29
29: ; preds = %24, %27, %22
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%31 = load i32, i32* @stdin
%32 = call i32 @feof(i32 %31)
%33 = icmp eq i32 %32, 0
br i1 %33, label %11, label %34
34: ; preds = %11, %29, %0
ret i32 0
}