#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*/ character_exists(char *, char);
char *search_replace_string(char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *element_carrot_replace(char *data) {
  static char replace[2048];
  if (!character_exists(data, '^'))
    return data;
  strcpy(replace, data);
  return search_replace_string(replace, "^", "---");
}


x86 assembly (clang, -O0):
<element_carrot_replace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x5e,%esi
call   1050 <character_exists@plt>
cmp    $0x0,%eax
jne    1160 <element_carrot_replace+0x30>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    118e <element_carrot_replace+0x5e>
mov    -0x10(%rbp),%rsi
lea    0x2ee5(%rip),%rdi
call   1030 <strcpy@plt>
lea    0x2ed9(%rip),%rdi
lea    0xe82(%rip),%rsi
lea    0xe7d(%rip),%rdx
call   1040 <search_replace_string@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<element_carrot_replace>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x5e,%esi
call   1050 <character_exists@plt>
test   %eax,%eax
je     1174 <element_carrot_replace+0x44>
lea    0x2f04(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xea2(%rip),%rsi
lea    0xe9d(%rip),%rdx
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <search_replace_string@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@element_carrot_replace.replace = internal global [2048 x i8] zeroinitializer
@.str = [2 x i8] c"^\00"
@.str.1 = [4 x i8] c"---\00"
define i8* @element_carrot_replace(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @character_exists(i8* %4, i8 signext 94)
%6 = icmp ne i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = load i8*, i8** %3
store i8* %8, i8** %2
br label %13
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @strcpy(i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @element_carrot_replace.replace, i64 0, i64 0), i8* %10)
%12 = call i8* @search_replace_string(i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @element_carrot_replace.replace, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i8* %12, i8** %2
br label %13
13: ; preds = %9, %7
%14 = load i8*, i8** %2
ret i8* %14
}

LLVM IR (-O2):
@element_carrot_replace.replace = internal global [2048 x i8] zeroinitializer
@.str = [2 x i8] c"^\00"
@.str.1 = [4 x i8] c"---\00"
define i8* @element_carrot_replace(i8* %0) {
%2 = tail call i32 @character_exists(i8* %0, i8 signext 94)
%3 = icmp eq i32 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 @strcpy(i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @element_carrot_replace.replace, i64 0, i64 0), i8* %0)
%6 = tail call i8* @search_replace_string(i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @element_carrot_replace.replace, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %1, %4
%8 = phi i8* [ %6, %4 ], [ %0, %1 ]
ret i8* %8
}