#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 PrintShortArray(char *lab, int n, short *sa) {
  int i;
  if (lab)
    printf("%s", lab);
  printf("%hi", *sa);
  for (i = 1; i < n; i++)
    printf(", %hi", sa[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<PrintShortArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1140 <PrintShortArray+0x30>
mov    -0x8(%rbp),%rsi
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movswl (%rax),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1190 <PrintShortArray+0x80>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movswl (%rax,%rcx,2),%esi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115c <PrintShortArray+0x4c>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintShortArray>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %esi,%ebp
test   %rdi,%rdi
je     1142 <PrintShortArray+0x22>
mov    %rdi,%rsi
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movswl (%r15),%esi
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%ebp
jl     1188 <PrintShortArray+0x68>
mov    %ebp,%ebp
mov    $0x1,%ebx
lea    0xe9c(%rip),%r14
nopw   0x0(%rax,%rax,1)
movswl (%r15,%rbx,2),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1170 <PrintShortArray+0x50>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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