#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 atoi(char *);
int /*<<< orphan*/ putchar(unsigned char);
scalar_t__ read(int /*<<< orphan*/, unsigned char *, int);
int /*<<< orphan*/ write(int, char *, int);
int main(int i, char **a) {
  int s = 16e3 / atoi(a[1]);
  unsigned char v[s];
  if (read(0, v, s) < 0) {
    write(2, "FATAL: could not read input.\n\n", 31);
    return 1;
  }
  for (;;) {
    putchar(v[i % s] = (v[i % s] + v[++i % s]) / 2);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe91(%rip),%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x30(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%edx
xor    %edi,%edi
call   1050 <read@plt>
cmp    $0x0,%rax
jge    11e0 <main+0xa0>
mov    $0x2,%edi
lea    0xe48(%rip),%rsi
mov    $0x1f,%edx
call   1040 <write@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret
jmp    11e5 <main+0xa5>
mov    -0x30(%rbp),%rcx
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
movslq %edx,%rax
movzbl (%rcx,%rax,1),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    %eax,-0x8(%rbp)
cltd
idivl  -0x14(%rbp)
mov    -0x3c(%rbp),%eax
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%edx
add    %edx,%eax
mov    %eax,-0x38(%rbp)
mov    $0x2,%esi
cltd
idiv   %esi
mov    %al,-0x31(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    -0x31(%rbp),%al
movslq %edx,%rdx
mov    %al,(%rcx,%rdx,1)
movzbl %al,%edi
call   1030 <putchar@plt>
jmp    11e5 <main+0xa5>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe9f(%rip),%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%r14d
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
xor    %edi,%edi
mov    %r15,%rsi
mov    %r14d,%edx
call   1050 <read@plt>
test   %rax,%rax
js     11be <main+0x7e>
nopl   (%rax)
mov    %ebx,%eax
cltd
idiv   %r14d
movslq %edx,%rax
movzbl (%r15,%rax,1),%ecx
add    $0x1,%ebx
mov    %ebx,%eax
cltd
idiv   %r14d
movslq %edx,%rax
movzbl (%r15,%rax,1),%edi
add    %ecx,%edi
shr    %edi
mov    %dil,(%r15,%rax,1)
call   1030 <putchar@plt>
jmp    1190 <main+0x50>
lea    0xe43(%rip),%rsi
mov    $0x2,%edi
mov    $0x1f,%edx
call   1040 <write@plt>
mov    $0x1,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"FATAL: could not read input.\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @atoi(i8* %11)
%13 = sitofp i32 %12 to double
%14 = fdiv double 1.600000e+04, %13
%15 = fptosi double %14 to i32
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %7
%19 = alloca i8, i64 %17
store i64 %17, i64* %8
%20 = load i32, i32* %6
%21 = call i64 @read(i32 0, i8* %19, i32 %20)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %2
%24 = call i32 @write(i32 2, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 31)
store i32 1, i32* %3
%25 = load i8*, i8** %7
%26 = load i32, i32* %3
ret i32 %26
27: ; preds = %2
br label %28
28: ; preds = %28, %27
%29 = load i32, i32* %4
%30 = load i32, i32* %6
%31 = srem i32 %29, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %19, i64 %32
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
%38 = load i32, i32* %6
%39 = srem i32 %37, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %19, i64 %40
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = add nsw i32 %35, %43
%45 = sdiv i32 %44, 2
%46 = trunc i32 %45 to i8
%47 = load i32, i32* %4
%48 = load i32, i32* %6
%49 = srem i32 %47, %48
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %19, i64 %50
store i8 %46, i8* %51
%52 = call i32 @putchar(i8 zeroext %46)
br label %28
}

LLVM IR (-O2):
@.str = [31 x i8] c"FATAL: could not read input.\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = sitofp i32 %5 to double
%7 = fdiv double 1.600000e+04, %6
%8 = fptosi double %7 to i32
%9 = zext i32 %8 to i64
%10 = alloca i8, i64 %9
%11 = call i64 @read(i32 0, i8* %10, i32 %8)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = tail call i32 @write(i32 2, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 31)
ret i32 1
15: ; preds = %2, %15
%16 = phi i32 [ %22, %15 ], [ %0, %2 ]
%17 = srem i32 %16, %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %10, i64 %18
%20 = load i8, i8* %19
%21 = zext i8 %20 to i16
%22 = add nsw i32 %16, 1
%23 = srem i32 %22, %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %10, i64 %24
%26 = load i8, i8* %25
%27 = zext i8 %26 to i16
%28 = add nuw nsw i16 %27, %21
%29 = lshr i16 %28, 1
%30 = trunc i16 %29 to i8
store i8 %30, i8* %25
%31 = tail call i32 @putchar(i8 zeroext %30)
br label %15
}