#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 candy(int *, int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int arr1[] = {1, 2, 2};
  int arr2[] = {3, 2, 1, 1, 2, 3};
  printf("%d\n", candy(arr1, 3));
  printf("%d\n", candy(arr2, 6));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec8(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xec6(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1040 <candy@plt>
mov    %eax,%esi
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    $0x6,%esi
call   1040 <candy@plt>
mov    %eax,%esi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    0xedd(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xeca(%rip),%rax
mov    %rax,(%rsp)
mov    0xedf(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xec3(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %rsp,%rdi
mov    $0x3,%esi
call   1040 <candy@plt>
lea    0xec2(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x10(%rsp),%rdi
mov    $0x6,%esi
call   1040 <candy@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.arr1 = [3 x i32] [i32 1, i32 2, i32 2]
@__const.main.arr2 = [6 x i32] [i32 3, i32 2, i32 1, i32 1, i32 2, i32 3]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca [6 x i32]
store i32 0, i32* %1
%4 = bitcast [3 x i32]* %2 to i8*
%5 = bitcast [6 x i32]* %3 to i8*
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%7 = call i32 @candy(i32* %6, i32 3)
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%10 = call i32 @candy(i32* %9, i32 6)
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr1 = [3 x i32] [i32 1, i32 2, i32 2]
@__const.main.arr2 = [6 x i32] [i32 3, i32 2, i32 1, i32 1, i32 2, i32 3]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [3 x i32]
%2 = alloca [6 x i32]
%3 = bitcast [3 x i32]* %1 to i8*
%4 = bitcast [6 x i32]* %2 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%6 = call i32 @candy(i32* %5, i32 3)
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 0
%9 = call i32 @candy(i32* %8, i32 6)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
ret i32 0
}