#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 */
scalar_t__ mean(int, int *, double *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ sum(int, int *, int *);
int main(void) {
  int values[] = {3, 1, 4};
  double mean_result;
  int sum_result;
  if (mean(3, values, &mean_result) == 0) {
    printf("mean: %.20f\n", mean_result);
  } else {
    printf("failed calculating mean value\n");
  }
  if (sum(3, values, &sum_result) == 0) {
    printf("sum: %d\n", sum_result);
  } else {
    printf("failed calculating sum\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xeb8(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x10(%rbp),%rsi
mov    $0x3,%edi
lea    -0x18(%rbp),%rdx
call   1050 <mean@plt>
cmp    $0x0,%rax
jne    1187 <main+0x57>
movsd  -0x18(%rbp),%xmm0
lea    0xe91(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1195 <main+0x65>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rsi
mov    $0x3,%edi
lea    -0x1c(%rbp),%rdx
call   1040 <sum@plt>
cmp    $0x0,%rax
jne    11c7 <main+0x97>
mov    -0x1c(%rbp),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d5 <main+0xa5>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
mov    0xebe(%rip),%eax
mov    %eax,0x18(%rsp)
mov    0xeab(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0x10(%rsp),%rsi
lea    0x20(%rsp),%rdx
mov    $0x3,%edi
call   1060 <mean@plt>
test   %rax,%rax
je     1181 <main+0x41>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
jmp    1195 <main+0x55>
movsd  0x20(%rsp),%xmm0
lea    0xe7e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    $0x3,%edi
call   1050 <sum@plt>
test   %rax,%rax
je     11bc <main+0x7c>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
jmp    11ce <main+0x8e>
mov    0xc(%rsp),%esi
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.main.values = [3 x i32] [i32 3, i32 1, i32 4]
@.str = [13 x i8] c"mean: %.20f\0A\00"
@.str.1 = [31 x i8] c"failed calculating mean value\0A\00"
@.str.2 = [9 x i8] c"sum: %d\0A\00"
@.str.3 = [24 x i8] c"failed calculating sum\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca double
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [3 x i32]* %2 to i8*
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%7 = call i64 @mean(i32 3, i32* %6, double* %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = load double, double* %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %10)
br label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%16 = call i64 @sum(i32 3, i32* %15, i32* %4)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i32, i32* %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %19)
br label %23
21: ; preds = %14
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %18
ret i32 0
}

LLVM IR (-O2):
@__const.main.values = [3 x i32] [i32 3, i32 1, i32 4]
@.str = [13 x i8] c"mean: %.20f\0A\00"
@.str.2 = [9 x i8] c"sum: %d\0A\00"
@str = [30 x i8] c"failed calculating mean value\00"
@str.4 = [23 x i8] c"failed calculating sum\00"
define i32 @main() {
%1 = alloca [3 x i32]
%2 = alloca double
%3 = alloca i32
%4 = bitcast [3 x i32]* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%8 = call i64 @mean(i32 3, i32* %7, double* %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = load double, double* %2
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %11)
br label %15
13: ; preds = %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
%16 = call i64 @sum(i32 3, i32* %7, i32* %3)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %19)
br label %23
21: ; preds = %15
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.4, i64 0, i64 0))
br label %23
23: ; preds = %21, %18
ret i32 0
}