#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 EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, float, unsigned int);
int scanf(char *, float *, char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, unsigned int *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  char *access_kind;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s {read|write}", argv[0]);
    exit(1);
  }
  access_kind = argv[1];
  fprintf(stderr, "start.\n");
  while (1) {
    int ret;
    float v;
    char s[1024], a[1024];
    unsigned int n;
    ret = scanf("%f%s%s", &v, a, s);
    if (ret == 0)
      break;
    if (ret == EOF)
      break;
    if (strcmp(a, access_kind) == 0) {
      sscanf(s + 2, "%x", &n);
      printf("%f %d\n", v, n >> 12);
    }
  }
  fprintf(stderr, "finish.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11ab <main+0x4b>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
lea    -0x820(%rbp),%rdx
lea    -0x420(%rbp),%rcx
lea    0xe3c(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <scanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11fe <main+0x9e>
jmp    126c <main+0x10c>
mov    -0x1c(%rbp),%eax
mov    0x2de0(%rip),%rcx
cmp    (%rcx),%eax
jne    1215 <main+0xb5>
jmp    126c <main+0x10c>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1267 <main+0x107>
lea    -0x420(%rbp),%rdi
add    $0x2,%rdi
lea    0xde5(%rip),%rsi
lea    -0x824(%rbp),%rdx
call   1060 <sscanf@plt>
movss  -0x20(%rbp),%xmm0
mov    -0x824(%rbp),%esi
shr    $0xc,%esi
lea    0xdc7(%rip),%rdi
call   1030 <printf@plt>
jmp    11ce <main+0x6e>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
lea    0xdb4(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
cmp    $0x2,%edi
jne    1264 <main+0x104>
mov    0x8(%rsi),%r15
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe83(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x410(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1070 <scanf@plt>
test   %eax,%eax
je     1239 <main+0xd9>
mov    0x2e26(%rip),%rbp
cmp    0x0(%rbp),%eax
je     1239 <main+0xd9>
lea    0x410(%rsp),%rbx
lea    0xe49(%rip),%r14
lea    0x8(%rsp),%r12
lea    0x10(%rsp),%r13
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    121f <main+0xbf>
lea    0x12(%rsp),%rdi
lea    0xe2a(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1060 <sscanf@plt>
movss  0x8(%rsp),%xmm0
mov    0xc(%rsp),%esi
shr    $0xc,%esi
lea    0xe0f(%rip),%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
call   1070 <scanf@plt>
test   %eax,%eax
je     1239 <main+0xd9>
cmp    0x0(%rbp),%eax
jne    11e0 <main+0x80>
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
lea    0xde7(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xd89(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"Usage: %s {read|write}\00"
@.str.1 = [8 x i8] c"start.\0A\00"
@.str.2 = [7 x i8] c"%f%s%s\00"
@EOF = global i32 0
@.str.3 = [3 x i8] c"%x\00"
@.str.4 = [7 x i8] c"%f %d\0A\00"
@.str.5 = [9 x i8] c"finish.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca float
%9 = alloca [1024 x i8]
%10 = alloca [1024 x i8]
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
store i8* %24, i8** %6
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %21, %52
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%30 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), float* %8, i8* %28, i8* %29)
store i32 %30, i32* %7
%31 = load i32, i32* %7
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %27
br label %53
34: ; preds = %27
%35 = load i32, i32* %7
%36 = load i32, i32* @EOF
%37 = icmp eq i32 %35, %36
br i1 %37, label %38, label %39
38: ; preds = %34
br label %53
39: ; preds = %34
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%41 = load i8*, i8** %6
%42 = call i64 @strcmp(i8* %40, i8* %41)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %52
44: ; preds = %39
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%46 = getelementptr inbounds i8, i8* %45, i64 2
%47 = call i32 @sscanf(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %11)
%48 = load float, float* %8
%49 = load i32, i32* %11
%50 = lshr i32 %49, 12
%51 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), float %48, i32 %50)
br label %52
52: ; preds = %44, %39
br label %27
53: ; preds = %38, %33
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"Usage: %s {read|write}\00"
@.str.1 = [8 x i8] c"start.\0A\00"
@.str.2 = [7 x i8] c"%f%s%s\00"
@EOF = global i32 0
@.str.3 = [3 x i8] c"%x\00"
@.str.4 = [7 x i8] c"%f %d\0A\00"
@.str.5 = [9 x i8] c"finish.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca float
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca i32
%7 = icmp eq i32 %0, 2
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%18 = bitcast float* %3 to i8*
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%21 = bitcast i32* %6 to i8*
%22 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), float* %3, i8* %20, i8* %19)
%23 = icmp eq i32 %22, 0
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %22, %24
%26 = select i1 %23, i1 true, i1 %25
br i1 %26, label %44, label %27
27: ; preds = %13
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 2
br label %29
29: ; preds = %27, %38
%30 = call i64 @strcmp(i8* %20, i8* %15)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = call i32 @sscanf(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%34 = load float, float* %3
%35 = load i32, i32* %6
%36 = lshr i32 %35, 12
%37 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), float %34, i32 %36)
br label %38
38: ; preds = %29, %32
%39 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), float* %3, i8* %20, i8* %19)
%40 = icmp eq i32 %39, 0
%41 = load i32, i32* @EOF
%42 = icmp eq i32 %39, %41
%43 = select i1 %40, i1 true, i1 %42
br i1 %43, label %44, label %29
44: ; preds = %38, %13
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}