#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*/ printf(char *, char);
void foo(int n) {
  char s[n];
  for (int i = 0; i < n; i++)
    s[i] = i * i;
  printf("%d\n", s[n / 2]);
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1176 <foo+0x66>
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    %cl,%dl
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1148 <foo+0x38>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
lea    0xe6f(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,%r9d
mov    %rsp,%rax
lea    0xf(%r9),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rax
mov    %rax,%rsp
test   %edi,%edi
jle    15e1 <foo+0x4d1>
cmp    $0x10,%edi
jae    113c <foo+0x2c>
xor    %edx,%edx
jmp    15d0 <foo+0x4c0>
mov    %r9d,%edx
and    $0xfffffff0,%edx
lea    -0x10(%rdx),%rsi
mov    %rsi,%rcx
shr    $0x4,%rcx
add    $0x1,%rcx
mov    %ecx,%r8d
and    $0x3,%r8d
cmp    $0x30,%rsi
jae    1187 <foo+0x77>
movdqa 0xe99(%rip),%xmm13
movdqa 0xea0(%rip),%xmm14
movdqa 0xea8(%rip),%xmm2
movdqa 0xeb0(%rip),%xmm3
xor    %esi,%esi
jmp    14d1 <foo+0x3c1>
and    $0xfffffffffffffffc,%rcx
movdqa 0xe6c(%rip),%xmm13
movdqa 0xe73(%rip),%xmm14
movdqa 0xe7b(%rip),%xmm2
movdqa 0xe83(%rip),%xmm3
xor    %esi,%esi
movdqa 0xe88(%rip),%xmm12
movdqa 0xe8f(%rip),%xmm8
movdqa 0xe96(%rip),%xmm9
movdqa 0xe9d(%rip),%xmm10
movdqa 0xea4(%rip),%xmm11
nopl   0x0(%rax)
movdqa %xmm13,%xmm5
pmuludq %xmm13,%xmm5
pshufd $0xe8,%xmm5,%xmm6
pshufd $0xf5,%xmm13,%xmm5
pmuludq %xmm5,%xmm5
pshufd $0xe8,%xmm5,%xmm5
punpckldq %xmm5,%xmm6
movdqa %xmm14,%xmm5
pmuludq %xmm14,%xmm5
pshufd $0xe8,%xmm5,%xmm7
pshufd $0xf5,%xmm14,%xmm5
pmuludq %xmm5,%xmm5
pshufd $0xe8,%xmm5,%xmm5
punpckldq %xmm5,%xmm7
movdqa %xmm2,%xmm5
pmuludq %xmm2,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pshufd $0xf5,%xmm2,%xmm4
pmuludq %xmm4,%xmm4
pshufd $0xe8,%xmm4,%xmm4
punpckldq %xmm4,%xmm5
movdqa %xmm3,%xmm4
pmuludq %xmm3,%xmm4
pshufd $0xe8,%xmm4,%xmm4
pshufd $0xf5,%xmm3,%xmm0
pmuludq %xmm0,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm4
pand   %xmm12,%xmm4
pand   %xmm12,%xmm5
packuswb %xmm5,%xmm4
pand   %xmm12,%xmm7
pand   %xmm12,%xmm6
packuswb %xmm6,%xmm7
packuswb %xmm7,%xmm4
movdqa %xmm4,(%rax,%rsi,1)
movdqa %xmm3,%xmm7
paddd  %xmm8,%xmm7
movdqa %xmm2,%xmm0
paddd  %xmm8,%xmm0
movdqa %xmm14,%xmm4
paddd  %xmm8,%xmm4
movdqa %xmm13,%xmm5
paddd  %xmm8,%xmm5
pshufd $0xf5,%xmm5,%xmm1
pmuludq %xmm5,%xmm5
pshufd $0xe8,%xmm5,%xmm6
pmuludq %xmm1,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm6
pshufd $0xf5,%xmm4,%xmm1
pmuludq %xmm4,%xmm4
pshufd $0xe8,%xmm4,%xmm5
pmuludq %xmm1,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm5
pshufd $0xf5,%xmm0,%xmm1
pmuludq %xmm0,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm1,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm0
pshufd $0xf5,%xmm7,%xmm1
pmuludq %xmm7,%xmm7
pshufd $0xe8,%xmm7,%xmm4
pmuludq %xmm1,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm4
pand   %xmm12,%xmm4
pand   %xmm12,%xmm0
packuswb %xmm0,%xmm4
pand   %xmm12,%xmm5
pand   %xmm12,%xmm6
packuswb %xmm6,%xmm5
packuswb %xmm5,%xmm4
movdqa %xmm4,0x10(%rax,%rsi,1)
movdqa %xmm3,%xmm7
paddd  %xmm9,%xmm7
movdqa %xmm2,%xmm0
paddd  %xmm9,%xmm0
movdqa %xmm14,%xmm1
paddd  %xmm9,%xmm1
movdqa %xmm13,%xmm4
paddd  %xmm9,%xmm4
pshufd $0xf5,%xmm4,%xmm5
pmuludq %xmm4,%xmm4
pshufd $0xe8,%xmm4,%xmm6
pmuludq %xmm5,%xmm5
pshufd $0xe8,%xmm5,%xmm4
punpckldq %xmm4,%xmm6
pshufd $0xf5,%xmm1,%xmm4
pmuludq %xmm1,%xmm1
pshufd $0xe8,%xmm1,%xmm5
pmuludq %xmm4,%xmm4
pshufd $0xe8,%xmm4,%xmm1
punpckldq %xmm1,%xmm5
pshufd $0xf5,%xmm0,%xmm1
pmuludq %xmm0,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm1,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm0
pshufd $0xf5,%xmm7,%xmm1
pmuludq %xmm7,%xmm7
pshufd $0xe8,%xmm7,%xmm4
pmuludq %xmm1,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm4
pand   %xmm12,%xmm4
pand   %xmm12,%xmm0
packuswb %xmm0,%xmm4
pand   %xmm12,%xmm5
pand   %xmm12,%xmm6
packuswb %xmm6,%xmm5
packuswb %xmm5,%xmm4
movdqa %xmm4,0x20(%rax,%rsi,1)
movdqa %xmm3,%xmm7
paddd  %xmm10,%xmm7
movdqa %xmm2,%xmm0
paddd  %xmm10,%xmm0
movdqa %xmm14,%xmm1
paddd  %xmm10,%xmm1
movdqa %xmm13,%xmm4
paddd  %xmm10,%xmm4
pshufd $0xf5,%xmm4,%xmm5
pmuludq %xmm4,%xmm4
pshufd $0xe8,%xmm4,%xmm6
pmuludq %xmm5,%xmm5
pshufd $0xe8,%xmm5,%xmm4
punpckldq %xmm4,%xmm6
pshufd $0xf5,%xmm1,%xmm4
pmuludq %xmm1,%xmm1
pshufd $0xe8,%xmm1,%xmm5
pmuludq %xmm4,%xmm4
pshufd $0xe8,%xmm4,%xmm1
punpckldq %xmm1,%xmm5
pshufd $0xf5,%xmm0,%xmm1
pmuludq %xmm0,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm1,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm0
pshufd $0xf5,%xmm7,%xmm1
pmuludq %xmm7,%xmm7
pshufd $0xe8,%xmm7,%xmm4
pmuludq %xmm1,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm4
pand   %xmm12,%xmm4
pand   %xmm12,%xmm0
packuswb %xmm0,%xmm4
pand   %xmm12,%xmm5
pand   %xmm12,%xmm6
packuswb %xmm6,%xmm5
packuswb %xmm5,%xmm4
movdqa %xmm4,0x30(%rax,%rsi,1)
add    $0x40,%rsi
paddd  %xmm11,%xmm3
paddd  %xmm11,%xmm2
paddd  %xmm11,%xmm14
paddd  %xmm11,%xmm13
add    $0xfffffffffffffffc,%rcx
jne    11e0 <foo+0xd0>
test   %r8,%r8
je     15c6 <foo+0x4b6>
add    %rax,%rsi
shl    $0x4,%r8
xor    %ecx,%ecx
movdqa 0xb54(%rip),%xmm8
movdqa 0xb5c(%rip),%xmm5
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movdqa %xmm13,%xmm0
pmuludq %xmm13,%xmm0
pshufd $0xe8,%xmm0,%xmm6
pshufd $0xf5,%xmm13,%xmm0
pmuludq %xmm0,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm6
movdqa %xmm14,%xmm0
pmuludq %xmm14,%xmm0
pshufd $0xe8,%xmm0,%xmm7
pshufd $0xf5,%xmm14,%xmm0
pmuludq %xmm0,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm7
movdqa %xmm2,%xmm0
pmuludq %xmm2,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pshufd $0xf5,%xmm2,%xmm1
pmuludq %xmm1,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm0
movdqa %xmm3,%xmm1
pmuludq %xmm3,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pshufd $0xf5,%xmm3,%xmm4
pmuludq %xmm4,%xmm4
pshufd $0xe8,%xmm4,%xmm4
punpckldq %xmm4,%xmm1
pand   %xmm8,%xmm1
pand   %xmm8,%xmm0
packuswb %xmm0,%xmm1
pand   %xmm8,%xmm7
pand   %xmm8,%xmm6
packuswb %xmm6,%xmm7
packuswb %xmm7,%xmm1
movdqa %xmm1,(%rsi,%rcx,1)
paddd  %xmm5,%xmm3
paddd  %xmm5,%xmm2
paddd  %xmm5,%xmm14
paddd  %xmm5,%xmm13
add    $0x10,%rcx
cmp    %rcx,%r8
jne    1500 <foo+0x3f0>
cmp    %r9,%rdx
je     15e1 <foo+0x4d1>
nopl   0x0(%rax,%rax,1)
mov    %edx,%ecx
imul   %edx,%ecx
mov    %cl,(%rax,%rdx,1)
add    $0x1,%rdx
cmp    %rdx,%r9
jne    15d0 <foo+0x4c0>
mov    %edi,%ecx
shr    $0x1f,%ecx
add    %edi,%ecx
sar    %ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xa98(%rip),%rdi
mov    %rbp,%rsp
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define void @foo(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %3
%9 = alloca i8, i64 %7
store i64 %7, i64* %4
store i32 0, i32* %5
br label %10
10: ; preds = %22, %1
%11 = load i32, i32* %5
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = load i32, i32* %5
%16 = load i32, i32* %5
%17 = mul nsw i32 %15, %16
%18 = trunc i32 %17 to i8
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %9, i64 %20
store i8 %18, i8* %21
br label %22
22: ; preds = %14
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %10
25: ; preds = %10
%26 = load i32, i32* %2
%27 = sdiv i32 %26, 2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %9, i64 %28
%30 = load i8, i8* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %30)
%32 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @foo(i32 %0) {
%2 = zext i32 %0 to i64
%3 = alloca i8, i64 %2
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %66
5: ; preds = %1
%6 = icmp ult i32 %0, 16
br i1 %6, label %64, label %7
7: ; preds = %5
%8 = and i64 %2, 4294967280
%9 = add nsw i64 %8, -16
%10 = lshr exact i64 %9, 4
%11 = add nuw nsw i64 %10, 1
%12 = and i64 %11, 3
%13 = icmp ult i64 %9, 48
br i1 %13, label %46, label %14
14: ; preds = %7
%15 = and i64 %11, 2305843009213693948
br label %16
16: ; preds = %16, %14
%17 = phi i64 [ 0, %14 ], [ %42, %16 ]
%18 = phi <16 x i32> [ <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>, %14 ], [ %43, %16 ]
%19 = phi i64 [ 0, %14 ], [ %44, %16 ]
%20 = mul nsw <16 x i32> %18, %18
%21 = trunc <16 x i32> %20 to <16 x i8>
%22 = getelementptr inbounds i8, i8* %3, i64 %17
%23 = bitcast i8* %22 to <16 x i8>*
store <16 x i8> %21, <16 x i8>* %23
%24 = or i64 %17, 16
%25 = add <16 x i32> %18, <i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
%26 = mul nsw <16 x i32> %25, %25
%27 = trunc <16 x i32> %26 to <16 x i8>
%28 = getelementptr inbounds i8, i8* %3, i64 %24
%29 = bitcast i8* %28 to <16 x i8>*
store <16 x i8> %27, <16 x i8>* %29
%30 = or i64 %17, 32
%31 = add <16 x i32> %18, <i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32>
%32 = mul nsw <16 x i32> %31, %31
%33 = trunc <16 x i32> %32 to <16 x i8>
%34 = getelementptr inbounds i8, i8* %3, i64 %30
%35 = bitcast i8* %34 to <16 x i8>*
store <16 x i8> %33, <16 x i8>* %35
%36 = or i64 %17, 48
%37 = add <16 x i32> %18, <i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48>
%38 = mul nsw <16 x i32> %37, %37
%39 = trunc <16 x i32> %38 to <16 x i8>
%40 = getelementptr inbounds i8, i8* %3, i64 %36
%41 = bitcast i8* %40 to <16 x i8>*
store <16 x i8> %39, <16 x i8>* %41
%42 = add nuw i64 %17, 64
%43 = add <16 x i32> %18, <i32 64, i32 64, i32 64, i32 64, i32 64, i32 64, i32 64, i32 64, i32 64, i32 64, i32 64, i32 64, i32 64, i32 64, i32 64, i32 64>
%44 = add i64 %19, 4
%45 = icmp eq i64 %44, %15
br i1 %45, label %46, label %16
46: ; preds = %16, %7
%47 = phi i64 [ 0, %7 ], [ %42, %16 ]
%48 = phi <16 x i32> [ <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>, %7 ], [ %43, %16 ]
%49 = icmp eq i64 %12, 0
br i1 %49, label %62, label %50
50: ; preds = %46, %50
%51 = phi i64 [ %58, %50 ], [ %47, %46 ]
%52 = phi <16 x i32> [ %59, %50 ], [ %48, %46 ]
%53 = phi i64 [ %60, %50 ], [ 0, %46 ]
%54 = mul nsw <16 x i32> %52, %52
%55 = trunc <16 x i32> %54 to <16 x i8>
%56 = getelementptr inbounds i8, i8* %3, i64 %51
%57 = bitcast i8* %56 to <16 x i8>*
store <16 x i8> %55, <16 x i8>* %57
%58 = add nuw i64 %51, 16
%59 = add <16 x i32> %52, <i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
%60 = add i64 %53, 1
%61 = icmp eq i64 %60, %12
br i1 %61, label %62, label %50
62: ; preds = %50, %46
%63 = icmp eq i64 %8, %2
br i1 %63, label %66, label %64
64: ; preds = %5, %62
%65 = phi i64 [ 0, %5 ], [ %8, %62 ]
br label %72
66: ; preds = %72, %62, %1
%67 = sdiv i32 %0, 2
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %3, i64 %68
%70 = load i8, i8* %69
%71 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %70)
ret void
72: ; preds = %64, %72
%73 = phi i64 [ %78, %72 ], [ %65, %64 ]
%74 = trunc i64 %73 to i32
%75 = mul nsw i32 %74, %74
%76 = trunc i32 %75 to i8
%77 = getelementptr inbounds i8, i8* %3, i64 %73
store i8 %76, i8* %77
%78 = add nuw nsw i64 %73, 1
%79 = icmp eq i64 %78, %2
br i1 %79, label %66, label %72
}