#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fcloseall();
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, short);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, short *, ...);
int main() {
  FILE *fi = fopen("INP.TXT", "r"), *fo = fopen("OUT.TXT", "w");
  short n, i, a, b[10000] = {};
  char m;
  fscanf(fi, "%hd %hhd", &n, &m);
  for (i = 0; i < n; i++) {
    fscanf(fi, "%hd", &a);
    fprintf(fo, "%hd ", ++b[a - 1]);
  }
  fputc(10, fo);
  fcloseall();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
lea    0xe88(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe7a(%rip),%rdi
lea    0xe7b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x4e40(%rbp),%rdi
xor    %esi,%esi
mov    $0x4e20,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    0xe56(%rip),%rsi
lea    -0x1a(%rbp),%rdx
lea    -0x4e41(%rbp),%rcx
mov    $0x0,%al
call   1040 <fscanf@plt>
movw   $0x0,-0x1c(%rbp)
movswl -0x1c(%rbp),%eax
movswl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
jge    123e <main+0xde>
mov    -0x10(%rbp),%rdi
lea    0xe2c(%rip),%rsi
lea    -0x1e(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0x18(%rbp),%rdi
movswl -0x1e(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
mov    -0x4e40(%rbp,%rcx,2),%ax
ff
add    $0x1,%ax
mov    %ax,-0x4e40(%rbp,%rcx,2)
ff
lea    0xdfc(%rip),%rsi
movswl %ax,%edx
call   1060 <fprintf@plt>
mov    -0x1c(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x1c(%rbp)
jmp    11d6 <main+0x76>
mov    -0x18(%rbp),%rsi
mov    $0xa,%edi
call   1050 <fputc@plt>
mov    $0x0,%al
call   1080 <fcloseall@plt>
xor    %eax,%eax
add    $0x4e50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4e38,%rsp
lea    0xe88(%rip),%rdi
lea    0xe89(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
lea    0xe7c(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0x10(%rsp),%rdi
mov    $0x4e20,%edx
xor    %esi,%esi
call   1030 <memset@plt>
lea    0xe5f(%rip),%rsi
lea    0xa(%rsp),%rdx
lea    0xf(%rsp),%rcx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
cmpw   $0x0,0xa(%rsp)
jle    122b <main+0xcb>
lea    0xe45(%rip),%r15
lea    0xc(%rsp),%r12
lea    0xe3d(%rip),%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
movswq 0xc(%rsp),%rax
movzwl 0xe(%rsp,%rax,2),%ecx
add    $0x1,%ecx
mov    %cx,0xe(%rsp,%rax,2)
movswl %cx,%edx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <fprintf@plt>
add    $0x1,%ebp
cmp    0xa(%rsp),%bp
jl     11f0 <main+0x90>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
xor    %eax,%eax
call   1080 <fcloseall@plt>
xor    %eax,%eax
add    $0x4e38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"INP.TXT\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"OUT.TXT\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [9 x i8] c"%hd %hhd\00"
@.str.5 = [4 x i8] c"%hd\00"
@.str.6 = [5 x i8] c"%hd \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
%7 = alloca [10000 x i16]
%8 = alloca i8
store i32 0, i32* %1
%9 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %2
%10 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %10, i32** %3
%11 = bitcast [10000 x i16]* %7 to i8*
%12 = load i32*, i32** %2
%13 = call i32 (i32*, i8*, i16*, ...) @fscanf(i32* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i16* %4, i8* %8)
store i16 0, i16* %5
br label %14
14: ; preds = %32, %0
%15 = load i16, i16* %5
%16 = sext i16 %15 to i32
%17 = load i16, i16* %4
%18 = sext i16 %17 to i32
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %35
20: ; preds = %14
%21 = load i32*, i32** %2
%22 = call i32 (i32*, i8*, i16*, ...) @fscanf(i32* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i16* %6)
%23 = load i32*, i32** %3
%24 = load i16, i16* %6
%25 = sext i16 %24 to i32
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10000 x i16], [10000 x i16]* %7, i64 0, i64 %27
%29 = load i16, i16* %28
%30 = add i16 %29, 1
store i16 %30, i16* %28
%31 = call i32 @fprintf(i32* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i16 signext %30)
br label %32
32: ; preds = %20
%33 = load i16, i16* %5
%34 = add i16 %33, 1
store i16 %34, i16* %5
br label %14
35: ; preds = %14
%36 = load i32*, i32** %3
%37 = call i32 @fputc(i32 10, i32* %36)
%38 = call i32 (...) @fcloseall()
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"INP.TXT\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"OUT.TXT\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [9 x i8] c"%hd %hhd\00"
@.str.5 = [4 x i8] c"%hd\00"
@.str.6 = [5 x i8] c"%hd \00"
define i32 @main() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca [10000 x i16]
%4 = alloca i8
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%7 = bitcast i16* %1 to i8*
%8 = bitcast i16* %2 to i8*
%9 = bitcast [10000 x i16]* %3 to i8*
%10 = call i32 (i32*, i8*, i16*, ...) @fscanf(i32* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i16* %1, i8* %4)
%11 = load i16, i16* %1
%12 = icmp sgt i16 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %0, %13
%14 = phi i16 [ %23, %13 ], [ 0, %0 ]
%15 = call i32 (i32*, i8*, i16*, ...) @fscanf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i16* %2)
%16 = load i16, i16* %2
%17 = sext i16 %16 to i64
%18 = add nsw i64 %17, -1
%19 = getelementptr inbounds [10000 x i16], [10000 x i16]* %3, i64 0, i64 %18
%20 = load i16, i16* %19
%21 = add i16 %20, 1
store i16 %21, i16* %19
%22 = call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i16 signext %21)
%23 = add nuw nsw i16 %14, 1
%24 = load i16, i16* %1
%25 = icmp slt i16 %23, %24
br i1 %25, label %13, label %26
26: ; preds = %13, %0
%27 = call i32 @fputc(i32 10, i32* %6)
%28 = call i32 (...) @fcloseall()
ret i32 0
}