#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*/ modifyArray(int *, int);
int /*<<< orphan*/ modifyElement(int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int i, a[5] = {0, 1, 2, 3, 4};
  printf("-- Effects of passing entire values of the original array by "
         "reference:\n"
         "The values of the original array are:\n");
  for (i = 0; i < 5; ++i) {
    printf("%3d", a[i]);
  }
  modifyArray(a, 5);
  printf("\nThe values of the modified array are:\n");
  for (i = 0; i < 5; ++i) {
    printf("%3d", a[i]);
  }
  printf("\n-- Effects of passing array element "
         "by value:\nThe value of a[3] is %d\n",
         a[3]);
  modifyElement(a[3]);
  printf("The value of a[3] is %d\n", a[3]);
  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,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    11a1 <main+0x71>
movslq -0x8(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1173 <main+0x43>
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1050 <modifyArray@plt>
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    11f2 <main+0xc2>
movslq -0x8(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c4 <main+0x94>
mov    -0x14(%rbp),%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1030 <modifyElement@plt>
mov    -0x14(%rbp),%esi
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    0xec5(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xeff(%rip),%rdi
call   1040 <puts@plt>
lea    0xea7(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rdi
mov    $0x5,%esi
call   1060 <modifyArray@plt>
lea    0xf05(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xdfa(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%edi
call   1030 <modifyElement@plt>
mov    0xc(%rsp),%esi
lea    0xe0e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.a = [5 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4]
@.str = [111 x i8] c"-- Effects of passing entire values of the original array by reference:\0AThe values of the original array are:\0A\00"
@.str.1 = [4 x i8] c"%3d\00"
@.str.2 = [40 x i8] c"\0AThe values of the modified array are:\0A\00"
@.str.3 = [72 x i8] c"\0A-- Effects of passing array element by value:\0AThe value of a[3] is %d\0A\00"
@.str.4 = [25 x i8] c"The value of a[3] is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5 x i32]
store i32 0, i32* %1
%4 = bitcast [5 x i32]* %3 to i8*
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %6
6: ; preds = %15, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 5
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %9
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %6
18: ; preds = %6
%19 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%20 = call i32 @modifyArray(i32* %19, i32 5)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %22
22: ; preds = %31, %18
%23 = load i32, i32* %2
%24 = icmp slt i32 %23, 5
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %25
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %22
34: ; preds = %22
%35 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 3
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 3
%39 = load i32, i32* %38
%40 = call i32 @modifyElement(i32 %39)
%41 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 3
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %42)
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [5 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4]
@.str.1 = [4 x i8] c"%3d\00"
@.str.3 = [72 x i8] c"\0A-- Effects of passing array element by value:\0AThe value of a[3] is %d\0A\00"
@.str.4 = [25 x i8] c"The value of a[3] is %d\0A\00"
@str = [110 x i8] c"-- Effects of passing entire values of the original array by reference:\0AThe values of the original array are:\00"
@str.5 = [39 x i8] c"\0AThe values of the modified array are:\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([110 x i8], [110 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 0)
%6 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1)
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 2)
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 4)
%14 = call i32 @modifyArray(i32* %4, i32 5)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.5, i64 0, i64 0))
%16 = load i32, i32* %4
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %6
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %8
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %10
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %12
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %10
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %10
%29 = call i32 @modifyElement(i32 %28)
%30 = load i32, i32* %10
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %30)
ret i32 0
}