#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*/ printf(char *, char);
int vmem_read(int);
void display_data(int length) {
  int i;
  for (i = 0; i < length; i++) {
    printf("%10d", vmem_read(i));
    printf("%c", ((i + 1) % 8) ? ' ' : '\n');
  }
}


x86 assembly (clang, -O0):
<display_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1190 <display_data+0x70>
mov    -0x8(%rbp),%edi
call   1030 <vmem_read@plt>
lea    0xeb3(%rip),%rdi
movsbl %al,%esi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    $0xa,%eax
mov    $0x20,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
lea    0xe8b(%rip),%rdi
movsbl %al,%esi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <display_data+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_data>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edi,%edi
jle    117e <display_data+0x5e>
mov    %edi,%ebx
xor    %ebp,%ebp
lea    0xec9(%rip),%r14
mov    $0xa,%r12d
lea    0xec1(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
call   1030 <vmem_read@plt>
movsbl %al,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%ebp
test   $0x7,%bpl
mov    $0x20,%esi
cmove  %r12d,%esi
mov    %r15,%rdi
call   1040 <printf@plt>
cmp    %ebp,%ebx
jne    1150 <display_data+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%10d\00"
@.str.1 = [3 x i8] c"%c\00"
define void @display_data(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %14
3: ; preds = %1, %3
%4 = phi i32 [ %8, %3 ], [ 0, %1 ]
%5 = tail call i32 @vmem_read(i32 %4)
%6 = trunc i32 %5 to i8
%7 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %6)
%8 = add nuw nsw i32 %4, 1
%9 = and i32 %8, 7
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i8 10, i8 32
%12 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %11)
%13 = icmp eq i32 %8, %0
br i1 %13, label %14, label %3
14: ; preds = %3, %1
ret void
}