#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*/ findOccurrence(char *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int processString(char *istring, char *ostring) {
  int i = 0, count = 1, length;
  char buffer[100];
  length = strlen(istring);
  if (NULL == istring) {
    printf("\nERROR : invalid input\n");
  } else if (1 == length) {
    return 0;
  }
  while (i != length) {
    count = 1;
    strcat(ostring, &istring[i]);
    if (istring[i] == istring[i + 1]) {
      findOccurrence(istring, &i, &count);
    }
    sprintf(buffer, "%d", count);
    printf("\nbuffer : %s", buffer);
    strcat(ostring, buffer);
  }
  return 0;
}


x86 assembly (clang, -O0):
<processString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    119c <processString+0x4c>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11bb <processString+0x6b>
mov    $0x1,%eax
cmp    -0x24(%rbp),%eax
jne    11b6 <processString+0x66>
movl   $0x0,-0x4(%rbp)
jmp    1264 <processString+0x114>
jmp    11bb <processString+0x6b>
jmp    11c0 <processString+0x70>
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     125d <processString+0x10d>
movl   $0x1,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rax
add    %rax,%rsi
call   1060 <strcat@plt>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    121d <processString+0xcd>
mov    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <findOccurrence@plt>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xdea(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x90(%rbp),%rsi
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1060 <strcat@plt>
jmp    11c0 <processString+0x70>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,0x8(%rsp)
call   1040 <strlen@plt>
mov    %eax,%ebp
test   %rbx,%rbx
je     1192 <processString+0x32>
cmp    $0x2,%ebp
jae    11a6 <processString+0x46>
jmp    1228 <processString+0xc8>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
test   %ebp,%ebp
je     1228 <processString+0xc8>
lea    0xe53(%rip),%r13
lea    0x10(%rsp),%r15
lea    0xe4a(%rip),%r12
xor    %eax,%eax
jmp    11ef <processString+0x8f>
nopl   (%rax)
mov    0xc(%rsp),%edx
mov    %r15,%rdi
mov    %r13,%rsi
call   1080 <sprintf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <strcat@plt>
mov    0x8(%rsp),%eax
cmp    %ebp,%eax
je     1228 <processString+0xc8>
movl   $0x1,0xc(%rsp)
movslq %eax,%rsi
add    %rbx,%rsi
mov    %r14,%rdi
call   1070 <strcat@plt>
movslq 0x8(%rsp),%rax
movzbl (%rbx,%rax,1),%ecx
cmp    0x1(%rbx,%rax,1),%cl
jne    11c0 <processString+0x60>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1060 <findOccurrence@plt>
jmp    11c0 <processString+0x60>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"\0Abuffer : %s\00"
@str = [23 x i8] c"\0AERROR : invalid input\00"
define i32 @processString(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i8]
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast i32* %4 to i8*
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%9 = tail call i32 @strlen(i8* %0)
%10 = icmp eq i8* %0, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%13 = icmp eq i32 %9, 0
br i1 %13, label %40, label %16
14: ; preds = %2
%15 = icmp ult i32 %9, 2
br i1 %15, label %40, label %16
16: ; preds = %11, %14
br label %17
17: ; preds = %16, %33
%18 = phi i32 [ %38, %33 ], [ 0, %16 ]
store i32 1, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = call i32 @strcat(i8* %1, i8* %20)
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = load i8, i8* %24
%26 = add nsw i32 %22, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %0, i64 %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %25, %29
br i1 %30, label %31, label %33
31: ; preds = %17
%32 = call i32 @findOccurrence(i8* %0, i32* %3, i32* %4)
br label %33
33: ; preds = %31, %17
%34 = load i32, i32* %4
%35 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%37 = call i32 @strcat(i8* %1, i8* %8)
%38 = load i32, i32* %3
%39 = icmp eq i32 %38, %9
br i1 %39, label %40, label %17
40: ; preds = %33, %11, %14
ret i32 0
}