#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 number_of_elements(int *, int);
int /*<<< orphan*/ print_int_array(int *, int);
int /*<<< orphan*/ printf(char *, int);
int main(int args, char **argv) {
  int s = 20;
  int ns[20] = {0, 0, 1, 1, 2, 2, 2, 3, 4, 4, 4, 4, 4, 4, 5, 6, 7, 8, 9, 9};
  int new_size = number_of_elements(ns, s);
  printf("new size: %d\n", new_size);
  print_int_array(ns, new_size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x14,-0x14(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe95(%rip),%rsi
mov    $0x50,%edx
call   1050 <memcpy@plt>
lea    -0x70(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <number_of_elements@plt>
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%esi
lea    0xec2(%rip),%rdi
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%esi
call   1060 <print_int_array@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
movaps 0xf03(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xee7(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xecb(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeaf(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe93(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
call   1030 <number_of_elements@plt>
mov    %eax,%ebp
lea    0xec6(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <print_int_array@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.ns = [20 x i32] [i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 2, i32 3, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 9]
@.str = [14 x i8] c"new size: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [20 x i32]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 20, i32* %6
%9 = bitcast [20 x i32]* %7 to i8*
%10 = getelementptr inbounds [20 x i32], [20 x i32]* %7, i64 0, i64 0
%11 = load i32, i32* %6
%12 = call i32 @number_of_elements(i32* %10, i32 %11)
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [20 x i32], [20 x i32]* %7, i64 0, i64 0
%16 = load i32, i32* %8
%17 = call i32 @print_int_array(i32* %15, i32 %16)
ret i32 0
}

LLVM IR (-O2):
@__const.main.ns = [20 x i32] [i32 0, i32 0, i32 1, i32 1, i32 2, i32 2, i32 2, i32 3, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 9]
@.str = [14 x i8] c"new size: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [20 x i32]
%4 = bitcast [20 x i32]* %3 to i8*
%5 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 0
%6 = call i32 @number_of_elements(i32* %5, i32 20)
%7 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @print_int_array(i32* %5, i32 %6)
ret i32 0
}