#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 *, short, short, ...);
bool _assertShortArrayEquals(short *expected, short *actual, int length,
                             int line) {
  int i;
  if (length <= 0) {
    printf("assertShortArrayEquals FAILED, line: %i, negative or zero array "
           "length: %i",
           line, length);
    return false;
  }
  for (i = 0; i < length; i++) {
    if (expected[i] != actual[i]) {
      printf("assertShortArrayEquals FAILED, line: %i, on index %i with array "
             "length %i\n",
             line, i, length);
      printf("expected: %i, actual: %i\n", expected[i], actual[i]);
      return false;
    }
  }
  return true;
}


x86 assembly (clang, -O0):
<_assertShortArrayEquals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     1159 <_assertShortArrayEquals+0x49>
mov    -0x20(%rbp),%eax
mov    %ax,%cx
mov    -0x1c(%rbp),%eax
lea    0xec0(%rip),%rdi
movswl %cx,%esi
movswl %ax,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11fb <_assertShortArrayEquals+0xeb>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11f4 <_assertShortArrayEquals+0xe4>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movswl (%rax,%rcx,2),%eax
mov    -0x18(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movswl (%rcx,%rdx,2),%ecx
cmp    %ecx,%eax
je     11e1 <_assertShortArrayEquals+0xd1>
mov    -0x20(%rbp),%eax
mov    %ax,%dx
mov    -0x24(%rbp),%eax
mov    -0x1c(%rbp),%ecx
lea    0xeac(%rip),%rdi
movswl %dx,%esi
movswl %ax,%edx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,2),%dx
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
lea    0xecf(%rip),%rdi
movswl %dx,%esi
movswl (%rax,%rcx,2),%edx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11fb <_assertShortArrayEquals+0xeb>
jmp    11e6 <_assertShortArrayEquals+0xd6>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1160 <_assertShortArrayEquals+0x50>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_assertShortArrayEquals>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edx,%edx
jle    114c <_assertShortArrayEquals+0x3c>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,%eax
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movzwl (%rbx,%rbp,2),%edx
cmp    (%r14,%rbp,2),%dx
jne    115e <_assertShortArrayEquals+0x4e>
add    $0x1,%rbp
cmp    %rbp,%rax
jne    1130 <_assertShortArrayEquals+0x20>
mov    $0x1,%r15d
jmp    118e <_assertShortArrayEquals+0x7e>
movswl %cx,%esi
movswl %dx,%edx
lea    0xea7(%rip),%rdi
xor    %r15d,%r15d
jmp    1187 <_assertShortArrayEquals+0x77>
movswl %cx,%esi
movswl %bp,%edx
lea    0xee0(%rip),%rdi
xor    %r15d,%r15d
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
movswl (%rbx,%rbp,2),%esi
movswl (%r14,%rbp,2),%edx
lea    0xf0f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [75 x i8] c"assertShortArrayEquals FAILED, line: %i, negative or zero array length: %i\00"
@.str.1 = [75 x i8] c"assertShortArrayEquals FAILED, line: %i, on index %i with array length %i\0A\00"
@.str.2 = [26 x i8] c"expected: %i, actual: %i\0A\00"
define i32 @_assertShortArrayEquals(i16* %0, i16* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i16*
%7 = alloca i16*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i16* %0, i16** %6
store i16* %1, i16** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%11 = load i32, i32* %8
%12 = icmp sle i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %4
%14 = load i32, i32* %9
%15 = trunc i32 %14 to i16
%16 = load i32, i32* %8
%17 = trunc i32 %16 to i16
%18 = call i32 (i8*, i16, i16, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), i16 signext %15, i16 signext %17)
store i32 0, i32* %5
br label %61
19: ; preds = %4
store i32 0, i32* %10
br label %20
20: ; preds = %57, %19
%21 = load i32, i32* %10
%22 = load i32, i32* %8
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %60
24: ; preds = %20
%25 = load i16*, i16** %6
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i16, i16* %25, i64 %27
%29 = load i16, i16* %28
%30 = sext i16 %29 to i32
%31 = load i16*, i16** %7
%32 = load i32, i32* %10
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i16, i16* %31, i64 %33
%35 = load i16, i16* %34
%36 = sext i16 %35 to i32
%37 = icmp ne i32 %30, %36
br i1 %37, label %38, label %56
38: ; preds = %24
%39 = load i32, i32* %9
%40 = trunc i32 %39 to i16
%41 = load i32, i32* %10
%42 = trunc i32 %41 to i16
%43 = load i32, i32* %8
%44 = call i32 (i8*, i16, i16, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0), i16 signext %40, i16 signext %42, i32 %43)
%45 = load i16*, i16** %6
%46 = load i32, i32* %10
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i16, i16* %45, i64 %47
%49 = load i16, i16* %48
%50 = load i16*, i16** %7
%51 = load i32, i32* %10
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i16, i16* %50, i64 %52
%54 = load i16, i16* %53
%55 = call i32 (i8*, i16, i16, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i16 signext %49, i16 signext %54)
store i32 0, i32* %5
br label %61
56: ; preds = %24
br label %57
57: ; preds = %56
%58 = load i32, i32* %10
%59 = add nsw i32 %58, 1
store i32 %59, i32* %10
br label %20
60: ; preds = %20
store i32 1, i32* %5
br label %61
61: ; preds = %60, %38, %13
%62 = load i32, i32* %5
ret i32 %62
}

LLVM IR (-O2):
@.str = [75 x i8] c"assertShortArrayEquals FAILED, line: %i, negative or zero array length: %i\00"
@.str.1 = [75 x i8] c"assertShortArrayEquals FAILED, line: %i, on index %i with array length %i\0A\00"
@.str.2 = [26 x i8] c"expected: %i, actual: %i\0A\00"
define i32 @_assertShortArrayEquals(i16* nocapture %0, i16* nocapture %1, i32 %2, i32 %3) {
%5 = icmp slt i32 %2, 1
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = zext i32 %2 to i64
br label %12
8: ; preds = %4
%9 = trunc i32 %3 to i16
%10 = trunc i32 %2 to i16
%11 = tail call i32 (i8*, i16, i16, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), i16 signext %9, i16 signext %10)
br label %32
12: ; preds = %6, %29
%13 = phi i64 [ 0, %6 ], [ %30, %29 ]
%14 = getelementptr inbounds i16, i16* %0, i64 %13
%15 = load i16, i16* %14
%16 = getelementptr inbounds i16, i16* %1, i64 %13
%17 = load i16, i16* %16
%18 = icmp eq i16 %15, %17
br i1 %18, label %29, label %19
19: ; preds = %12
%20 = and i64 %13, 4294967295
%21 = getelementptr inbounds i16, i16* %0, i64 %20
%22 = getelementptr inbounds i16, i16* %1, i64 %20
%23 = trunc i32 %3 to i16
%24 = trunc i64 %13 to i16
%25 = tail call i32 (i8*, i16, i16, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0), i16 signext %23, i16 signext %24, i32 %2)
%26 = load i16, i16* %21
%27 = load i16, i16* %22
%28 = tail call i32 (i8*, i16, i16, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i16 signext %26, i16 signext %27)
br label %32
29: ; preds = %12
%30 = add nuw nsw i64 %13, 1
%31 = icmp eq i64 %30, %7
br i1 %31, label %32, label %12
32: ; preds = %29, %19, %8
%33 = phi i32 [ 0, %8 ], [ 0, %19 ], [ 1, %29 ]
ret i32 %33
}