#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 EOF;
int /*<<< orphan*/ code(int *);
scalar_t__ getchar();
int key(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int buf[4];
  int i, counter = 0;
  buf[counter] = (int)getchar();
  while (buf[counter] != EOF) {
    counter++;
    if (counter == 4) {
      printf("%i ", key(code(buf)));
      counter = 0;
    }
    buf[counter] = (int)getchar();
  }
  if (counter > 0) {
    for (i = counter; i < 4; i++)
      buf[i] = ' ';
    printf("%i ", key(code(buf)));
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x28(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,%ecx
movslq -0x28(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    0x2e72(%rip),%rcx
cmp    (%rcx),%eax
je     11ce <main+0x8e>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jne    11b8 <main+0x78>
lea    -0x20(%rbp),%rdi
call   1060 <code@plt>
mov    %eax,%edi
call   1030 <key@plt>
mov    %eax,%esi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,%ecx
movslq -0x28(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
jmp    1167 <main+0x27>
cmpl   $0x0,-0x28(%rbp)
jle    1222 <main+0xe2>
mov    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    1202 <main+0xc2>
movslq -0x24(%rbp),%rax
movl   $0x20,-0x20(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11de <main+0x9e>
lea    -0x20(%rbp),%rdi
call   1060 <code@plt>
mov    %eax,%edi
call   1030 <key@plt>
mov    %eax,%esi
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,(%rsp)
mov    0x2e7d(%rip),%rbx
cmp    %eax,(%rbx)
je     1210 <main+0xc0>
mov    %rsp,%r14
lea    0xe83(%rip),%r15
xor    %ebp,%ebp
jmp    11a1 <main+0x51>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
movslq %ebp,%rcx
mov    %eax,(%rsp,%rcx,4)
cmp    %eax,(%rbx)
je     11c8 <main+0x78>
add    $0x1,%ebp
cmp    $0x4,%ebp
jne    1190 <main+0x40>
mov    %r14,%rdi
call   1070 <code@plt>
mov    %eax,%edi
call   1040 <key@plt>
xor    %ebp,%ebp
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1190 <main+0x40>
test   %ebp,%ebp
jle    1210 <main+0xc0>
cmp    $0x3,%ebp
ja     11f1 <main+0xa1>
mov    %ebp,%eax
movl   $0x20,(%rsp,%rax,4)
je     11f1 <main+0xa1>
movl   $0x20,0x4(%rsp,%rax,4)
cmp    $0x2,%eax
je     11f1 <main+0xa1>
movl   $0x20,0x8(%rsp,%rax,4)
mov    %rsp,%rdi
call   1070 <code@plt>
mov    %eax,%edi
call   1040 <key@plt>
lea    0xdf9(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [4 x i8] c"%i \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i64 (...) @getchar()
%6 = trunc i64 %5 to i32
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %8
store i32 %6, i32* %9
br label %10
10: ; preds = %27, %0
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = load i32, i32* @EOF
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %33
17: ; preds = %10
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 4
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%24 = call i32 @code(i32* %23)
%25 = call i32 @key(i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
store i32 0, i32* %4
br label %27
27: ; preds = %22, %17
%28 = call i64 (...) @getchar()
%29 = trunc i64 %28 to i32
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %31
store i32 %29, i32* %32
br label %10
33: ; preds = %10
%34 = load i32, i32* %4
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %53
36: ; preds = %33
%37 = load i32, i32* %4
store i32 %37, i32* %3
br label %38
38: ; preds = %45, %36
%39 = load i32, i32* %3
%40 = icmp slt i32 %39, 4
br i1 %40, label %41, label %48
41: ; preds = %38
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %43
store i32 32, i32* %44
br label %45
45: ; preds = %41
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
br label %38
48: ; preds = %38
%49 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%50 = call i32 @code(i32* %49)
%51 = call i32 @key(i32 %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %48, %33
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [4 x i8] c"%i \00"
define i32 @main() {
%1 = alloca [4 x i32]
%2 = bitcast [4 x i32]* %1 to i8*
%3 = tail call i64 (...) @getchar()
%4 = trunc i64 %3 to i32
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
store i32 %4, i32* %5
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %6, %4
br i1 %7, label %45, label %8
8: ; preds = %0, %16
%9 = phi i32 [ %17, %16 ], [ 0, %0 ]
%10 = add nsw i32 %9, 1
%11 = icmp eq i32 %10, 4
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = call i32 @code(i32* %5)
%14 = call i32 @key(i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %12, %8
%17 = phi i32 [ 0, %12 ], [ %10, %8 ]
%18 = call i64 (...) @getchar()
%19 = trunc i64 %18 to i32
%20 = sext i32 %17 to i64
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %20
store i32 %19, i32* %21
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %22, %19
br i1 %23, label %24, label %8
24: ; preds = %16
%25 = icmp sgt i32 %17, 0
br i1 %25, label %26, label %45
26: ; preds = %24
%27 = icmp ult i32 %17, 4
br i1 %27, label %28, label %41
28: ; preds = %26
%29 = zext i32 %17 to i64
%30 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %29
store i32 32, i32* %30
%31 = add nuw nsw i64 %29, 1
%32 = trunc i64 %31 to i32
%33 = icmp eq i32 %32, 4
br i1 %33, label %41, label %34
34: ; preds = %28
%35 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %31
store i32 32, i32* %35
%36 = add nuw nsw i64 %29, 2
%37 = trunc i64 %36 to i32
%38 = icmp eq i32 %37, 4
br i1 %38, label %41, label %39
39: ; preds = %34
%40 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %36
store i32 32, i32* %40
br label %41
41: ; preds = %28, %34, %39, %26
%42 = call i32 @code(i32* %5)
%43 = call i32 @key(i32 %42)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %0, %41, %24
%46 = call i32 @putchar(i32 10)
ret i32 0
}