#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 const *, ...);
void print_short_array(unsigned short *a, size_t width) {
  int i;
  printf("{\n");
  for (i = 0; i <= 0xFF; i++) {
    const char *fmt = (width == 4) ? "0x%04X" : "0x%02X";
    printf(fmt, (int)a[i]);
    printf("%s%s", i < 0xFF ? "," : "", (i + 1) % 8 ? "" : "\n");
  }
  printf("};\n");
}


x86 assembly (clang, -O0):
<print_short_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xff,-0x14(%rbp)
jg     11d3 <print_short_array+0xc3>
mov    -0x10(%rbp),%rdx
lea    0xebd(%rip),%rax
lea    0xeaf(%rip),%rcx
cmp    $0x4,%rdx
cmove  %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzwl (%rax,%rcx,2),%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%ecx
lea    0xe9a(%rip),%rsi
lea    0xe8e(%rip),%rax
cmp    $0xff,%ecx
cmovl  %rax,%rsi
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
lea    0xe71(%rip),%rdx
lea    0xe6b(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1135 <print_short_array+0x25>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_short_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x4,%rbx
lea    0xeb8(%rip),%rax
lea    0xeb8(%rip),%r12
cmove  %rax,%r12
mov    $0xffffffffffffff00,%r13
lea    0xeb5(%rip),%rbx
lea    0xea6(%rip),%r15
mov    $0xffffffffffffff00,%rbp
nop
movzwl 0x200(%r14,%r13,2),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
inc    %rbp
lea    0xe86(%rip),%rsi
cmove  %rbx,%rsi
add    $0x101,%r13d
test   $0x7,%r13b
mov    %rbx,%rdx
lea    0xe6f(%rip),%rax
cmove  %rax,%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%r13
test   %rbp,%rbp
jne    1170 <print_short_array+0x50>
lea    0xe56(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

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

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