int main() {
  int n = 0, num, i = 0;
  scanf("%d", ({
          printf("Enter a number:");
          &num;
        }));
  num = ((num < 0) ? (-num) : (num));
  n = int2arr((int[1000]){}, 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    $0xfd0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xc(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jge    11c2 <main+0x62>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0xfc8(%rbp)
jmp    11cb <main+0x6b>
mov    -0xc(%rbp),%eax
mov    %eax,-0xfc8(%rbp)
mov    -0xfc8(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0xfb8(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1050 <memset@plt>
lea    -0xfb8(%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,-0xfc0(%rbp)
mov    -0xfc0(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1060 <int2arr@plt>
mov    -0xfc0(%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    12d2 <main+0x172>
movl   $0x0,-0xfc4(%rbp)
mov    -0xfc0(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0xfc0(%rbp),%rcx
mov    -0x10(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,4),%eax
jne    1292 <main+0x132>
mov    -0xfc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfc4(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    124e <main+0xee>
cmpl   $0x1,-0xfc4(%rbp)
jl     12c4 <main+0x164>
mov    -0xfc0(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0xfc4(%rbp),%edx
add    $0x1,%edx
lea    0xd56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1238 <main+0xd8>
xor    %eax,%eax
add    $0xfd0,%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    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe7a(%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    125e <main+0xfe>
mov    %r12,%r13
add    $0x4,%r13
xor    %ebp,%ebp
jmp    121b <main+0xbb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
sub    %r14,%rbx
cmp    %ebp,%r15d
mov    %rbx,%rbp
jle    125e <main+0xfe>
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     1230 <main+0xd0>
sub    %r14,%rbp
cmp    $0xffffffff,%r14d
je     1210 <main+0xb0>
mov    %r14,%rdx
neg    %rdx
lea    0xdbe(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1210 <main+0xb0>
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 = [16 x i8] c"Enter a number:\00"
@.str.2 = [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 i32*
%6 = alloca [1000 x i32]
%7 = alloca i32*
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %4
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %5
%10 = load i32*, i32** %5
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %10)
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = load i32, i32* %3
%16 = sub nsw i32 0, %15
br label %19
17: ; preds = %0
%18 = load i32, i32* %3
br label %19
19: ; preds = %17, %14
%20 = phi i32 [ %16, %14 ], [ %18, %17 ]
store i32 %20, i32* %3
%21 = bitcast [1000 x i32]* %6 to i8*
%22 = getelementptr inbounds [1000 x i32], [1000 x i32]* %6, i64 0, i64 0
%23 = getelementptr inbounds [1000 x i32], [1000 x i32]* %6, i64 0, i64 0
%24 = load i32, i32* %3
%25 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @int2arr to i32 (i32*, i32, ...)*)(i32* %23, i32 %24)
store i32 %25, i32* %2
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = mul i64 %27, 4
%29 = call i8* @malloc(i64 %28)
%30 = bitcast i8* %29 to i32*
store i32* %30, i32** %7
%31 = load i32*, i32** %7
%32 = load i32, i32* %3
%33 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @int2arr to i32 (i32*, i32, ...)*)(i32* %31, i32 %32)
%34 = load i32*, i32** %7
%35 = load i32, i32* %2
%36 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @sort to i32 (i32*, i32, ...)*)(i32* %34, i32 %35)
store i32 0, i32* %4
br label %37
37: ; preds = %72, %19
%38 = load i32, i32* %4
%39 = load i32, i32* %2
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %75
41: ; preds = %37
store i32 0, i32* %8
br label %42
42: ; preds = %55, %41
%43 = load i32*, i32** %7
%44 = load i32, i32* %4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = load i32, i32* %46
%48 = load i32*, i32** %7
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %48, i64 %51
%53 = load i32, i32* %52
%54 = icmp eq i32 %47, %53
br i1 %54, label %55, label %60
55: ; preds = %42
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
store i32 %57, i32* %8
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
store i32 %59, i32* %4
br label %42
60: ; preds = %42
%61 = load i32, i32* %8
%62 = icmp sge i32 %61, 1
br i1 %62, label %63, label %72
63: ; preds = %60
%64 = load i32*, i32** %7
%65 = load i32, i32* %4
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %64, i64 %66
%68 = load i32, i32* %67
%69 = load i32, i32* %8
%70 = add nsw i32 %69, 1
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i32 %68, i32 %70)
br label %72
72: ; preds = %63, %60
%73 = load i32, i32* %4
%74 = add nsw i32 %73, 1
store i32 %74, i32* %4
br label %37
75: ; preds = %37
ret i32 0
}

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