#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 sum(int *);
int /*<<< orphan*/ test_assert(int);
int main(void) {
  int x[3] = {1, 2, 3};
  int temp, ret, ret2;
  ret = sum(x);
  temp = x[0];
  x[0] = x[1];
  x[1] = x[2];
  x[2] = temp;
  ret2 = sum(x);
  test_assert(ret == ret2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec8(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
call   1030 <sum@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
call   1030 <sum@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <test_assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    0xedc(%rip),%eax
mov    %eax,0x10(%rsp)
mov    0xec9(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <sum@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%rcx
mov    %rcx,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    %rbx,%rdi
call   1030 <sum@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
call   1040 <test_assert@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.x = [3 x i32] [i32 1, i32 2, i32 3]
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [3 x i32]* %2 to i8*
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%8 = call i32 @sum(i32* %7)
store i32 %8, i32* %4
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%10 = load i32, i32* %9
store i32 %10, i32* %3
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%12 = load i32, i32* %11
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
store i32 %12, i32* %13
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
%15 = load i32, i32* %14
%16 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
store i32 %15, i32* %16
%17 = load i32, i32* %3
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
store i32 %17, i32* %18
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%20 = call i32 @sum(i32* %19)
store i32 %20, i32* %5
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = icmp eq i32 %21, %22
%24 = zext i1 %23 to i32
%25 = call i32 @test_assert(i32 %24)
ret i32 0
}

LLVM IR (-O2):
@__const.main.x = [3 x i32] [i32 1, i32 2, i32 3]
define i32 @main() {
%1 = alloca [3 x i32]
%2 = bitcast [3 x i32]* %1 to i8*
%3 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%4 = call i32 @sum(i32* %3)
%5 = load i32, i32* %3
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%7 = load i32, i32* %6
store i32 %7, i32* %3
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
%9 = load i32, i32* %8
store i32 %9, i32* %6
store i32 %5, i32* %8
%10 = call i32 @sum(i32* %3)
%11 = icmp eq i32 %4, %10
%12 = zext i1 %11 to i32
%13 = call i32 @test_assert(i32 %12)
ret i32 0
}