int main() {
  int n = 0, num, i = 0;
  scanf("%d", &num);
  num = ((num < 0) ? (-num) : (num));
  n = int2arr((int[1000]){0}, num);
  int *arr = malloc(n * sizeof(int));
  int2arr(arr, num);
  sort(arr, n);
  i = 0;
  while (i < n) {
    int curr_cnt = 0;
    while (arr[i] == arr[i + 1]) {
      curr_cnt++;
      i++;
    }
    if (curr_cnt >= 1)
      printf("The number %d is repeated exactly %d times\n", arr[i],
             curr_cnt + 1);
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xe79(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jge    11ac <main+0x4c>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0xfc0(%rbp)
jmp    11b5 <main+0x55>
mov    -0xc(%rbp),%eax
mov    %eax,-0xfc0(%rbp)
mov    -0xfc0(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0xfb0(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1050 <memset@plt>
lea    -0xfb0(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1060 <int2arr@plt>
mov    %eax,-0x8(%rbp)
movslq -0x8(%rbp),%rdi
shl    $0x2,%rdi
call   1070 <malloc@plt>
mov    %rax,-0xfb8(%rbp)
mov    -0xfb8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1060 <int2arr@plt>
mov    -0xfb8(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    $0x0,%al
call   1040 <sort@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12bc <main+0x15c>
movl   $0x0,-0xfbc(%rbp)
mov    -0xfb8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0xfb8(%rbp),%rcx
mov    -0x10(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,4),%eax
jne    127c <main+0x11c>
mov    -0xfbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfbc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1238 <main+0xd8>
cmpl   $0x1,-0xfbc(%rbp)
jl     12ae <main+0x14e>
mov    -0xfb8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0xfbc(%rbp),%edx
add    $0x1,%edx
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1222 <main+0xc2>
xor    %eax,%eax
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xfa8,%rsp
lea    0xe88(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
mov    %eax,%ebx
neg    %ebx
cmovs  %eax,%ebx
mov    %ebx,0x4(%rsp)
lea    0x8(%rsp),%rbp
mov    $0xfa0,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <int2arr@plt>
mov    %eax,%r15d
movslq %eax,%r14
lea    0x0(,%r14,4),%rdi
call   1070 <malloc@plt>
mov    %rax,%r12
mov    0x4(%rsp),%esi
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <int2arr@plt>
mov    %r12,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <sort@plt>
test   %r14d,%r14d
jle    124e <main+0xee>
mov    %r12,%r13
add    $0x4,%r13
xor    %ebp,%ebp
jmp    120b <main+0xab>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
sub    %r14,%rbx
cmp    %ebp,%r15d
mov    %rbx,%rbp
jle    124e <main+0xee>
movslq %ebp,%rbx
mov    (%r12,%rbx,4),%esi
lea    0x0(,%rbx,4),%rax
add    %r13,%rax
xor    %r14d,%r14d
add    $0xffffffffffffffff,%r14
lea    0x4(%rax),%rcx
cmp    (%rax),%esi
mov    %rcx,%rax
je     1220 <main+0xc0>
sub    %r14,%rbp
cmp    $0xffffffff,%r14d
je     1200 <main+0xa0>
mov    %r14,%rdx
neg    %rdx
lea    0xdbe(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1200 <main+0xa0>
xor    %eax,%eax
add    $0xfa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [44 x i8] c"The number %d is repeated exactly %d times\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1000 x i32]
%6 = alloca i32*
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %4
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = load i32, i32* %3
%13 = sub nsw i32 0, %12
br label %16
14: ; preds = %0
%15 = load i32, i32* %3
br label %16
16: ; preds = %14, %11
%17 = phi i32 [ %13, %11 ], [ %15, %14 ]
store i32 %17, i32* %3
%18 = bitcast [1000 x i32]* %5 to i8*
%19 = getelementptr inbounds [1000 x i32], [1000 x i32]* %5, i64 0, i64 0
%20 = getelementptr inbounds [1000 x i32], [1000 x i32]* %5, i64 0, i64 0
%21 = load i32, i32* %3
%22 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @int2arr to i32 (i32*, i32, ...)*)(i32* %20, i32 %21)
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = mul i64 %24, 4
%26 = call i8* @malloc(i64 %25)
%27 = bitcast i8* %26 to i32*
store i32* %27, i32** %6
%28 = load i32*, i32** %6
%29 = load i32, i32* %3
%30 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @int2arr to i32 (i32*, i32, ...)*)(i32* %28, i32 %29)
%31 = load i32*, i32** %6
%32 = load i32, i32* %2
%33 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @sort to i32 (i32*, i32, ...)*)(i32* %31, i32 %32)
store i32 0, i32* %4
br label %34
34: ; preds = %69, %16
%35 = load i32, i32* %4
%36 = load i32, i32* %2
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %72
38: ; preds = %34
store i32 0, i32* %7
br label %39
39: ; preds = %52, %38
%40 = load i32*, i32** %6
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
%44 = load i32, i32* %43
%45 = load i32*, i32** %6
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %45, i64 %48
%50 = load i32, i32* %49
%51 = icmp eq i32 %44, %50
br i1 %51, label %52, label %57
52: ; preds = %39
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
%55 = load i32, i32* %4
%56 = add nsw i32 %55, 1
store i32 %56, i32* %4
br label %39
57: ; preds = %39
%58 = load i32, i32* %7
%59 = icmp sge i32 %58, 1
br i1 %59, label %60, label %69
60: ; preds = %57
%61 = load i32*, i32** %6
%62 = load i32, i32* %4
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %61, i64 %63
%65 = load i32, i32* %64
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 %65, i32 %67)
br label %69
69: ; preds = %60, %57
%70 = load i32, i32* %4
%71 = add nsw i32 %70, 1
store i32 %71, i32* %4
br label %34
72: ; preds = %34
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [44 x i8] c"The number %d is repeated exactly %d times\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i32]
%3 = bitcast i32* %1 to i8*
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = call i32 @llvm.abs.i32(i32 %5, i1 true)
store i32 %6, i32* %1
%7 = bitcast [1000 x i32]* %2 to i8*
%8 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 0
%9 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @int2arr to i32 (i32*, i32, ...)*)(i32* %8, i32 %6)
%10 = sext i32 %9 to i64
%11 = shl nsw i64 %10, 2
%12 = call i8* @malloc(i64 %11)
%13 = bitcast i8* %12 to i32*
%14 = load i32, i32* %1
%15 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @int2arr to i32 (i32*, i32, ...)*)(i32* %13, i32 %14)
%16 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @sort to i32 (i32*, i32, ...)*)(i32* %13, i32 %9)
%17 = icmp sgt i32 %9, 0
br i1 %17, label %18, label %39
18: ; preds = %0, %37
%19 = phi i64 [ %27, %37 ], [ 0, %0 ]
%20 = shl i64 %19, 32
%21 = ashr exact i64 %20, 32
%22 = getelementptr inbounds i32, i32* %13, i64 %21
%23 = load i32, i32* %22
br label %24
24: ; preds = %24, %18
%25 = phi i64 [ %27, %24 ], [ %21, %18 ]
%26 = phi i32 [ %31, %24 ], [ 0, %18 ]
%27 = add nsw i64 %25, 1
%28 = getelementptr inbounds i32, i32* %13, i64 %27
%29 = load i32, i32* %28
%30 = icmp eq i32 %23, %29
%31 = add nuw nsw i32 %26, 1
br i1 %30, label %24, label %32
32: ; preds = %24
%33 = trunc i64 %27 to i32
%34 = icmp eq i32 %26, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %31)
br label %37
37: ; preds = %35, %32
%38 = icmp sgt i32 %9, %33
br i1 %38, label %18, label %39
39: ; preds = %37, %0
ret i32 0
}