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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int read(int /*<<< orphan*/, unsigned char *, int);
main() {
  unsigned char buf[8];
  int i, len;
  while ((len = read(0, buf, sizeof(buf))) > 0) {
    for (i = 0; i < len; i++)
      printf("%3d ", buf[i]);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rsi
xor    %edi,%edi
mov    $0x8,%edx
call   1040 <read@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    1196 <main+0x76>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1183 <main+0x63>
movslq -0x10(%rbp),%rax
movzbl -0xc(%rbp,%rax,1),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1152 <main+0x32>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsp,%rsi
xor    %edi,%edi
mov    $0x8,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    11a4 <main+0x74>
lea    0xeae(%rip),%r15
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%r12d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rsp,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1170 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
mov    %r14,%rsi
mov    $0x8,%edx
call   1050 <read@plt>
test   %eax,%eax
jg     1160 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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