#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 get_length(int *, int, int);
int get_length_brute(int *, int, int);
int test_target_small() {
  int array_start[] = {5, 2, 3, 1, 4};
  int array_end[] = {4, 2, 3, 1, 5};
  return 1 == get_length_brute(array_start, 5, 5) &&
         1 == get_length_brute(array_end, 5, 5) &&
         1 == get_length(array_start, 5, 5) && 1 == get_length(array_end, 5, 5);
}


x86 assembly (clang, -O0):
<test_target_small>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xecc(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xed2(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xecf(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xecd(%rip),%eax
mov    %eax,-0x30(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x5,%edx
mov    %edx,%esi
call   1030 <get_length_brute@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %edx,%ecx
mov    %al,-0x41(%rbp)
jne    11f1 <test_target_small+0xd1>
lea    -0x40(%rbp),%rdi
mov    $0x5,%edx
mov    %edx,%esi
call   1030 <get_length_brute@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %edx,%ecx
mov    %al,-0x41(%rbp)
jne    11f1 <test_target_small+0xd1>
lea    -0x20(%rbp),%rdi
mov    $0x5,%edx
mov    %edx,%esi
call   1040 <get_length@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %edx,%ecx
mov    %al,-0x41(%rbp)
jne    11f1 <test_target_small+0xd1>
lea    -0x40(%rbp),%rdi
mov    $0x5,%edx
mov    %edx,%esi
call   1040 <get_length@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_target_small>:
push   %rbx
sub    $0x40,%rsp
mov    0xee5(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xeca(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    0xeef(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xed4(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x20(%rsp),%rdi
mov    $0x5,%esi
mov    $0x5,%edx
call   1030 <get_length_brute@plt>
xor    %ebx,%ebx
cmp    $0x1,%eax
jne    11b5 <test_target_small+0x95>
mov    %rsp,%rdi
mov    $0x5,%esi
mov    $0x5,%edx
call   1030 <get_length_brute@plt>
cmp    $0x1,%eax
jne    11b5 <test_target_small+0x95>
lea    0x20(%rsp),%rdi
mov    $0x5,%esi
mov    $0x5,%edx
call   1040 <get_length@plt>
cmp    $0x1,%eax
jne    11b5 <test_target_small+0x95>
mov    %rsp,%rdi
mov    $0x5,%esi
mov    $0x5,%edx
call   1040 <get_length@plt>
xor    %ebx,%ebx
cmp    $0x1,%eax
sete   %bl
mov    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test_target_small.array_start = [5 x i32] [i32 5, i32 2, i32 3, i32 1, i32 4]
@__const.test_target_small.array_end = [5 x i32] [i32 4, i32 2, i32 3, i32 1, i32 5]
define i32 @test_target_small() {
%1 = alloca [5 x i32]
%2 = alloca [5 x i32]
%3 = bitcast [5 x i32]* %1 to i8*
%4 = bitcast [5 x i32]* %2 to i8*
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%6 = call i32 @get_length_brute(i32* %5, i32 5, i32 5)
%7 = icmp eq i32 1, %6
br i1 %7, label %8, label %20
8: ; preds = %0
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%10 = call i32 @get_length_brute(i32* %9, i32 5, i32 5)
%11 = icmp eq i32 1, %10
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%14 = call i32 @get_length(i32* %13, i32 5, i32 5)
%15 = icmp eq i32 1, %14
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%18 = call i32 @get_length(i32* %17, i32 5, i32 5)
%19 = icmp eq i32 1, %18
br label %20
20: ; preds = %16, %12, %8, %0
%21 = phi i1 [ false, %12 ], [ false, %8 ], [ false, %0 ], [ %19, %16 ]
%22 = zext i1 %21 to i32
ret i32 %22
}

LLVM IR (-O2):
@__const.test_target_small.array_start = [5 x i32] [i32 5, i32 2, i32 3, i32 1, i32 4]
@__const.test_target_small.array_end = [5 x i32] [i32 4, i32 2, i32 3, i32 1, i32 5]
define i32 @test_target_small() {
%1 = alloca [5 x i32]
%2 = alloca [5 x i32]
%3 = bitcast [5 x i32]* %1 to i8*
%4 = bitcast [5 x i32]* %2 to i8*
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%6 = call i32 @get_length_brute(i32* %5, i32 5, i32 5)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %19
8: ; preds = %0
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%10 = call i32 @get_length_brute(i32* %9, i32 5, i32 5)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = call i32 @get_length(i32* %5, i32 5, i32 5)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = call i32 @get_length(i32* %9, i32 5, i32 5)
%17 = icmp eq i32 %16, 1
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %15, %12, %8, %0
%20 = phi i32 [ 0, %12 ], [ 0, %8 ], [ 0, %0 ], [ %18, %15 ]
ret i32 %20
}