#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*/ getchar();
int /*<<< orphan*/ printf(char *, int);
int main() {
  int q[102] = {0, 6, 3, 1, 7, 5, 8, 9, 2, 4};
  int head, tail;
  head = 1;
  tail = 10;
  while (head < tail) {
    printf("%d ", q[head]);
    head++;
    q[tail] = q[head];
    tail++;
    head++;
  }
  getchar();
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1a0(%rbp),%rdi
lea    0xeb0(%rip),%rsi
mov    $0x198,%edx
call   1050 <memcpy@plt>
movl   $0x1,-0x1a4(%rbp)
movl   $0xa,-0x1a8(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x1a8(%rbp),%eax
jge    11e8 <main+0xb8>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0x1003(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%ecx
movslq -0x1a8(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    116e <main+0x3e>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1a0,%rsp
lea    0xebd(%rip),%rsi
mov    %rsp,%rdi
mov    $0x198,%edx
call   1050 <memcpy@plt>
mov    $0xa,%r15d
mov    $0x1,%ebx
lea    0x1036(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x4(%rsp,%rbx,4),%eax
mov    %eax,(%rsp,%r15,4)
lea    0x1(%r15),%rax
add    $0x2,%rbx
cmp    %r15,%rbx
mov    %rax,%r15
jbe    1170 <main+0x40>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.q = <{ [10 x i32], [92 x i32] }> <{ [10 x i32] [i32 0, i32 6, i32 3, i32 1, i32 7, i32 5, i32 8, i32 9, i32 2, i32 4], [92 x i32] zeroinitializer }>
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [102 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [102 x i32]* %2 to i8*
store i32 1, i32* %3
store i32 10, i32* %4
br label %6
6: ; preds = %10, %0
%7 = load i32, i32* %3
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %29
10: ; preds = %6
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [102 x i32], [102 x i32]* %2, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [102 x i32], [102 x i32]* %2, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [102 x i32], [102 x i32]* %2, i64 0, i64 %23
store i32 %21, i32* %24
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %6
29: ; preds = %6
%30 = call i32 (...) @getchar()
%31 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@__const.main.q = <{ [10 x i32], [92 x i32] }> <{ [10 x i32] [i32 0, i32 6, i32 3, i32 1, i32 7, i32 5, i32 8, i32 9, i32 2, i32 4], [92 x i32] zeroinitializer }>
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [102 x i32]
%2 = bitcast [102 x i32]* %1 to i8*
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 1, %0 ], [ %14, %3 ]
%5 = phi i64 [ 10, %0 ], [ %13, %3 ]
%6 = getelementptr inbounds [102 x i32], [102 x i32]* %1, i64 0, i64 %4
%7 = load i32, i32* %6
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = add nuw nsw i64 %4, 1
%10 = getelementptr inbounds [102 x i32], [102 x i32]* %1, i64 0, i64 %9
%11 = load i32, i32* %10
%12 = getelementptr inbounds [102 x i32], [102 x i32]* %1, i64 0, i64 %5
store i32 %11, i32* %12
%13 = add nuw nsw i64 %5, 1
%14 = add nuw nsw i64 %4, 2
%15 = icmp ugt i64 %14, %5
br i1 %15, label %16, label %3
16: ; preds = %3
%17 = tail call i32 (...) @getchar()
%18 = tail call i32 (...) @getchar()
ret i32 0
}