#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*/ chapelProc(int *);
int /*<<< orphan*/ printf(char *, ...);
void cProc(int *a) {
  int i;
  printf("Hello from cProc\n");
  for (i = 0; i < 10; i++)
    a[i] = 10 * a[i];
  for (i = 0; i < 10; i++)
    printf("a[%i] is %i\n", i, a[i]);
  printf("calling Chapel\n");
  chapelProc(a);
  printf("cProc done\n");
}


x86 assembly (clang, -O0):
<cProc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1170 <cProc+0x50>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0xa,(%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1141 <cProc+0x21>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    11ab <cProc+0x8b>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1177 <cProc+0x57>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <chapelProc@plt>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cProc>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
movdqa 0xeb5(%rip),%xmm1
movdqu (%rbx),%xmm0
movdqu 0x10(%rbx),%xmm2
pshufd $0xf5,%xmm0,%xmm3
pmuludq %xmm1,%xmm0
pshufd $0xe8,%xmm0,%xmm4
pmuludq %xmm1,%xmm3
pshufd $0xe8,%xmm3,%xmm3
punpckldq %xmm3,%xmm4
movdqu %xmm4,(%rbx)
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm1,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pmuludq %xmm1,%xmm3
pshufd $0xe8,%xmm3,%xmm1
punpckldq %xmm1,%xmm2
movdqu %xmm2,0x10(%rbx)
mov    0x20(%rbx),%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %eax,0x20(%rbx)
mov    0x24(%rbx),%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %eax,0x24(%rbx)
movd   %xmm0,%edx
lea    0xe5c(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rbx),%edx
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%edx
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rbx),%edx
mov    %r14,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rbx),%edx
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rbx),%edx
mov    %r14,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%edx
mov    %r14,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rbx),%edx
mov    %r14,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rbx),%edx
mov    %r14,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rbx),%edx
mov    %r14,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdc5(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <chapelProc@plt>
lea    0xdc0(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Hello from cProc\0A\00"
@.str.1 = [13 x i8] c"a[%i] is %i\0A\00"
@.str.2 = [16 x i8] c"calling Chapel\0A\00"
@.str.3 = [12 x i8] c"cProc done\0A\00"
define void @cProc(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %5
5: ; preds = %19, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 10
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = load i32*, i32** %2
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %9, i64 %11
%13 = load i32, i32* %12
%14 = mul nsw i32 10, %13
%15 = load i32*, i32** %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
store i32 %14, i32* %18
br label %19
19: ; preds = %8
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %5
22: ; preds = %5
store i32 0, i32* %3
br label %23
23: ; preds = %34, %22
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 10
br i1 %25, label %26, label %37
26: ; preds = %23
%27 = load i32, i32* %3
%28 = load i32*, i32** %2
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %32)
br label %34
34: ; preds = %26
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %23
37: ; preds = %23
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%39 = load i32*, i32** %2
%40 = call i32 @chapelProc(i32* %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"a[%i] is %i\0A\00"
@str = [17 x i8] c"Hello from cProc\00"
@str.4 = [15 x i8] c"calling Chapel\00"
@str.5 = [11 x i8] c"cProc done\00"
define void @cProc(i32* %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%3 = getelementptr inbounds i32, i32* %0, i64 1
%4 = getelementptr inbounds i32, i32* %0, i64 2
%5 = getelementptr inbounds i32, i32* %0, i64 3
%6 = bitcast i32* %0 to <4 x i32>*
%7 = load <4 x i32>, <4 x i32>* %6
%8 = mul nsw <4 x i32> %7, <i32 10, i32 10, i32 10, i32 10>
%9 = bitcast i32* %0 to <4 x i32>*
store <4 x i32> %8, <4 x i32>* %9
%10 = getelementptr inbounds i32, i32* %0, i64 4
%11 = getelementptr inbounds i32, i32* %0, i64 5
%12 = getelementptr inbounds i32, i32* %0, i64 6
%13 = getelementptr inbounds i32, i32* %0, i64 7
%14 = bitcast i32* %10 to <4 x i32>*
%15 = load <4 x i32>, <4 x i32>* %14
%16 = mul nsw <4 x i32> %15, <i32 10, i32 10, i32 10, i32 10>
%17 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %17
%18 = getelementptr inbounds i32, i32* %0, i64 8
%19 = load i32, i32* %18
%20 = mul nsw i32 %19, 10
store i32 %20, i32* %18
%21 = getelementptr inbounds i32, i32* %0, i64 9
%22 = load i32, i32* %21
%23 = mul nsw i32 %22, 10
store i32 %23, i32* %21
%24 = extractelement <4 x i32> %8, i64 0
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %24)
%26 = load i32, i32* %3
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %26)
%28 = load i32, i32* %4
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %28)
%30 = load i32, i32* %5
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %30)
%32 = load i32, i32* %10
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 %32)
%34 = load i32, i32* %11
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %34)
%36 = load i32, i32* %12
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 %36)
%38 = load i32, i32* %13
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 7, i32 %38)
%40 = load i32, i32* %18
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 8, i32 %40)
%42 = load i32, i32* %21
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 9, i32 %42)
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.4, i64 0, i64 0))
%45 = tail call i32 @chapelProc(i32* %0)
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.5, i64 0, i64 0))
ret void
}