#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*/ cbr_swap(int *, int *);
int /*<<< orphan*/ cbv_swap(int, int);
double getAverage(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int a = 100;
  int b = 200;
  printf("value of a PRE cbv_swap : %d\n", a);
  printf("value of b PRE cbv_swap : %d\n", b);
  cbv_swap(a, b);
  printf("value of a POST cbv_swap : %d\n", a);
  printf("value of b POST cbv_swap : %d\n", b);
  printf("---\n");
  printf("value of a PRE cbr_swap : %d\n", a);
  printf("value of b PRE cbr_swap : %d\n", b);
  cbr_swap(&a, &b);
  printf("value of a POST cbr_swap : %d\n", a);
  printf("value of b POST cbr_swap : %d\n", b);
  printf("---\n");
  int balance[5] = {1000, 2, 3, 17, 50};
  double avg = 0.0;
  avg = getAverage(balance, 5);
  printf("Average value is: %f\n", avg);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x64,-0x14(%rbp)
movl   $0xc8,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <cbv_swap@plt>
mov    -0x14(%rbp),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <cbr_swap@plt>
mov    -0x14(%rbp),%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0xee9(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xee6(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xee4(%rip),%eax
mov    %eax,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   1040 <getAverage@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
lea    0xe93(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movl   $0x64,0xc(%rsp)
movl   $0xc8,0x8(%rsp)
lea    0xe94(%rip),%rdi
mov    $0x64,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    $0xc8,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x64,%edi
mov    $0xc8,%esi
call   1030 <cbv_swap@plt>
lea    0xe9b(%rip),%rdi
mov    $0x64,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xea7(%rip),%rdi
mov    $0xc8,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf43(%rip),%rbx
mov    %rbx,%rdi
call   1050 <puts@plt>
lea    0xea4(%rip),%rdi
mov    $0x64,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xeaf(%rip),%rdi
mov    $0xc8,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1070 <cbr_swap@plt>
mov    0xc(%rsp),%esi
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
mov    0xeea(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xecf(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x5,%esi
call   1040 <getAverage@plt>
lea    0xe98(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"value of a PRE cbv_swap : %d\0A\00"
@.str.1 = [30 x i8] c"value of b PRE cbv_swap : %d\0A\00"
@.str.2 = [31 x i8] c"value of a POST cbv_swap : %d\0A\00"
@.str.3 = [31 x i8] c"value of b POST cbv_swap : %d\0A\00"
@.str.4 = [5 x i8] c"---\0A\00"
@.str.5 = [30 x i8] c"value of a PRE cbr_swap : %d\0A\00"
@.str.6 = [30 x i8] c"value of b PRE cbr_swap : %d\0A\00"
@.str.7 = [31 x i8] c"value of a POST cbr_swap : %d\0A\00"
@.str.8 = [31 x i8] c"value of b POST cbr_swap : %d\0A\00"
@__const.main.balance = [5 x i32] [i32 1000, i32 2, i32 3, i32 17, i32 50]
@.str.9 = [22 x i8] c"Average value is: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [5 x i32]
%9 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 100, i32* %6
store i32 200, i32* %7
%10 = load i32, i32* %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %7
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %6
%15 = load i32, i32* %7
%16 = call i32 @cbv_swap(i32 %14, i32 %15)
%17 = load i32, i32* %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %7
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%22 = load i32, i32* %6
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %7
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %24)
%26 = call i32 @cbr_swap(i32* %6, i32* %7)
%27 = load i32, i32* %6
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %7
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%32 = bitcast [5 x i32]* %8 to i8*
store double 0.000000e+00, double* %9
%33 = getelementptr inbounds [5 x i32], [5 x i32]* %8, i64 0, i64 0
%34 = call double @getAverage(i32* %33, i32 5)
store double %34, double* %9
%35 = load double, double* %9
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), double %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"value of a PRE cbv_swap : %d\0A\00"
@.str.1 = [30 x i8] c"value of b PRE cbv_swap : %d\0A\00"
@.str.2 = [31 x i8] c"value of a POST cbv_swap : %d\0A\00"
@.str.3 = [31 x i8] c"value of b POST cbv_swap : %d\0A\00"
@.str.5 = [30 x i8] c"value of a PRE cbr_swap : %d\0A\00"
@.str.6 = [30 x i8] c"value of b PRE cbr_swap : %d\0A\00"
@.str.7 = [31 x i8] c"value of a POST cbr_swap : %d\0A\00"
@.str.8 = [31 x i8] c"value of b POST cbr_swap : %d\0A\00"
@__const.main.balance = [5 x i32] [i32 1000, i32 2, i32 3, i32 17, i32 50]
@.str.9 = [22 x i8] c"Average value is: %f\0A\00"
@str.10 = [4 x i8] c"---\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [5 x i32]
%6 = bitcast i32* %3 to i8*
store i32 100, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 200, i32* %4
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 100)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 200)
%10 = tail call i32 @cbv_swap(i32 100, i32 200)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 100)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 200)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.10, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 100)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 200)
%16 = call i32 @cbr_swap(i32* %3, i32* %4)
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %4
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i32 %19)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.10, i64 0, i64 0))
%22 = bitcast [5 x i32]* %5 to i8*
%23 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
%24 = call double @getAverage(i32* %23, i32 5)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), double %24)
ret i32 0
}