#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*/ printf(char *, char *);
int main(void) {
  bool replaceString(char source[], const char s1[], const char s2[]);
  bool stillFound;
  char text1[] = "the wrong person";
  char text2[] = "e";
  char text3[] = "";
  do
    stillFound = replaceString(text1, text2, text3);
  while (stillFound == true);
  printf("%s", text1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%al
mov    %al,-0x10(%rbp)
mov    0xeac(%rip),%ax
mov    %ax,-0x22(%rbp)
lea    -0x23(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
lea    -0x20(%rbp),%rdi
lea    -0x22(%rbp),%rsi
lea    -0x23(%rbp),%rdx
call   1030 <replaceString@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     1179 <main+0x49>
lea    -0x20(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movb   $0x0,0x20(%rsp)
movw   $0x65,0xe(%rsp)
movb   $0x0,0xd(%rsp)
lea    0x10(%rsp),%r14
lea    0xe(%rsp),%r15
lea    0xd(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <replaceString@plt>
cmp    $0x1,%eax
je     1160 <main+0x40>
lea    0xe97(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.text1 = [17 x i8] c"the wrong person\00"
@__const.main.text2 = [2 x i8] c"e\00"
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [17 x i8]
%4 = alloca [2 x i8]
%5 = alloca [1 x i8]
store i32 0, i32* %1
%6 = bitcast [17 x i8]* %3 to i8*
%7 = bitcast [2 x i8]* %4 to i8*
%8 = bitcast [1 x i8]* %5 to i8*
br label %9
9: ; preds = %14, %0
%10 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
%13 = call i32 @replaceString(i8* %10, i8* %11, i8* %12)
store i32 %13, i32* %2
br label %14
14: ; preds = %9
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 1
br i1 %16, label %9, label %17
17: ; preds = %14
%18 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %18)
ret i32 0
}

LLVM IR (-O2):
@__const.main.text1 = [17 x i8] c"the wrong person\00"
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [17 x i8]
%2 = alloca i16
%3 = alloca [1 x i8]
%4 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 0
%5 = bitcast i16* %2 to i8*
store i16 101, i16* %2
%6 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
store i8 0, i8* %6
br label %7
7: ; preds = %7, %0
%8 = call i32 @replaceString(i8* %4, i8* %5, i8* %6)
%9 = icmp eq i32 %8, 1
br i1 %9, label %7, label %10
10: ; preds = %7
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
ret i32 0
}