#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 count(int, int *, int);
int /*<<< orphan*/ printArray(int *, int);
int /*<<< orphan*/ printf(char *, int, int);
int main() {
  int a1[5] = {1, 2, 3, 4, 5};
  int number = 2;
  printArray(a1, 5);
  printf(", %i, %i\n", number, count(number, a1, 5));
  int a2[5] = {2, 2, 2, 2, 2};
  number = 2;
  printArray(a2, 5);
  printf(", %i, %i\n", number, count(number, a2, 5));
  int a3[1] = {2};
  number = 0;
  printArray(a3, 5);
  printf(", %i, %i\n", number, count(number, a3, 5));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x2,-0x24(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1050 <printArray@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x5,%edx
call   1030 <count@plt>
mov    -0x50(%rbp),%esi
mov    %eax,%edx
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
mov    0xe7e(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe7b(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe79(%rip),%eax
mov    %eax,-0x30(%rbp)
movl   $0x2,-0x24(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0x5,%esi
call   1050 <printArray@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x5,%edx
call   1030 <count@plt>
mov    -0x4c(%rbp),%esi
mov    %eax,%edx
lea    0xe42(%rip),%rdi
call   1040 <printf@plt>
mov    0xe43(%rip),%eax
mov    %eax,-0x44(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x44(%rbp),%rdi
mov    $0x5,%esi
call   1050 <printArray@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x44(%rbp),%rsi
mov    $0x5,%edx
call   1030 <count@plt>
mov    -0x48(%rbp),%esi
mov    %eax,%edx
lea    0xdfc(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    0xed3(%rip),%eax
mov    %eax,0x40(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1050 <printArray@plt>
mov    $0x2,%edi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1030 <count@plt>
lea    0xebc(%rip),%r14
mov    %r14,%rdi
mov    $0x2,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    0xea3(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xe88(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1050 <printArray@plt>
mov    $0x2,%edi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1030 <count@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    %eax,%edx
call   1040 <printf@plt>
movl   $0x2,0xc(%rsp)
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1050 <printArray@plt>
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1030 <count@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.a1 = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@.str = [10 x i8] c", %i, %i\0A\00"
@__const.main.a2 = [5 x i32] [i32 2, i32 2, i32 2, i32 2, i32 2]
@__const.main.a3 = [1 x i32] [i32 2]
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
%4 = alloca [5 x i32]
%5 = alloca [1 x i32]
store i32 0, i32* %1
%6 = bitcast [5 x i32]* %2 to i8*
store i32 2, i32* %3
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%8 = call i32 @printArray(i32* %7, i32 5)
%9 = load i32, i32* %3
%10 = load i32, i32* %3
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%12 = call i32 @count(i32 %10, i32* %11, i32 5)
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12)
%14 = bitcast [5 x i32]* %4 to i8*
store i32 2, i32* %3
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%16 = call i32 @printArray(i32* %15, i32 5)
%17 = load i32, i32* %3
%18 = load i32, i32* %3
%19 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%20 = call i32 @count(i32 %18, i32* %19, i32 5)
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %20)
%22 = bitcast [1 x i32]* %5 to i8*
store i32 0, i32* %3
%23 = getelementptr inbounds [1 x i32], [1 x i32]* %5, i64 0, i64 0
%24 = call i32 @printArray(i32* %23, i32 5)
%25 = load i32, i32* %3
%26 = load i32, i32* %3
%27 = getelementptr inbounds [1 x i32], [1 x i32]* %5, i64 0, i64 0
%28 = call i32 @count(i32 %26, i32* %27, i32 5)
%29 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %28)
ret i32 0
}

LLVM IR (-O2):
@__const.main.a1 = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@.str = [10 x i8] c", %i, %i\0A\00"
@__const.main.a2 = [5 x i32] [i32 2, i32 2, i32 2, i32 2, i32 2]
define i32 @main() {
%1 = alloca [5 x i32]
%2 = alloca [5 x i32]
%3 = alloca [1 x i32]
%4 = bitcast [5 x i32]* %1 to i8*
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%6 = call i32 @printArray(i32* %5, i32 5)
%7 = call i32 @count(i32 2, i32* %5, i32 5)
%8 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 2, i32 %7)
%9 = bitcast [5 x i32]* %2 to i8*
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%11 = call i32 @printArray(i32* %10, i32 5)
%12 = call i32 @count(i32 2, i32* %10, i32 5)
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 2, i32 %12)
%14 = bitcast [1 x i32]* %3 to i8*
%15 = getelementptr inbounds [1 x i32], [1 x i32]* %3, i64 0, i64 0
store i32 2, i32* %15
%16 = call i32 @printArray(i32* %15, i32 5)
%17 = call i32 @count(i32 0, i32* %15, i32 5)
%18 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 0, i32 %17)
ret i32 0
}