#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 *str_replace(char *, char *, char *);
char *reformat_error_msg(const char *msg) {
  char *ret = str_replace((char *)msg, "unexpected", "Unexpected");
  ret = str_replace(ret, "syntax error, ", "");
  ret = str_replace(ret, "\"", "");
  ret = str_replace(ret, ", expecting ", "\n              | Expected ");
  return ret;
}


x86 assembly (clang, -O0):
<reformat_error_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed9(%rip),%rsi
lea    0xedd(%rip),%rdx
call   1030 <str_replace@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed4(%rip),%rsi
lea    0xedb(%rip),%rdx
call   1030 <str_replace@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec8(%rip),%rsi
lea    0xec0(%rip),%rdx
call   1030 <str_replace@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeaf(%rip),%rsi
lea    0xeb5(%rip),%rdx
call   1030 <str_replace@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reformat_error_msg>:
push   %rbx
lea    0xee8(%rip),%rsi
lea    0xeec(%rip),%rdx
call   1030 <str_replace@plt>
lea    0xeeb(%rip),%rsi
lea    0xef2(%rip),%rbx
mov    %rax,%rdi
mov    %rbx,%rdx
call   1030 <str_replace@plt>
lea    0xee1(%rip),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
call   1030 <str_replace@plt>
lea    0xed1(%rip),%rsi
lea    0xed7(%rip),%rdx
mov    %rax,%rdi
pop    %rbx
jmp    1030 <str_replace@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"unexpected\00"
@.str.1 = [11 x i8] c"Unexpected\00"
@.str.2 = [15 x i8] c"syntax error, \00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [13 x i8] c", expecting \00"
@.str.6 = [27 x i8] c"\0A | Expected \00"
define i8* @reformat_error_msg(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @str_replace(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @str_replace(i8* %6, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = call i8* @str_replace(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = call i8* @str_replace(i8* %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
store i8* %11, i8** %3
%12 = load i8*, i8** %3
ret i8* %12
}

LLVM IR (-O2):
@.str = [11 x i8] c"unexpected\00"
@.str.1 = [11 x i8] c"Unexpected\00"
@.str.2 = [15 x i8] c"syntax error, \00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [13 x i8] c", expecting \00"
@.str.6 = [27 x i8] c"\0A | Expected \00"
define i8* @reformat_error_msg(i8* %0) {
%2 = tail call i8* @str_replace(i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i8* @str_replace(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%4 = tail call i8* @str_replace(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i8* @str_replace(i8* %4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
ret i8* %5
}