#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*/ bar(int *);
int foo(int *p) {
  int x[4];
  int tem0, tem1, tem2, tem3;
  tem0 = p[0] + 1;
  x[0] = tem0;
  tem1 = p[1] + 2;
  x[1] = tem1;
  tem2 = p[2] + 3;
  x[2] = tem2;
  tem3 = p[3] + 4;
  x[3] = tem3;
  bar(x);
  return tem0 + tem1 + tem2 + tem3;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
add    $0x2,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%eax
add    $0x3,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%eax
add    $0x4,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <bar@plt>
mov    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
add    -0x2c(%rbp),%eax
add    -0x30(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
sub    $0x28,%rsp
movdqu (%rdi),%xmm0
paddd  0xee0(%rip),%xmm0
movdqa %xmm0,(%rsp)
movdqa %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
call   1030 <bar@plt>
movdqa (%rsp),%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
define i32 @foo(i32* %0) {
%2 = alloca i32*
%3 = alloca [4 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %2
%8 = load i32*, i32** %2
%9 = getelementptr inbounds i32, i32* %8, i64 0
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
store i32 %12, i32* %13
%14 = load i32*, i32** %2
%15 = getelementptr inbounds i32, i32* %14, i64 1
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 2
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
store i32 %18, i32* %19
%20 = load i32*, i32** %2
%21 = getelementptr inbounds i32, i32* %20, i64 2
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 3
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
store i32 %24, i32* %25
%26 = load i32*, i32** %2
%27 = getelementptr inbounds i32, i32* %26, i64 3
%28 = load i32, i32* %27
%29 = add nsw i32 %28, 4
store i32 %29, i32* %7
%30 = load i32, i32* %7
%31 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
store i32 %30, i32* %31
%32 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%33 = call i32 @bar(i32* %32)
%34 = load i32, i32* %4
%35 = load i32, i32* %5
%36 = add nsw i32 %34, %35
%37 = load i32, i32* %6
%38 = add nsw i32 %36, %37
%39 = load i32, i32* %7
%40 = add nsw i32 %38, %39
ret i32 %40
}

LLVM IR (-O2):
define i32 @foo(i32* nocapture %0) {
%2 = alloca <4 x i32>
%3 = bitcast <4 x i32>* %2 to i8*
%4 = getelementptr inbounds <4 x i32>, <4 x i32>* %2, i64 0, i64 0
%5 = bitcast i32* %0 to <4 x i32>*
%6 = load <4 x i32>, <4 x i32>* %5
%7 = add nsw <4 x i32> %6, <i32 1, i32 2, i32 3, i32 4>
store <4 x i32> %7, <4 x i32>* %2
%8 = call i32 @bar(i32* %4)
%9 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %7)
ret i32 %9
}