#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 *, int const);
int /*<<< orphan*/ putchar(char);
void print(const int *x, int n) {
  if (!x || !n)
    return;
  int i, wrap;
  for (i = wrap = 0; i < n; i++, wrap++) {
    if (wrap % 8 == 0)
      putchar('\n');
    printf("%6d", x[i]);
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1144 <print+0x24>
cmpl   $0x0,-0xc(%rbp)
jne    1149 <print+0x29>
jmp    11b9 <print+0x99>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11af <print+0x8f>
mov    -0x14(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1181 <print+0x61>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1157 <print+0x37>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
test   %rdi,%rdi
je     1176 <print+0x56>
test   %esi,%esi
je     1176 <print+0x56>
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
jle    1177 <print+0x57>
mov    %rdi,%r15
mov    %esi,%r12d
xor    %ebx,%ebx
lea    0xebe(%rip),%r14
jmp    1165 <print+0x45>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
je     1177 <print+0x57>
test   $0x7,%bl
jne    1150 <print+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1150 <print+0x30>
ret
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

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