#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, char);
void form_out(char text[1000], int len) {
  int i = 0;
  for (i = 0; i <= len; ++i) {
    printf("%6c%c", text[i], (i % 10 == 9 || i == len - 1) ? '\n' : ' ');
  };
}


x86 assembly (clang, -O0):
<form_out>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11a9 <form_out+0x99>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x12(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0x1,%al
cmp    $0x9,%edx
mov    %al,-0x11(%rbp)
je     1171 <form_out+0x61>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x12(%rbp),%cl
mov    -0x11(%rbp),%sil
mov    $0x20,%eax
mov    $0xa,%edx
test   $0x1,%sil
cmovne %edx,%eax
lea    0xe70(%rip),%rdi
movsbl %cl,%esi
movsbl %al,%edx
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112d <form_out+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<form_out>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
js     1181 <form_out+0x71>
mov    %esi,%r13d
mov    %rdi,%r14
lea    -0x1(%r13),%r12d
add    $0x1,%r13d
xor    %ebx,%ebx
mov    $0xcccccccd,%ebp
lea    0xec5(%rip),%r15
jmp    1156 <form_out+0x46>
nopl   (%rax)
movsbl (%r14,%rbx,1),%esi
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
je     1181 <form_out+0x71>
mov    %ebx,%eax
imul   %rbp,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,1),%ecx
add    $0x9,%ecx
cmp    %rbx,%r12
mov    $0xa,%edx
mov    $0x20,%eax
cmove  %edx,%eax
cmp    %ebx,%ecx
je     1140 <form_out+0x30>
mov    %eax,%edx
jmp    1140 <form_out+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%6c%c\00"
define void @form_out(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %5
br label %6
6: ; preds = %30, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %33
10: ; preds = %6
%11 = load i8*, i8** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = load i32, i32* %5
%17 = srem i32 %16, 10
%18 = icmp eq i32 %17, 9
br i1 %18, label %24, label %19
19: ; preds = %10
%20 = load i32, i32* %5
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 1
%23 = icmp eq i32 %20, %22
br label %24
24: ; preds = %19, %10
%25 = phi i1 [ true, %10 ], [ %23, %19 ]
%26 = zext i1 %25 to i64
%27 = select i1 %25, i32 10, i32 32
%28 = trunc i32 %27 to i8
%29 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 signext %15, i8 signext %28)
br label %30
30: ; preds = %24
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %6
33: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%6c%c\00"
define void @form_out(i8* nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 0
br i1 %3, label %22, label %4
4: ; preds = %2
%5 = add nsw i32 %1, -1
%6 = zext i32 %5 to i64
%7 = add nuw i32 %1, 1
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %4, %9
%10 = phi i64 [ 0, %4 ], [ %20, %9 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = trunc i64 %10 to i32
%14 = urem i32 %13, 10
%15 = icmp eq i32 %14, 9
%16 = icmp eq i64 %10, %6
%17 = select i1 %15, i1 true, i1 %16
%18 = select i1 %17, i8 10, i8 32
%19 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 signext %12, i8 signext %18)
%20 = add nuw nsw i64 %10, 1
%21 = icmp eq i64 %20, %8
br i1 %21, label %22, label %9
22: ; preds = %9, %2
ret void
}