#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*/ extension(int *, int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ read_into_array(int *, int);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int d, N, a[30];
  scanf("%d %d", &d, &N);
  read_into_array(a, d);
  extension(a, N, d);
  printf("%d", a[N]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    0xeae(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1060 <scanf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1040 <read_into_array@plt>
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
call   1030 <extension@plt>
movslq -0x8(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%esi
lea    0xe7a(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x90,%rsp
lea    0xeb1(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <read_into_array@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
call   1030 <extension@plt>
movslq 0x8(%rsp),%rax
mov    0x10(%rsp,%rax,4),%esi
lea    0xe74(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [30 x i32]
%4 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%5 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 0
%6 = load i32, i32* %1
%7 = call i32 @read_into_array(i32* %5, i32 %6)
%8 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 0
%9 = load i32, i32* %2
%10 = load i32, i32* %1
%11 = call i32 @extension(i32* %8, i32 %9, i32 %10)
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [30 x i32]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast [30 x i32]* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%8 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 0
%9 = load i32, i32* %1
%10 = call i32 @read_into_array(i32* %8, i32 %9)
%11 = load i32, i32* %2
%12 = load i32, i32* %1
%13 = call i32 @extension(i32* %8, i32 %11, i32 %12)
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [30 x i32], [30 x i32]* %3, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %17)
ret i32 0
}