#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 /*<<< orphan*/ printf(char *, char *);
void compress() {
  int count = 0;
  int newCharIndex = 0;
  int len = 10;
  char word[] = {'s', 's', 'h', 'h', 'h', 'j', 'j', 'v', 'v', 'a'};
  int i = 0;
  for (i = 0; i < len; i++) {
    if (word[i] != word[i + 1]) {
      count++;
      word[newCharIndex] = word[i];
      newCharIndex = newCharIndex + 1;
      word[newCharIndex] = (char)(count + 48);
      newCharIndex = newCharIndex + 1;
      count = 0;
    } else {
      count++;
    }
  }
  word[len] = '\0';
  printf("%s\n", word);
}


x86 assembly (clang, -O0):
<compress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
mov    0xecc(%rip),%rax
mov    %rax,-0x16(%rbp)
mov    0xec9(%rip),%ax
mov    %ax,-0xe(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11df <compress+0xcf>
movslq -0x1c(%rbp),%rax
movsbl -0x16(%rbp,%rax,1),%eax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x16(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11c3 <compress+0xb3>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x16(%rbp,%rax,1),%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0x16(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0x16(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
jmp    11cc <compress+0xbc>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11d1 <compress+0xc1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1151 <compress+0x41>
movslq -0xc(%rbp),%rax
movb   $0x0,-0x16(%rbp,%rax,1)
lea    -0x16(%rbp),%rsi
lea    0xe17(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compress>:
sub    $0x18,%rsp
movabs $0x3276326a33683273,%rax
32 76 32
mov    %rax,0xe(%rsp)
movw   $0x3161,0x16(%rsp)
movb   $0x0,0x18(%rsp)
lea    0xeca(%rip),%rdi
lea    0xe(%rsp),%rsi
call   1030 <printf@plt>
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @compress() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 1
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 2
store i8 115, i8* %2
store i8 50, i8* %3
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 3
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 4
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 5
store i8 104, i8* %4
store i8 51, i8* %5
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 6
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 7
store i8 106, i8* %6
store i8 50, i8* %7
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 8
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 9
store i8 118, i8* %8
store i8 50, i8* %9
store i8 97, i8* %10
store i8 49, i8* %11
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 10
store i8 0, i8* %12
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
ret void
}