#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);
int mean(int *, int, int *);
void test_mean(void) {
  int arr[] = {2, 2, 1, 4, 100, -100};
  int ret;
  int res;
  ret = mean(arr, 3, &res);
  assert(ret == 0);
  assert(res == 2);
  ret = mean(arr, 4, &res);
  assert(ret == 0);
  assert(res == 2);
  ret = mean(arr, 5, &res);
  assert(ret == 0);
  assert(res == 22);
  ret = mean(arr, 6, &res);
  assert(ret == 0);
  assert(res == 2);
}


x86 assembly (clang, -O0):
<test_mean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xecb(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x3,%esi
lea    -0x28(%rbp),%rdx
call   1040 <mean@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x2,-0x28(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
lea    -0x28(%rbp),%rdx
call   1040 <mean@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x2,-0x28(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
lea    -0x28(%rbp),%rdx
call   1040 <mean@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x16,-0x28(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    -0x20(%rbp),%rdi
mov    $0x6,%esi
lea    -0x28(%rbp),%rdx
call   1040 <mean@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x2,-0x28(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_mean>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    0xee2(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r14
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %r14,%rdx
call   1040 <mean@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x2,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r14,%rdx
call   1040 <mean@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x2,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %r14,%rdx
call   1040 <mean@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x16,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    %r14,%rdx
call   1040 <mean@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x2,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.test_mean.arr = [6 x i32] [i32 2, i32 2, i32 1, i32 4, i32 100, i32 -100]
define void @test_mean() {
%1 = alloca [6 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [6 x i32]* %1 to i8*
%5 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%6 = call i32 @mean(i32* %5, i32 3, i32* %3)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 2
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%16 = call i32 @mean(i32* %15, i32 4, i32* %3)
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 2
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%26 = call i32 @mean(i32* %25, i32 5, i32* %3)
store i32 %26, i32* %2
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 0
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i32, i32* %3
%32 = icmp eq i32 %31, 22
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%36 = call i32 @mean(i32* %35, i32 6, i32* %3)
store i32 %36, i32* %2
%37 = load i32, i32* %2
%38 = icmp eq i32 %37, 0
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = load i32, i32* %3
%42 = icmp eq i32 %41, 2
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
ret void
}

LLVM IR (-O2):
@__const.test_mean.arr = [6 x i32] [i32 2, i32 2, i32 1, i32 4, i32 100, i32 -100]
define void @test_mean() {
%1 = alloca [6 x i32]
%2 = alloca i32
%3 = bitcast [6 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%6 = call i32 @mean(i32* %5, i32 3, i32* %2)
%7 = icmp eq i32 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 2
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = call i32 @mean(i32* %5, i32 4, i32* %2)
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 2
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = call i32 @mean(i32* %5, i32 5, i32* %2)
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 22
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = call i32 @mean(i32* %5, i32 6, i32* %2)
%31 = icmp eq i32 %30, 0
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = load i32, i32* %2
%35 = icmp eq i32 %34, 2
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
ret void
}