#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 a[5] = {0, 1, 2, 3, 4};
  int i;
  printf("Effects of passing entire array by reference:\n\nThe "
         "values of the original array are:\n");
  for (i = 0; i < 5; i++) {
    printf("%3d", a[i]);
  }
  printf("\n");
  modifyArray(a, 5);
  printf("The values of the modified array are:\n");
  for (i = 0; i < 5; i++) {
    printf("%3d", a[i]);
  }
  printf("\n\n\nEffects of passing array element "
         "by value:\n\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    $0x30,%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,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    11a1 <main+0x71>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1173 <main+0x43>
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1050 <modifyArray@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    1200 <main+0xd0>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d2 <main+0xa2>
mov    -0x14(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1030 <modifyElement@plt>
mov    -0x14(%rbp),%esi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    0xeb5(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xe9a(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xf0a(%rip),%rdi
call   1050 <puts@plt>
lea    0xe97(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %rsp,%rdi
mov    $0x5,%esi
call   1070 <modifyArray@plt>
lea    0xeed(%rip),%rdi
call   1050 <puts@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xde0(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%edi
call   1030 <modifyElement@plt>
mov    0xc(%rsp),%esi
lea    0xe0d(%rip),%rdi
xor    %eax,%eax
call   1060 <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 = [86 x i8] c"Effects of passing entire array by reference:\0A\0AThe values of the original array are:\0A\00"
@.str.1 = [4 x i8] c"%3d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [39 x i8] c"The values of the modified array are:\0A\00"
@.str.4 = [72 x i8] c"\0A\0A\0AEffects of passing array element by value:\0A\0AThe value of a[3] is %d\0A\00"
@.str.5 = [27 x i8] c"The value of a[ 3 ] is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [5 x i32]* %2 to i8*
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %6
6: ; preds = %15, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 5
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %2, 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* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %6
18: ; preds = %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%21 = call i32 @modifyArray(i32* %20, i32 5)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %23
23: ; preds = %32, %18
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 5
br i1 %25, label %26, label %35
26: ; preds = %23
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %26
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %23
35: ; preds = %23
%36 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 3
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 3
%40 = load i32, i32* %39
%41 = call i32 @modifyElement(i32 %40)
%42 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 3
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %43)
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.4 = [72 x i8] c"\0A\0A\0AEffects of passing array element by value:\0A\0AThe value of a[3] is %d\0A\00"
@.str.5 = [27 x i8] c"The value of a[ 3 ] is %d\0A\00"
@str = [85 x i8] c"Effects of passing entire array by reference:\0A\0AThe values of the original array are:\00"
@str.6 = [38 x i8] c"The 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 ([85 x i8], [85 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 = tail call i32 @putchar(i32 10)
%15 = call i32 @modifyArray(i32* %4, i32 5)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.6, i64 0, i64 0))
%17 = load i32, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %6
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %8
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %10
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %12
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %10
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %10
%30 = call i32 @modifyElement(i32 %29)
%31 = load i32, i32* %10
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %31)
ret i32 0
}