#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
char *strstr(char const *, char *);
char *rename_pop_registers(char *dest, const char *src, int dest_size) {
  int i, j, regs;
  char *eq[6] = {"sl", "fp", "ip", "sp", "lr", "pc"};
  char *pos[6];
  unsigned char pos2[6];
  char *__restrict tmp1;
  char *__restrict tmp2;
  char *ptr;
  for (i = 0; i < dest_size; i++)
    dest[i] = '\0';
  tmp1 = (char *)malloc(10);
  tmp2 = (char *)malloc(10);
  for (i = 10, j = 0, regs = 0; i <= 15; i++) {
    sprintf(tmp1, "r%d", i);
    ptr = strstr(src, tmp1);
    if (ptr != NULL) {
      pos[regs++] = ptr;
      pos2[j++] = i - 10;
    }
  }
  if (regs == 0) {
    free(tmp1);
    free(tmp2);
    return dest;
  }
  if (regs < 6)
    pos[regs] = pos[regs - 1] + 3;
  strncpy(dest, src, pos[0] - src);
  for (i = 0; i < regs; i++) {
    ptr = pos[i] + 3;
    strcat(dest, eq[pos2[i]]);
    while (ptr < pos[i + 1]) {
      sprintf(tmp2, "%c", *ptr++);
      strcat(dest, tmp2);
    }
  }
  while (*ptr != 0) {
    sprintf(tmp2, "%c", *ptr++);
    strcat(dest, tmp2);
  }
  free(tmp1);
  free(tmp2);
  return dest;
}


