#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 */
char *memchr(char *, char, size_t);
void fixxref(char *line, size_t *len) {
  char *loc;
  char *pline = &line[4];
  size_t plen = *len - 4;
  if (*len < 4)
    return;
  if (line[1] == 'X' && line[2] == 'r') {
    if ((loc = memchr(pline, ' ', plen)) != NULL) {
      *loc++ = '(';
      loc++;
      *loc++ = ')';
      *len = loc - line;
    }
  }
}


x86 assembly (clang, -O0):
<fixxref>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
sub    $0x4,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x4,(%rax)
jae    114e <fixxref+0x3e>
jmp    11d7 <fixxref+0xc7>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x58,%eax
jne    11d7 <fixxref+0xc7>
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x72,%eax
jne    11d7 <fixxref+0xc7>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x20,%esi
call   1030 <memchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11d2 <fixxref+0xc2>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x28,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x29,(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
sub    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    11d7 <fixxref+0xc7>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fixxref>:
push   %r14
push   %rbx
push   %rax
mov    (%rsi),%rdx
sub    $0x4,%rdx
jb     1154 <fixxref+0x44>
mov    %rdi,%r14
cmpb   $0x58,0x1(%rdi)
jne    1154 <fixxref+0x44>
cmpb   $0x72,0x2(%r14)
jne    1154 <fixxref+0x44>
mov    %rsi,%rbx
lea    0x4(%r14),%rdi
mov    $0x20,%esi
call   1030 <memchr@plt>
test   %rax,%rax
je     1154 <fixxref+0x44>
movb   $0x28,(%rax)
movb   $0x29,0x2(%rax)
sub    %r14,%rax
add    $0x3,%rax
mov    %rax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @fixxref(i8* %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i64*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %3
store i64* %1, i64** %4
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 4
store i8* %9, i8** %6
%10 = load i64*, i64** %4
%11 = load i64, i64* %10
%12 = sub i64 %11, 4
store i64 %12, i64* %7
%13 = load i64*, i64** %4
%14 = load i64, i64* %13
%15 = icmp ult i64 %14, 4
br i1 %15, label %16, label %17
16: ; preds = %2
br label %48
17: ; preds = %2
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 88
br i1 %22, label %23, label %48
23: ; preds = %17
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i64 2
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 114
br i1 %28, label %29, label %48
29: ; preds = %23
%30 = load i8*, i8** %6
%31 = load i64, i64* %7
%32 = call i8* @memchr(i8* %30, i8 signext 32, i64 %31)
store i8* %32, i8** %5
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %47
34: ; preds = %29
%35 = load i8*, i8** %5
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %5
store i8 40, i8* %35
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %5
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %5
store i8 41, i8* %39
%41 = load i8*, i8** %5
%42 = load i8*, i8** %3
%43 = ptrtoint i8* %41 to i64
%44 = ptrtoint i8* %42 to i64
%45 = sub i64 %43, %44
%46 = load i64*, i64** %4
store i64 %45, i64* %46
br label %47
47: ; preds = %34, %29
br label %48
48: ; preds = %16, %47, %23, %17
ret void
}

LLVM IR (-O2):
define void @fixxref(i8* %0, i64* nocapture %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 4
%4 = load i64, i64* %1
%5 = add i64 %4, -4
%6 = icmp ult i64 %4, 4
br i1 %6, label %24, label %7
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 88
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %0, i64 2
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 114
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = tail call i8* @memchr(i8* %3, i8 signext 32, i64 %5)
%17 = icmp eq i8* %16, null
br i1 %17, label %24, label %18
18: ; preds = %15
store i8 40, i8* %16
%19 = getelementptr inbounds i8, i8* %16, i64 2
%20 = getelementptr inbounds i8, i8* %16, i64 3
store i8 41, i8* %19
%21 = ptrtoint i8* %20 to i64
%22 = ptrtoint i8* %0 to i64
%23 = sub i64 %21, %22
store i64 %23, i64* %1
br label %24
24: ; preds = %7, %11, %18, %15, %2
ret void
}