#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*/ strcpy(char *, char *);
scalar_t__ tolower(char);
void replaceCharacter(char *str, char car, char car2, char *strString) {
  int i;
  strcpy(strString, "");
  i = 0;
  while (*str != '\0') {
    if (tolower(*str) != tolower(car)) {
      strString[i++] = *str;
    } else {
      strString[i++] = car2;
    }
    str++;
  }
  strString[i] = '\0';
}


x86 assembly (clang, -O0):
<replaceCharacter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %rdi,-0x8(%rbp)
mov    %dl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeba(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d4 <replaceCharacter+0xb4>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %rax,-0x28(%rbp)
movsbl -0x9(%rbp),%edi
call   1040 <tolower@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     11ab <replaceCharacter+0x8b>
mov    -0x8(%rbp),%rax
mov    (%rax),%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11c3 <replaceCharacter+0xa3>
mov    -0xa(%rbp),%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1152 <replaceCharacter+0x32>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<replaceCharacter>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%r15d
mov    %esi,%ebp
mov    %rdi,%r13
lea    0xec3(%rip),%rsi
mov    %rcx,%rdi
call   1030 <strcpy@plt>
mov    0x0(%r13),%al
test   %al,%al
je     1199 <replaceCharacter+0x79>
xor    %ebx,%ebx
movsbl %bpl,%r12d
jmp    1172 <replaceCharacter+0x52>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %cl,(%r14,%rbx,1)
movzbl 0x1(%r13,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
je     1195 <replaceCharacter+0x75>
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %rax,%rbp
mov    %r12d,%edi
call   1040 <tolower@plt>
mov    %r15d,%ecx
cmp    %rax,%rbp
je     1160 <replaceCharacter+0x40>
movzbl 0x0(%r13,%rbx,1),%ecx
jmp    1160 <replaceCharacter+0x40>
mov    %ebx,%eax
jmp    119b <replaceCharacter+0x7b>
xor    %eax,%eax
movb   $0x0,(%r14,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define void @replaceCharacter(i8* %0, i8 signext %1, i8 signext %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i8 %1, i8* %6
store i8 %2, i8* %7
store i8* %3, i8** %8
%10 = load i8*, i8** %8
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
br label %12
12: ; preds = %39, %4
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %42
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
%20 = call i64 @tolower(i8 signext %19)
%21 = load i8, i8* %6
%22 = call i64 @tolower(i8 signext %21)
%23 = icmp ne i64 %20, %22
br i1 %23, label %24, label %32
24: ; preds = %17
%25 = load i8*, i8** %5
%26 = load i8, i8* %25
%27 = load i8*, i8** %8
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
store i32 %29, i32* %9
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
store i8 %26, i8* %31
br label %39
32: ; preds = %17
%33 = load i8, i8* %7
%34 = load i8*, i8** %8
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds i8, i8* %34, i64 %37
store i8 %33, i8* %38
br label %39
39: ; preds = %32, %24
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %5
br label %12
42: ; preds = %12
%43 = load i8*, i8** %8
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
store i8 0, i8* %46
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define void @replaceCharacter(i8* nocapture %0, i8 signext %1, i8 signext %2, i8* %3) {
%5 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 0
br i1 %7, label %26, label %8
8: ; preds = %4, %17
%9 = phi i64 [ %20, %17 ], [ 0, %4 ]
%10 = phi i8 [ %22, %17 ], [ %6, %4 ]
%11 = phi i8* [ %21, %17 ], [ %0, %4 ]
%12 = tail call i64 @tolower(i8 signext %10)
%13 = tail call i64 @tolower(i8 signext %1)
%14 = icmp eq i64 %12, %13
br i1 %14, label %17, label %15
15: ; preds = %8
%16 = load i8, i8* %11
br label %17
17: ; preds = %8, %15
%18 = phi i8 [ %16, %15 ], [ %2, %8 ]
%19 = getelementptr inbounds i8, i8* %3, i64 %9
store i8 %18, i8* %19
%20 = add nuw i64 %9, 1
%21 = getelementptr inbounds i8, i8* %11, i64 1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %8
24: ; preds = %17
%25 = and i64 %20, 4294967295
br label %26
26: ; preds = %24, %4
%27 = phi i64 [ 0, %4 ], [ %25, %24 ]
%28 = getelementptr inbounds i8, i8* %3, i64 %27
store i8 0, i8* %28
ret void
}