x86 assembly (clang, -O0):
<rename_pop_registers>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
lea    0xe63(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xe5b(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xe53(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xe4b(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xe43(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe3b(%rip),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1205 <rename_pop_registers+0x95>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11df <rename_pop_registers+0x6f>
mov    $0xa,%edi
call   1060 <malloc@plt>
mov    %rax,-0xa0(%rbp)
mov    $0xa,%edi
call   1060 <malloc@plt>
mov    %rax,-0xa8(%rbp)
movl   $0xa,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0xf,-0x20(%rbp)
jg     12cc <rename_pop_registers+0x15c>
mov    -0xa0(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xdbb(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0xa0(%rbp),%rsi
call   1090 <strstr@plt>
mov    %rax,-0xb0(%rbp)
cmpq   $0x0,-0xb0(%rbp)
je     12b9 <rename_pop_registers+0x149>
mov    -0xb0(%rbp),%rcx
mov    -0x28(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
cltq
mov    %rcx,-0x90(%rbp,%rax,8)
ff
mov    -0x20(%rbp),%eax
sub    $0xa,%eax
mov    %al,%cl
mov    -0x24(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
cltq
mov    %cl,-0x96(%rbp,%rax,1)
jmp    12be <rename_pop_registers+0x14e>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    123c <rename_pop_registers+0xcc>
cmpl   $0x0,-0x28(%rbp)
jne    12fb <rename_pop_registers+0x18b>
mov    -0xa0(%rbp),%rdi
call   1030 <free@plt>
mov    -0xa8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    146f <rename_pop_registers+0x2ff>
cmpl   $0x6,-0x28(%rbp)
jge    1325 <rename_pop_registers+0x1b5>
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x90(%rbp,%rax,8),%rcx
ff
add    $0x3,%rcx
movslq -0x28(%rbp),%rax
mov    %rcx,-0x90(%rbp,%rax,8)
ff
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x90(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1040 <strncpy@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    13f7 <rename_pop_registers+0x287>
movslq -0x20(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rax
ff
add    $0x3,%rax
mov    %rax,-0xb0(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x20(%rbp),%rax
movzbl -0x96(%rbp,%rax,1),%eax
ff
mov    -0x60(%rbp,%rax,8),%rsi
call   1070 <strcat@plt>
mov    -0xb0(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    -0x90(%rbp,%rcx,8),%rax
ff
jae    13e4 <rename_pop_registers+0x274>
mov    -0xa8(%rbp),%rdi
mov    -0xb0(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xb0(%rbp)
movsbl (%rax),%edx
lea    0xc4c(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0xa8(%rbp),%rsi
call   1070 <strcat@plt>
jmp    1386 <rename_pop_registers+0x216>
jmp    13e9 <rename_pop_registers+0x279>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1349 <rename_pop_registers+0x1d9>
jmp    13fc <rename_pop_registers+0x28c>
mov    -0xb0(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     144f <rename_pop_registers+0x2df>
mov    -0xa8(%rbp),%rdi
mov    -0xb0(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xb0(%rbp)
movsbl (%rax),%edx
lea    0xbe1(%rip),%rsi
call   1080 <sprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0xa8(%rbp),%rsi
call   1070 <strcat@plt>
jmp    13fc <rename_pop_registers+0x28c>
mov    -0xa0(%rbp),%rdi
call   1030 <free@plt>
mov    -0xa8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rename_pop_registers>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%r14
mov    %rdi,%rbp
lea    0xe72(%rip),%rax
mov    %rax,0x60(%rsp)
lea    0xe69(%rip),%rax
mov    %rax,0x68(%rsp)
lea    0xe60(%rip),%rax
mov    %rax,0x70(%rsp)
lea    0xe57(%rip),%rax
mov    %rax,0x78(%rsp)
lea    0xe4e(%rip),%rax
mov    %rax,0x80(%rsp)
lea    0xe42(%rip),%rax
mov    %rax,0x88(%rsp)
test   %edx,%edx
jle    11e5 <rename_pop_registers+0x75>
mov    %edx,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    $0xa,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0xa,%edi
call   1060 <malloc@plt>
mov    %rax,%r13
lea    0xe0c(%rip),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     1235 <rename_pop_registers+0xc5>
mov    %rax,0x30(%rsp)
movb   $0x0,0xa(%rsp)
mov    $0x1,%r15d
jmp    1238 <rename_pop_registers+0xc8>
xor    %r15d,%r15d
lea    0xdd3(%rip),%rsi
mov    %rbx,%rdi
mov    $0xb,%edx
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     126d <rename_pop_registers+0xfd>
mov    %r15d,%ecx
add    $0x1,%r15d
mov    %rax,0x30(%rsp,%rcx,8)
movb   $0x1,0xa(%rsp,%rcx,1)
lea    0xd9e(%rip),%rsi
mov    %rbx,%rdi
mov    $0xc,%edx
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     12a2 <rename_pop_registers+0x132>
mov    %r15d,%ecx
add    $0x1,%r15d
mov    %rax,0x30(%rsp,%rcx,8)
movb   $0x2,0xa(%rsp,%rcx,1)
lea    0xd69(%rip),%rsi
mov    %rbx,%rdi
mov    $0xd,%edx
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     12d7 <rename_pop_registers+0x167>
mov    %r15d,%ecx
add    $0x1,%r15d
mov    %rax,0x30(%rsp,%rcx,8)
movb   $0x3,0xa(%rsp,%rcx,1)
lea    0xd34(%rip),%rsi
mov    %rbx,%rdi
mov    $0xe,%edx
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     130c <rename_pop_registers+0x19c>
mov    %r15d,%ecx
add    $0x1,%r15d
mov    %rax,0x30(%rsp,%rcx,8)
movb   $0x4,0xa(%rsp,%rcx,1)
lea    0xcff(%rip),%rsi
mov    %rbx,%rdi
mov    $0xf,%edx
call   1080 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     1349 <rename_pop_registers+0x1d9>
mov    %r15d,%ecx
mov    %rax,0x30(%rsp,%rcx,8)
movb   $0x5,0xa(%rsp,%rcx,1)
cmp    $0x4,%r15d
ja     136e <rename_pop_registers+0x1fe>
add    $0x1,%r15d
jmp    1352 <rename_pop_registers+0x1e2>
test   %r15d,%r15d
je     146c <rename_pop_registers+0x2fc>
mov    %rbx,0x18(%rsp)
lea    -0x1(%r15),%eax
mov    0x30(%rsp,%rax,8),%rax
add    $0x3,%rax
mov    %r15d,%ecx
mov    %rax,0x30(%rsp,%rcx,8)
jmp    1379 <rename_pop_registers+0x209>
mov    %rbx,0x18(%rsp)
mov    $0x6,%r15d
mov    0x30(%rsp),%rbx
mov    %ebx,%edx
sub    %r14d,%edx
mov    %rbp,0x10(%rsp)
mov    %rbp,%rdi
mov    %r14,%rsi
call   1040 <strncpy@plt>
mov    %r15d,%ebp
xor    %r14d,%r14d
mov    %rbp,0x20(%rsp)
jmp    13a5 <rename_pop_registers+0x235>
cmp    %rbp,%r14
je     1424 <rename_pop_registers+0x2b4>
mov    %rbx,%r15
lea    0x3(%rbx),%r12
movzbl 0xa(%rsp,%r14,1),%eax
mov    0x60(%rsp,%rax,8),%rsi
mov    0x10(%rsp),%rdi
call   1070 <strcat@plt>
mov    0x38(%rsp,%r14,8),%rbx
add    $0x1,%r14
cmp    %rbx,%r12
jae    13a0 <rename_pop_registers+0x230>
mov    %rbx,0x28(%rsp)
mov    %rbx,%r12
sub    %r15,%r12
mov    $0x3,%ebx
mov    0x10(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r15,%rbx,1),%eax
mov    %al,0x0(%r13)
movb   $0x0,0x1(%r13)
mov    %rbp,%rdi
mov    %r13,%rsi
call   1070 <strcat@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    13f0 <rename_pop_registers+0x280>
mov    0x28(%rsp),%rbx
mov    %rbx,%r12
mov    0x20(%rsp),%rbp
jmp    13a0 <rename_pop_registers+0x230>
mov    (%r12),%al
test   %al,%al
je     1462 <rename_pop_registers+0x2f2>
add    $0x3,%r15
cmp    %r15,%rbx
cmova  %rbx,%r15
add    $0x1,%r15
mov    0x10(%rsp),%rbp
mov    %al,0x0(%r13)
movb   $0x0,0x1(%r13)
mov    %rbp,%rdi
mov    %r13,%rsi
call   1070 <strcat@plt>
movzbl (%r15),%eax
add    $0x1,%r15
test   %al,%al
jne    1440 <rename_pop_registers+0x2d0>
jmp    1467 <rename_pop_registers+0x2f7>
mov    0x10(%rsp),%rbp
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbp,%rax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"sl\00"
@.str.1 = [3 x i8] c"fp\00"
@.str.2 = [3 x i8] c"ip\00"
@.str.3 = [3 x i8] c"sp\00"
@.str.4 = [3 x i8] c"lr\00"
@.str.5 = [3 x i8] c"pc\00"
@.str.6 = [4 x i8] c"r%d\00"
@.str.7 = [3 x i8] c"%c\00"
define i8* @rename_pop_registers(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [6 x i8*]
%12 = alloca [6 x i8*]
%13 = alloca [6 x i8]
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%17 = bitcast [6 x i8*]* %11 to i8*
%18 = bitcast i8* %17 to [6 x i8*]*
%19 = getelementptr inbounds [6 x i8*], [6 x i8*]* %18, i32 0, i32 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8** %19
%20 = getelementptr inbounds [6 x i8*], [6 x i8*]* %18, i32 0, i32 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8** %20
%21 = getelementptr inbounds [6 x i8*], [6 x i8*]* %18, i32 0, i32 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8** %21
%22 = getelementptr inbounds [6 x i8*], [6 x i8*]* %18, i32 0, i32 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8** %22
%23 = getelementptr inbounds [6 x i8*], [6 x i8*]* %18, i32 0, i32 4
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8** %23
%24 = getelementptr inbounds [6 x i8*], [6 x i8*]* %18, i32 0, i32 5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i8** %24
store i32 0, i32* %8
br label %25
25: ; preds = %34, %3
%26 = load i32, i32* %8
%27 = load i32, i32* %7
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %37
29: ; preds = %25
%30 = load i8*, i8** %5
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
store i8 0, i8* %33
br label %34
34: ; preds = %29
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %25
37: ; preds = %25
%38 = call i64 @malloc(i32 10)
%39 = inttoptr i64 %38 to i8*
store i8* %39, i8** %14
%40 = call i64 @malloc(i32 10)
%41 = inttoptr i64 %40 to i8*
store i8* %41, i8** %15
store i32 10, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
br label %42
42: ; preds = %68, %37
%43 = load i32, i32* %8
%44 = icmp sle i32 %43, 15
br i1 %44, label %45, label %71
45: ; preds = %42
%46 = load i8*, i8** %14
%47 = load i32, i32* %8
%48 = call i32 @sprintf(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %47)
%49 = load i8*, i8** %6
%50 = load i8*, i8** %14
%51 = call i8* @strstr(i8* %49, i8* %50)
store i8* %51, i8** %16
%52 = load i8*, i8** %16
%53 = icmp ne i8* %52, null
br i1 %53, label %54, label %67
54: ; preds = %45
%55 = load i8*, i8** %16
%56 = load i32, i32* %10
%57 = add nsw i32 %56, 1
store i32 %57, i32* %10
%58 = sext i32 %56 to i64
%59 = getelementptr inbounds [6 x i8*], [6 x i8*]* %12, i64 0, i64 %58
store i8* %55, i8** %59
%60 = load i32, i32* %8
%61 = sub nsw i32 %60, 10
%62 = trunc i32 %61 to i8
%63 = load i32, i32* %9
%64 = add nsw i32 %63, 1
store i32 %64, i32* %9
%65 = sext i32 %63 to i64
%66 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 %65
store i8 %62, i8* %66
br label %67
67: ; preds = %54, %45
br label %68
68: ; preds = %67
%69 = load i32, i32* %8
%70 = add nsw i32 %69, 1
store i32 %70, i32* %8
br label %42
71: ; preds = %42
%72 = load i32, i32* %10
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %80
74: ; preds = %71
%75 = load i8*, i8** %14
%76 = call i32 @free(i8* %75)
%77 = load i8*, i8** %15
%78 = call i32 @free(i8* %77)
%79 = load i8*, i8** %5
store i8* %79, i8** %4
br label %167
80: ; preds = %71
%81 = load i32, i32* %10
%82 = icmp slt i32 %81, 6
br i1 %82, label %83, label %93
83: ; preds = %80
%84 = load i32, i32* %10
%85 = sub nsw i32 %84, 1
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [6 x i8*], [6 x i8*]* %12, i64 0, i64 %86
%88 = load i8*, i8** %87
%89 = getelementptr inbounds i8, i8* %88, i64 3
%90 = load i32, i32* %10
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [6 x i8*], [6 x i8*]* %12, i64 0, i64 %91
store i8* %89, i8** %92
br label %93
93: ; preds = %83, %80
%94 = load i8*, i8** %5
%95 = load i8*, i8** %6
%96 = getelementptr inbounds [6 x i8*], [6 x i8*]* %12, i64 0, i64 0
%97 = load i8*, i8** %96
%98 = load i8*, i8** %6
%99 = ptrtoint i8* %97 to i64
%100 = ptrtoint i8* %98 to i64
%101 = sub i64 %99, %100
%102 = trunc i64 %101 to i32
%103 = call i32 @strncpy(i8* %94, i8* %95, i32 %102)
store i32 0, i32* %8
br label %104
104: ; preds = %142, %93
%105 = load i32, i32* %8
%106 = load i32, i32* %10
%107 = icmp slt i32 %105, %106
br i1 %107, label %108, label %145
108: ; preds = %104
%109 = load i32, i32* %8
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds [6 x i8*], [6 x i8*]* %12, i64 0, i64 %110
%112 = load i8*, i8** %111
%113 = getelementptr inbounds i8, i8* %112, i64 3
store i8* %113, i8** %16
%114 = load i8*, i8** %5
%115 = load i32, i32* %8
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 %116
%118 = load i8, i8* %117
%119 = zext i8 %118 to i64
%120 = getelementptr inbounds [6 x i8*], [6 x i8*]* %11, i64 0, i64 %119
%121 = load i8*, i8** %120
%122 = call i32 @strcat(i8* %114, i8* %121)
br label %123
123: ; preds = %131, %108
%124 = load i8*, i8** %16
%125 = load i32, i32* %8
%126 = add nsw i32 %125, 1
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [6 x i8*], [6 x i8*]* %12, i64 0, i64 %127
%129 = load i8*, i8** %128
%130 = icmp ult i8* %124, %129
br i1 %130, label %131, label %141
131: ; preds = %123
%132 = load i8*, i8** %15
%133 = load i8*, i8** %16
%134 = getelementptr inbounds i8, i8* %133, i32 1
store i8* %134, i8** %16
%135 = load i8, i8* %133
%136 = sext i8 %135 to i32
%137 = call i32 @sprintf(i8* %132, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %136)
%138 = load i8*, i8** %5
%139 = load i8*, i8** %15
%140 = call i32 @strcat(i8* %138, i8* %139)
br label %123
141: ; preds = %123
br label %142
142: ; preds = %141
%143 = load i32, i32* %8
%144 = add nsw i32 %143, 1
store i32 %144, i32* %8
br label %104
145: ; preds = %104
br label %146
146: ; preds = %151, %145
%147 = load i8*, i8** %16
%148 = load i8, i8* %147
%149 = sext i8 %148 to i32
%150 = icmp ne i32 %149, 0
br i1 %150, label %151, label %161
151: ; preds = %146
%152 = load i8*, i8** %15
%153 = load i8*, i8** %16
%154 = getelementptr inbounds i8, i8* %153, i32 1
store i8* %154, i8** %16
%155 = load i8, i8* %153
%156 = sext i8 %155 to i32
%157 = call i32 @sprintf(i8* %152, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %156)
%158 = load i8*, i8** %5
%159 = load i8*, i8** %15
%160 = call i32 @strcat(i8* %158, i8* %159)
br label %146
161: ; preds = %146
%162 = load i8*, i8** %14
%163 = call i32 @free(i8* %162)
%164 = load i8*, i8** %15
%165 = call i32 @free(i8* %164)
%166 = load i8*, i8** %5
store i8* %166, i8** %4
br label %167
167: ; preds = %161, %74
%168 = load i8*, i8** %4
ret i8* %168
}

LLVM IR (-O2):
@.str = [3 x i8] c"sl\00"
@.str.1 = [3 x i8] c"fp\00"
@.str.2 = [3 x i8] c"ip\00"
@.str.3 = [3 x i8] c"sp\00"
@.str.4 = [3 x i8] c"lr\00"
@.str.5 = [3 x i8] c"pc\00"
@.str.6 = [4 x i8] c"r%d\00"
define i8* @rename_pop_registers(i8* returned %0, i8* %1, i32 %2) {
%4 = alloca [6 x i8*]
%5 = alloca [6 x i8*]
%6 = alloca [6 x i8]
%7 = bitcast [6 x i8*]* %4 to i8*
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 4
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %13
%14 = bitcast [6 x i8*]* %5 to i8*
%15 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%16 = icmp sgt i32 %2, 0
br i1 %16, label %17, label %19
17: ; preds = %3
%18 = zext i32 %2 to i64
br label %19
19: ; preds = %17, %3
%20 = tail call i64 @malloc(i32 10)
%21 = inttoptr i64 %20 to i8*
%22 = tail call i64 @malloc(i32 10)
%23 = tail call i32 @sprintf(i8* dereferenceable(1) %21, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 10)
%24 = tail call i8* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) %21)
%25 = icmp eq i8* %24, null
br i1 %25, label %28, label %26
26: ; preds = %19
%27 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 0
store i8* %24, i8** %27
store i8 0, i8* %15
br label %28
28: ; preds = %19, %26
%29 = phi i32 [ 1, %26 ], [ 0, %19 ]
%30 = tail call i32 @sprintf(i8* dereferenceable(1) %21, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 11)
%31 = tail call i8* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) %21)
%32 = icmp eq i8* %31, null
br i1 %32, label %38, label %33
33: ; preds = %28
%34 = add nuw nsw i32 %29, 1
%35 = zext i32 %29 to i64
%36 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 %35
store i8* %31, i8** %36
%37 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 %35
store i8 1, i8* %37
br label %38
38: ; preds = %33, %28
%39 = phi i32 [ %34, %33 ], [ %29, %28 ]
%40 = tail call i32 @sprintf(i8* dereferenceable(1) %21, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 12)
%41 = tail call i8* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) %21)
%42 = icmp eq i8* %41, null
br i1 %42, label %48, label %43
43: ; preds = %38
%44 = add nuw nsw i32 %39, 1
%45 = zext i32 %39 to i64
%46 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 %45
store i8* %41, i8** %46
%47 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 %45
store i8 2, i8* %47
br label %48
48: ; preds = %43, %38
%49 = phi i32 [ %44, %43 ], [ %39, %38 ]
%50 = tail call i32 @sprintf(i8* dereferenceable(1) %21, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 13)
%51 = tail call i8* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) %21)
%52 = icmp eq i8* %51, null
br i1 %52, label %58, label %53
53: ; preds = %48
%54 = add nuw nsw i32 %49, 1
%55 = zext i32 %49 to i64
%56 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 %55
store i8* %51, i8** %56
%57 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 %55
store i8 3, i8* %57
br label %58
58: ; preds = %53, %48
%59 = phi i32 [ %54, %53 ], [ %49, %48 ]
%60 = tail call i32 @sprintf(i8* dereferenceable(1) %21, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 14)
%61 = tail call i8* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) %21)
%62 = icmp eq i8* %61, null
br i1 %62, label %68, label %63
63: ; preds = %58
%64 = add nuw nsw i32 %59, 1
%65 = zext i32 %59 to i64
%66 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 %65
store i8* %61, i8** %66
%67 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 %65
store i8 4, i8* %67
br label %68
68: ; preds = %63, %58
%69 = phi i32 [ %64, %63 ], [ %59, %58 ]
%70 = tail call i32 @sprintf(i8* dereferenceable(1) %21, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 15)
%71 = tail call i8* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) %21)
%72 = icmp eq i8* %71, null
br i1 %72, label %73, label %76
73: ; preds = %68
%74 = inttoptr i64 %22 to i8*
%75 = icmp eq i32 %69, 0
br i1 %75, label %145, label %83
76: ; preds = %68
%77 = add nuw nsw i32 %69, 1
%78 = zext i32 %69 to i64
%79 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 %78
store i8* %71, i8** %79
%80 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 %78
store i8 5, i8* %80
%81 = inttoptr i64 %22 to i8*
%82 = icmp ult i32 %69, 5
br i1 %82, label %83, label %93
83: ; preds = %73, %76
%84 = phi i32 [ %77, %76 ], [ %69, %73 ]
%85 = phi i8* [ %81, %76 ], [ %74, %73 ]
%86 = add nsw i32 %84, -1
%87 = zext i32 %86 to i64
%88 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 %87
%89 = load i8*, i8** %88
%90 = getelementptr inbounds i8, i8* %89, i64 3
%91 = zext i32 %84 to i64
%92 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 %91
store i8* %90, i8** %92
br label %93
93: ; preds = %76, %83
%94 = phi i32 [ %84, %83 ], [ 6, %76 ]
%95 = phi i8* [ %85, %83 ], [ %81, %76 ]
%96 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 0
%97 = load i8*, i8** %96
%98 = ptrtoint i8* %97 to i64
%99 = ptrtoint i8* %1 to i64
%100 = sub i64 %98, %99
%101 = trunc i64 %100 to i32
%102 = tail call i32 @strncpy(i8* %0, i8* %1, i32 %101)
%103 = getelementptr i8, i8* %95, i64 1
%104 = zext i32 %94 to i64
br label %113
105: ; preds = %132, %113
%106 = phi i8* [ %116, %113 ], [ %131, %132 ]
%107 = icmp eq i64 %123, %104
br i1 %107, label %108, label %113
108: ; preds = %105
%109 = load i8, i8* %106
%110 = icmp eq i8 %109, 0
br i1 %110, label %145, label %111
111: ; preds = %108
%112 = getelementptr i8, i8* %95, i64 1
br label %138
113: ; preds = %93, %105
%114 = phi i8* [ %97, %93 ], [ %125, %105 ]
%115 = phi i64 [ 0, %93 ], [ %123, %105 ]
%116 = getelementptr inbounds i8, i8* %114, i64 3
%117 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 %115
%118 = load i8, i8* %117
%119 = zext i8 %118 to i64
%120 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 %119
%121 = load i8*, i8** %120
%122 = tail call i32 @strcat(i8* %0, i8* %121)
%123 = add nuw nsw i64 %115, 1
%124 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 %123
%125 = load i8*, i8** %124
%126 = icmp ult i8* %116, %125
br i1 %126, label %127, label %105
127: ; preds = %113
%128 = ptrtoint i8* %125 to i64
%129 = ptrtoint i8* %114 to i64
%130 = sub i64 %128, %129
%131 = getelementptr i8, i8* %114, i64 %130
br label %132
132: ; preds = %127, %132
%133 = phi i8* [ %134, %132 ], [ %116, %127 ]
%134 = getelementptr inbounds i8, i8* %133, i64 1
%135 = load i8, i8* %133
store i8 %135, i8* %95
store i8 0, i8* %103
%136 = tail call i32 @strcat(i8* %0, i8* %95)
%137 = icmp eq i8* %134, %131
br i1 %137, label %105, label %132
138: ; preds = %111, %138
%139 = phi i8 [ %109, %111 ], [ %143, %138 ]
%140 = phi i8* [ %106, %111 ], [ %141, %138 ]
%141 = getelementptr inbounds i8, i8* %140, i64 1
store i8 %139, i8* %95
store i8 0, i8* %112
%142 = tail call i32 @strcat(i8* %0, i8* %95)
%143 = load i8, i8* %141
%144 = icmp eq i8 %143, 0
br i1 %144, label %145, label %138
145: ; preds = %138, %108, %73
%146 = phi i8* [ %74, %73 ], [ %95, %108 ], [ %95, %138 ]
%147 = tail call i32 @free(i8* %21)
%148 = tail call i32 @free(i8* %146)
ret i8* %0
}