#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 *);
int /*<<< orphan*/ printf(char *);
void test_mean(void) {
  int res;
  int ints[] = {12, 13, 14};
  printf("Test mean using assert:      ");
  int ret = mean(ints, 3, NULL);
  assert(ret != 0);
  ret = mean(NULL, 3, &res);
  assert(ret != 0);
  printf(" OK\n");
}


x86 assembly (clang, -O0):
<test_mean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xebf(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
mov    $0x3,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <mean@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
mov    %eax,%edi
mov    $0x3,%esi
lea    -0x4(%rbp),%rdx
call   1050 <mean@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_mean>:
sub    $0x18,%rsp
mov    0xebe(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xeab(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
lea    0x8(%rsp),%rdi
mov    $0x3,%esi
xor    %edx,%edx
call   1060 <mean@plt>
xor    %edi,%edi
test   %eax,%eax
setne  %dil
call   1050 <assert@plt>
lea    0x14(%rsp),%rdx
xor    %edi,%edi
mov    $0x3,%esi
call   1060 <mean@plt>
xor    %edi,%edi
test   %eax,%eax
setne  %dil
call   1050 <assert@plt>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.test_mean.ints = [3 x i32] [i32 12, i32 13, i32 14]
@.str = [30 x i8] c"Test mean using assert: \00"
@.str.1 = [5 x i8] c" OK\0A\00"
define void @test_mean() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca i32
%4 = bitcast [3 x i32]* %2 to i8*
%5 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%7 = call i32 @mean(i32* %6, i32 3, i32* null)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = icmp ne i32 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i32 @mean(i32* null, i32 3, i32* %1)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.test_mean.ints = [3 x i32] [i32 12, i32 13, i32 14]
@.str = [30 x i8] c"Test mean using assert: \00"
@str = [4 x i8] c" OK\00"
define void @test_mean() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [3 x i32]* %2 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%7 = call i32 @mean(i32* %6, i32 3, i32* null)
%8 = icmp ne i32 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = call i32 @mean(i32* null, i32 3, i32* %1)
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
ret void
}