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


x86 assembly (clang, -O0):
<test_target_medium>:
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,%esi
mov    $0x7,%edx
call   1030 <get_length_brute@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x2,%ecx
cmp    %edx,%ecx
mov    %al,-0x41(%rbp)
jne    11fd <test_target_medium+0xdd>
lea    -0x40(%rbp),%rdi
mov    $0x5,%esi
mov    $0x7,%edx
call   1030 <get_length_brute@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x2,%ecx
cmp    %edx,%ecx
mov    %al,-0x41(%rbp)
jne    11fd <test_target_medium+0xdd>
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
mov    $0x7,%edx
call   1040 <get_length@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x2,%ecx
cmp    %edx,%ecx
mov    %al,-0x41(%rbp)
jne    11fd <test_target_medium+0xdd>
lea    -0x40(%rbp),%rdi
mov    $0x5,%esi
mov    $0x7,%edx
call   1040 <get_length@plt>
mov    %eax,%ecx
mov    $0x2,%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_medium>:
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    $0x7,%edx
call   1030 <get_length_brute@plt>
xor    %ebx,%ebx
cmp    $0x2,%eax
jne    11b5 <test_target_medium+0x95>
mov    %rsp,%rdi
mov    $0x5,%esi
mov    $0x7,%edx
call   1030 <get_length_brute@plt>
cmp    $0x2,%eax
jne    11b5 <test_target_medium+0x95>
lea    0x20(%rsp),%rdi
mov    $0x5,%esi
mov    $0x7,%edx
call   1040 <get_length@plt>
cmp    $0x2,%eax
jne    11b5 <test_target_medium+0x95>
mov    %rsp,%rdi
mov    $0x5,%esi
mov    $0x7,%edx
call   1040 <get_length@plt>
xor    %ebx,%ebx
cmp    $0x2,%eax
sete   %bl
mov    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test_target_medium.array_start = [5 x i32] [i32 5, i32 2, i32 3, i32 1, i32 4]
@__const.test_target_medium.array_end = [5 x i32] [i32 2, i32 3, i32 1, i32 4, i32 5]
define i32 @test_target_medium() {
%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 7)
%7 = icmp eq i32 2, %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 7)
%11 = icmp eq i32 2, %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 7)
%15 = icmp eq i32 2, %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 7)
%19 = icmp eq i32 2, %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_medium.array_start = [5 x i32] [i32 5, i32 2, i32 3, i32 1, i32 4]
@__const.test_target_medium.array_end = [5 x i32] [i32 2, i32 3, i32 1, i32 4, i32 5]
define i32 @test_target_medium() {
%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 7)
%7 = icmp eq i32 %6, 2
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 7)
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = call i32 @get_length(i32* %5, i32 5, i32 7)
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = call i32 @get_length(i32* %9, i32 5, i32 7)
%17 = icmp eq i32 %16, 2
%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
}