void outputrle(int chr, void (*outputfunc)(int)) {
  static int lastchr = 0, repeating = 0;
  int f;
  if (chr == -1) {
    lastchr = repeating = 0;
    return;
  }
  if (repeating) {
    if (chr == 0)
      (*outputfunc)(0x90);
    else
      for (f = 1; f < chr; f++)
        (*outputfunc)(lastchr);
    repeating = 0;
  } else {
    if (chr == 0x90)
      repeating = 1;
    else {
      (*outputfunc)(chr);
      lastchr = chr;
    }
  }
}


x86 assembly (clang, -O0):
<outputrle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    1132 <outputrle+0x32>
movl   $0x0,0x2f05(%rip)
movl   $0x0,0x2ef7(%rip)
jmp    11ca <outputrle+0xca>
cmpl   $0x0,0x2eef(%rip)
je     1197 <outputrle+0x97>
cmpl   $0x0,-0x4(%rbp)
jne    1156 <outputrle+0x56>
mov    $0x90,%edi
call   *-0x10(%rbp)
jmp    1188 <outputrle+0x88>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1183 <outputrle+0x83>
mov    -0x10(%rbp),%rax
mov    0x2eb1(%rip),%edi
call   *%rax
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <outputrle+0x5d>
jmp    1188 <outputrle+0x88>
movl   $0x0,0x2e96(%rip)
jmp    11ca <outputrle+0xca>
cmpl   $0x90,-0x4(%rbp)
jne    11b3 <outputrle+0xb3>
movl   $0x1,0x2e7a(%rip)
jmp    11c5 <outputrle+0xc5>
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%edi
call   *%rax
mov    -0x4(%rbp),%eax
mov    %eax,0x2e5f(%rip)
jmp    11ca <outputrle+0xca>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<outputrle>:
push   %rbp
push   %rbx
push   %rax
cmp    $0xffffffff,%edi
je     113f <outputrle+0x3f>
mov    %rsi,%rbx
mov    %edi,%ebp
cmpb   $0x1,0x2f14(%rip)
jne    1152 <outputrle+0x52>
test   %ebp,%ebp
je     116f <outputrle+0x6f>
cmp    $0x2,%ebp
jl     1176 <outputrle+0x76>
add    $0xffffffff,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x2eee(%rip),%edi
call   *%rbx
add    $0xffffffff,%ebp
jne    1130 <outputrle+0x30>
jmp    1176 <outputrle+0x76>
movb   $0x0,0x2ee2(%rip)
movl   $0x0,0x2ed4(%rip)
jmp    117d <outputrle+0x7d>
cmp    $0x90,%ebp
jne    1163 <outputrle+0x63>
movb   $0x1,0x2ec7(%rip)
jmp    117d <outputrle+0x7d>
mov    %ebp,%edi
call   *%rbx
mov    %ebp,0x2eb7(%rip)
jmp    117d <outputrle+0x7d>
mov    $0x90,%edi
call   *%rbx
movb   $0x0,0x2eab(%rip)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@outputrle.lastchr = internal global i32 0
@outputrle.repeating = internal global i32 0
define void @outputrle(i32 %0, void (i32)* %1) {
%3 = alloca i32
%4 = alloca void (i32)*
%5 = alloca i32
store i32 %0, i32* %3
store void (i32)* %1, void (i32)** %4
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 0, i32* @outputrle.repeating
store i32 0, i32* @outputrle.lastchr
br label %39
9: ; preds = %2
%10 = load i32, i32* @outputrle.repeating
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = load void (i32)*, void (i32)** %4
br label %29
17: ; preds = %12
store i32 1, i32* %5
br label %18
18: ; preds = %25, %17
%19 = load i32, i32* %5
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = load void (i32)*, void (i32)** %4
%24 = load i32, i32* @outputrle.lastchr
br label %25
25: ; preds = %22
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %18
28: ; preds = %18
br label %29
29: ; preds = %28, %15
store i32 0, i32* @outputrle.repeating
br label %39
30: ; preds = %9
%31 = load i32, i32* %3
%32 = icmp eq i32 %31, 144
br i1 %32, label %33, label %34
33: ; preds = %30
store i32 1, i32* @outputrle.repeating
br label %38
34: ; preds = %30
%35 = load void (i32)*, void (i32)** %4
%36 = load i32, i32* %3
%37 = load i32, i32* %3
store i32 %37, i32* @outputrle.lastchr
br label %38
38: ; preds = %34, %33
br label %39
39: ; preds = %8, %38, %29
ret void
}

LLVM IR (-O2):
@outputrle.lastchr = internal unnamed_addr global i32 0
@outputrle.repeating = internal unnamed_addr global i1 false
define void @outputrle(i32 %0, void (i32)* nocapture %1) {
%3 = icmp eq i32 %0, -1
br i1 %3, label %4, label %5
4: ; preds = %2
store i1 false, i1* @outputrle.repeating
store i32 0, i32* @outputrle.lastchr
br label %22
5: ; preds = %2
%6 = load i1, i1* @outputrle.repeating
br i1 %6, label %7, label %18
7: ; preds = %5
%8 = icmp eq i32 %0, 0
br i1 %8, label %11, label %9
9: ; preds = %7
%10 = icmp sgt i32 %0, 1
br i1 %10, label %12, label %17
11: ; preds = %7
tail call void %1(i32 144)
br label %17
12: ; preds = %9, %12
%13 = phi i32 [ %15, %12 ], [ 1, %9 ]
%14 = load i32, i32* @outputrle.lastchr
tail call void %1(i32 %14)
%15 = add nuw nsw i32 %13, 1
%16 = icmp eq i32 %15, %0
br i1 %16, label %17, label %12
17: ; preds = %12, %9, %11
store i1 false, i1* @outputrle.repeating
br label %22
18: ; preds = %5
%19 = icmp eq i32 %0, 144
br i1 %19, label %20, label %21
20: ; preds = %18
store i1 true, i1* @outputrle.repeating
br label %22
21: ; preds = %18
tail call void %1(i32 %0)
store i32 %0, i32* @outputrle.lastchr
br label %22
22: ; preds = %17, %21, %20, %4
ret void
}