#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 *, unsigned int);
int /*<<< orphan*/ putchar(char);
void floyd(unsigned n) {
  unsigned i, j, k;
  for (i = k = 1; i <= n; ++i) {
    for (j = 0; j < i; ++j, ++k)
      printf("%3u", k);
    putchar('\n');
  }
}


x86 assembly (clang, -O0):
<floyd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
ja     1196 <floyd+0x76>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    117e <floyd+0x5e>
mov    -0x10(%rbp),%esi
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114c <floyd+0x2c>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1139 <floyd+0x19>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floyd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
je     1189 <floyd+0x69>
mov    %edi,%r14d
mov    $0x1,%r13d
lea    0xec1(%rip),%r15
mov    $0x1,%ebx
jmp    1162 <floyd+0x42>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    %r14d,%ebx
ja     1189 <floyd+0x69>
test   %ebx,%ebx
je     1150 <floyd+0x30>
lea    (%rbx,%r13,1),%r12d
xor    %ebp,%ebp
nopl   0x0(%rax)
lea    0x0(%r13,%rbp,1),%esi
mov    %r15,%rdi
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1170 <floyd+0x50>
mov    %r12d,%r13d
jmp    1150 <floyd+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%3u\00"
define void @floyd(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %5
store i32 1, i32* %3
br label %6
6: ; preds = %25, %1
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = icmp ule i32 %7, %8
br i1 %9, label %10, label %28
10: ; preds = %6
store i32 0, i32* %4
br label %11
11: ; preds = %18, %10
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = icmp ult i32 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i32, i32* %5
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %15
%19 = load i32, i32* %4
%20 = add i32 %19, 1
store i32 %20, i32* %4
%21 = load i32, i32* %5
%22 = add i32 %21, 1
store i32 %22, i32* %5
br label %11
23: ; preds = %11
%24 = call i32 @putchar(i8 signext 10)
br label %25
25: ; preds = %23
%26 = load i32, i32* %3
%27 = add i32 %26, 1
store i32 %27, i32* %3
br label %6
28: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%3u\00"
define void @floyd(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %19, label %3
3: ; preds = %1, %14
%4 = phi i32 [ %15, %14 ], [ 1, %1 ]
%5 = phi i32 [ %17, %14 ], [ 1, %1 ]
%6 = icmp eq i32 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %3
%8 = add i32 %4, %5
br label %9
9: ; preds = %7, %9
%10 = phi i32 [ %12, %9 ], [ %4, %7 ]
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = add i32 %10, 1
%13 = icmp eq i32 %12, %8
br i1 %13, label %14, label %9
14: ; preds = %9, %3
%15 = phi i32 [ %4, %3 ], [ %8, %9 ]
%16 = tail call i32 @putchar(i8 signext 10)
%17 = add i32 %5, 1
%18 = icmp ugt i32 %17, %0
br i1 %18, label %19, label %3
19: ; preds = %14, %1
ret void
}