#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 */
typedef int /*<<< orphan*/ arr3;
typedef int /*<<< orphan*/ arr2;
typedef int /*<<< orphan*/ arr1;

/* Variables and functions */
int optimalStrategyOfGame(int *, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int arr1[] = {8, 15, 3, 7};
  int n = sizeof(arr1) / sizeof(arr1[0]);
  printf("%d\n", optimalStrategyOfGame(arr1, n));
  int arr2[] = {2, 2, 2, 2};
  n = sizeof(arr2) / sizeof(arr2[0]);
  printf("%d\n", optimalStrategyOfGame(arr2, n));
  int arr3[] = {20, 30, 2, 2, 2, 10};
  n = sizeof(arr3) / sizeof(arr3[0]);
  printf("%d\n", optimalStrategyOfGame(arr3, n));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x4,-0x24(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1040 <optimalStrategyOfGame@plt>
mov    %eax,%esi
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
mov    0xea3(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xea0(%rip),%rax
mov    %rax,-0x38(%rbp)
movl   $0x4,-0x24(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1040 <optimalStrategyOfGame@plt>
mov    %eax,%esi
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    0xe8c(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe89(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xe86(%rip),%rax
mov    %rax,-0x50(%rbp)
movl   $0x6,-0x24(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1040 <optimalStrategyOfGame@plt>
mov    %eax,%esi
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x30(%rsp),%rdi
mov    $0x4,%esi
call   1040 <optimalStrategyOfGame@plt>
lea    0xed9(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0x20(%rsp),%rdi
mov    $0x4,%esi
call   1040 <optimalStrategyOfGame@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0xec3(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xea7(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x6,%esi
call   1040 <optimalStrategyOfGame@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.arr1 = [4 x i32] [i32 8, i32 15, i32 3, i32 7]
@.str = [4 x i8] c"%d\0A\00"
@__const.main.arr2 = [4 x i32] [i32 2, i32 2, i32 2, i32 2]
@__const.main.arr3 = [6 x i32] [i32 20, i32 30, i32 2, i32 2, i32 2, i32 10]
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca i32
%4 = alloca [4 x i32]
%5 = alloca [6 x i32]
store i32 0, i32* %1
%6 = bitcast [4 x i32]* %2 to i8*
store i32 4, i32* %3
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%8 = load i32, i32* %3
%9 = call i32 @optimalStrategyOfGame(i32* %7, i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = bitcast [4 x i32]* %4 to i8*
store i32 4, i32* %3
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%13 = load i32, i32* %3
%14 = call i32 @optimalStrategyOfGame(i32* %12, i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = bitcast [6 x i32]* %5 to i8*
store i32 6, i32* %3
%17 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 0
%18 = load i32, i32* %3
%19 = call i32 @optimalStrategyOfGame(i32* %17, i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
ret i32 0
}

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