#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*/ assert(int);
scalar_t__ compare_array(int *, int *, int);
void test_compare_array() {
  int a[] = {1, 2, 3};
  int b[] = {1, 2, 5};
  assert(compare_array(a, a, 3));
  assert(compare_array(a, b, 2));
  assert(compare_array(a, b, 3) == 0);
}


x86 assembly (clang, -O0):
<test_compare_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xecf(%rip),%eax
mov    %eax,-0x4(%rbp)
mov    0xec9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec7(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0xc(%rbp),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x3,%edx
call   1040 <compare_array@plt>
mov    %eax,%edi
call   1030 <assert@plt>
lea    -0xc(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x2,%edx
call   1040 <compare_array@plt>
mov    %eax,%edi
call   1030 <assert@plt>
lea    -0xc(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x3,%edx
call   1040 <compare_array@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_compare_array>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    0xedb(%rip),%eax
mov    %eax,0x20(%rsp)
mov    0xec8(%rip),%rax
mov    %rax,0x18(%rsp)
mov    0xed1(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xebe(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1040 <compare_array@plt>
mov    %eax,%edi
call   1030 <assert@plt>
lea    0x8(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1040 <compare_array@plt>
mov    %eax,%edi
call   1030 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1040 <compare_array@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1030 <assert@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.test_compare_array.a = [3 x i32] [i32 1, i32 2, i32 3]
@__const.test_compare_array.b = [3 x i32] [i32 1, i32 2, i32 5]
define void @test_compare_array() {
%1 = alloca [3 x i32]
%2 = alloca [3 x i32]
%3 = bitcast [3 x i32]* %1 to i8*
%4 = bitcast [3 x i32]* %2 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%7 = call i64 @compare_array(i32* %5, i32* %6, i32 3)
%8 = trunc i64 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%12 = call i64 @compare_array(i32* %10, i32* %11, i32 2)
%13 = trunc i64 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%16 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%17 = call i64 @compare_array(i32* %15, i32* %16, i32 3)
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
ret void
}

LLVM IR (-O2):
@__const.test_compare_array.a = [3 x i32] [i32 1, i32 2, i32 3]
@__const.test_compare_array.b = [3 x i32] [i32 1, i32 2, i32 5]
define void @test_compare_array() {
%1 = alloca [3 x i32]
%2 = alloca [3 x i32]
%3 = bitcast [3 x i32]* %1 to i8*
%4 = bitcast [3 x i32]* %2 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%6 = call i64 @compare_array(i32* %5, i32* %5, i32 3)
%7 = trunc i64 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%10 = call i64 @compare_array(i32* %5, i32* %9, i32 2)
%11 = trunc i64 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i64 @compare_array(i32* %5, i32* %9, i32 3)
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
ret void
}