#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 *, ...);
void dumpUS(unsigned short *us, long vm) {
  long index = 0;
  while (index < vm) {
    printf("%7d ", *(us++));
    if ((++index) % 8 == 0)
      printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dumpUS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    1189 <dumpUS+0x79>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x2,%rcx
mov    %rcx,-0x8(%rbp)
movzwl (%rax),%esi
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    $0x8,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1184 <dumpUS+0x74>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1128 <dumpUS+0x18>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpUS>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
jle    1183 <dumpUS+0x63>
mov    %rsi,%r12
mov    %rdi,%r14
neg    %r12
mov    $0x1,%ebx
lea    0xebe(%rip),%r15
jmp    1162 <dumpUS+0x42>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%r12,%rbx,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    $0x1,%rax
je     1183 <dumpUS+0x63>
movzwl -0x2(%r14,%rbx,2),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x7,%bl
jne    1150 <dumpUS+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1150 <dumpUS+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

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