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

/* Variables and functions */
int read(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ write(int, int /*<<< orphan*/ *, int);
int main() {
  uint8_t buf[8];
  while (8 == read(0, buf, 8)) {
    write(1, &buf[7], 1);
    write(1, &buf[6], 1);
    write(1, &buf[5], 1);
    write(1, &buf[4], 1);
    write(1, &buf[3], 1);
    write(1, &buf[2], 1);
    write(1, &buf[1], 1);
    write(1, &buf[0], 1);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rsi
xor    %edi,%edi
mov    $0x8,%edx
call   1040 <read@plt>
mov    %eax,%ecx
mov    $0x8,%eax
cmp    %ecx,%eax
jne    11ef <main+0xcf>
lea    -0x30(%rbp),%rsi
add    $0x1c,%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1030 <write@plt>
lea    -0x30(%rbp),%rsi
add    $0x18,%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1030 <write@plt>
lea    -0x30(%rbp),%rsi
add    $0x14,%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1030 <write@plt>
lea    -0x30(%rbp),%rsi
add    $0x10,%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1030 <write@plt>
lea    -0x30(%rbp),%rsi
add    $0xc,%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1030 <write@plt>
lea    -0x30(%rbp),%rsi
add    $0x8,%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1030 <write@plt>
lea    -0x30(%rbp),%rsi
add    $0x4,%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1030 <write@plt>
lea    -0x30(%rbp),%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1030 <write@plt>
jmp    112f <main+0xf>
mov    -0x4(%rbp),%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
mov    %rsp,%rsi
xor    %edi,%edi
mov    $0x8,%edx
call   1040 <read@plt>
cmp    $0x8,%eax
jne    121c <main+0xfc>
lea    0x14(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0xc(%rsp),%rbx
lea    0x8(%rsp),%rbp
lea    0x4(%rsp),%r14
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x1,%edi
lea    0x1c(%rsp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
lea    0x18(%rsp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r12,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r13,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
xor    %edi,%edi
mov    %r15,%rsi
mov    $0x8,%edx
call   1040 <read@plt>
cmp    $0x8,%eax
je     1170 <main+0x50>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i32]
store i32 0, i32* %1
br label %3
3: ; preds = %7, %0
%4 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%5 = call i32 @read(i32 0, i32* %4, i32 8)
%6 = icmp eq i32 8, %5
br i1 %6, label %7, label %24
7: ; preds = %3
%8 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 7
%9 = call i32 @write(i32 1, i32* %8, i32 1)
%10 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 6
%11 = call i32 @write(i32 1, i32* %10, i32 1)
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 5
%13 = call i32 @write(i32 1, i32* %12, i32 1)
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 4
%15 = call i32 @write(i32 1, i32* %14, i32 1)
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 3
%17 = call i32 @write(i32 1, i32* %16, i32 1)
%18 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 2
%19 = call i32 @write(i32 1, i32* %18, i32 1)
%20 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 1
%21 = call i32 @write(i32 1, i32* %20, i32 1)
%22 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%23 = call i32 @write(i32 1, i32* %22, i32 1)
br label %3
24: ; preds = %3
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [8 x i32]
%2 = bitcast [8 x i32]* %1 to i8*
%3 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%4 = call i32 @read(i32 0, i32* %3, i32 8)
%5 = icmp eq i32 %4, 8
br i1 %5, label %6, label %25
6: ; preds = %0
%7 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 7
%8 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 6
%9 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 5
%10 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 4
%11 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 3
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 2
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 1
br label %14
14: ; preds = %6, %14
%15 = call i32 @write(i32 1, i32* %7, i32 1)
%16 = call i32 @write(i32 1, i32* %8, i32 1)
%17 = call i32 @write(i32 1, i32* %9, i32 1)
%18 = call i32 @write(i32 1, i32* %10, i32 1)
%19 = call i32 @write(i32 1, i32* %11, i32 1)
%20 = call i32 @write(i32 1, i32* %12, i32 1)
%21 = call i32 @write(i32 1, i32* %13, i32 1)
%22 = call i32 @write(i32 1, i32* %3, i32 1)
%23 = call i32 @read(i32 0, i32* %3, i32 8)
%24 = icmp eq i32 %23, 8
br i1 %24, label %14, label %25
25: ; preds = %14, %0
ret i32 0
}