#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 *, int);
int /*<<< orphan*/ putchar(int);
void push(char generator, int length) {
  static int k = 0;
  static char previous = 0;
  if (length == 0)
    return;
  if (generator == previous)
    k += length;
  else {
    if (previous != 0) {
      putchar((int)previous);
      if (k > 1)
        printf("%d ", k);
    }
    previous = generator;
    k = length;
  }
}


x86 assembly (clang, -O0):
<push>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1140 <push+0x20>
jmp    11b9 <push+0x99>
movsbl -0x1(%rbp),%eax
movsbl 0x2eed(%rip),%ecx
cmp    %ecx,%eax
jne    1167 <push+0x47>
mov    -0x8(%rbp),%eax
add    0x2ed8(%rip),%eax
mov    %eax,0x2ed2(%rip)
jmp    11b9 <push+0x99>
movsbl 0x2eca(%rip),%eax
cmp    $0x0,%eax
je     11a7 <push+0x87>
movsbl 0x2eba(%rip),%edi
call   1030 <putchar@plt>
cmpl   $0x1,0x2eaa(%rip)
jle    11a2 <push+0x82>
mov    0x2e9e(%rip),%esi
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
jmp    11a7 <push+0x87>
mov    -0x1(%rbp),%al
mov    %al,0x2e88(%rip)
mov    -0x8(%rbp),%eax
mov    %eax,0x2e7b(%rip)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<push>:
test   %esi,%esi
je     1173 <push+0x53>
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
movsbl 0x2f06(%rip),%edi
cmp    %bpl,%dil
jne    113f <push+0x1f>
add    0x2ef7(%rip),%ebx
jmp    1167 <push+0x47>
test   %dil,%dil
je     1160 <push+0x40>
call   1030 <putchar@plt>
mov    0x2ee5(%rip),%esi
cmp    $0x2,%esi
jl     1160 <push+0x40>
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
mov    %bpl,0x2ed1(%rip)
mov    %ebx,0x2ec7(%rip)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@push.k = internal global i32 0
@push.previous = internal global i8 0
@.str = [4 x i8] c"%d \00"
define void @push(i8 signext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
store i8 %0, i8* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %2
br label %35
8: ; preds = %2
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = load i8, i8* @push.previous
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %10, %12
br i1 %13, label %14, label %18
14: ; preds = %8
%15 = load i32, i32* %4
%16 = load i32, i32* @push.k
%17 = add nsw i32 %16, %15
store i32 %17, i32* @push.k
br label %35
18: ; preds = %8
%19 = load i8, i8* @push.previous
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = load i8, i8* @push.previous
%24 = sext i8 %23 to i32
%25 = call i32 @putchar(i32 %24)
%26 = load i32, i32* @push.k
%27 = icmp sgt i32 %26, 1
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i32, i32* @push.k
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %28, %22
br label %32
32: ; preds = %31, %18
%33 = load i8, i8* %3
store i8 %33, i8* @push.previous
%34 = load i32, i32* %4
store i32 %34, i32* @push.k
br label %35
35: ; preds = %7, %32, %14
ret void
}

LLVM IR (-O2):
@push.k = internal unnamed_addr global i32 0
@push.previous = internal unnamed_addr global i8 0
@.str = [4 x i8] c"%d \00"
define void @push(i8 signext %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %22, label %4
4: ; preds = %2
%5 = load i8, i8* @push.previous
%6 = sext i8 %5 to i32
%7 = icmp eq i8 %5, %0
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = load i32, i32* @push.k
%10 = add nsw i32 %9, %1
br label %20
11: ; preds = %4
%12 = icmp eq i8 %5, 0
br i1 %12, label %19, label %13
13: ; preds = %11
%14 = tail call i32 @putchar(i32 %6)
%15 = load i32, i32* @push.k
%16 = icmp sgt i32 %15, 1
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %19
19: ; preds = %13, %17, %11
store i8 %0, i8* @push.previous
br label %20
20: ; preds = %8, %19
%21 = phi i32 [ %1, %19 ], [ %10, %8 ]
store i32 %21, i32* @push.k
br label %22
22: ; preds = %20, %2
ret void
}