#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 *strchr(char *, char);
extern void string_translate_char(char *str, char from, char to) {
  char *p = str;
  while (p != NULL && (p = strchr(p, from)) != NULL)
    *p++ = to;
}


x86 assembly (clang, -O0):
<string_translate_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %sil,%cl
mov    %rdi,-0x8(%rbp)
mov    %cl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
je     115a <string_translate_char+0x4a>
mov    -0x18(%rbp),%rdi
movsbl -0x9(%rbp),%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    116a <string_translate_char+0x5a>
jmp    1183 <string_translate_char+0x73>
mov    -0xa(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    112f <string_translate_char+0x1f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_translate_char>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     1137 <string_translate_char+0x27>
mov    %edx,%ebx
movsbl %sil,%ebp
xchg   %ax,%ax
mov    %ebp,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1137 <string_translate_char+0x27>
mov    %bl,(%rax)
add    $0x1,%rax
mov    %rax,%rdi
jmp    1120 <string_translate_char+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @string_translate_char(i8* %0, i8 signext %1, i8 signext %2) {
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8*
store i8* %0, i8** %4
store i8 %1, i8* %5
store i8 %2, i8* %6
%8 = load i8*, i8** %4
store i8* %8, i8** %7
br label %9
9: ; preds = %19, %3
%10 = load i8*, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i8*, i8** %7
%14 = load i8, i8* %5
%15 = call i8* @strchr(i8* %13, i8 signext %14)
store i8* %15, i8** %7
%16 = icmp ne i8* %15, null
br label %17
17: ; preds = %12, %9
%18 = phi i1 [ false, %9 ], [ %16, %12 ]
br i1 %18, label %19, label %23
19: ; preds = %17
%20 = load i8, i8* %6
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %7
store i8 %20, i8* %21
br label %9
23: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @string_translate_char(i8* %0, i8 signext %1, i8 signext %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %13, label %5
5: ; preds = %3
%6 = tail call i8* @strchr(i8* %0, i8 signext %1)
%7 = icmp eq i8* %6, null
br i1 %7, label %13, label %8
8: ; preds = %5, %8
%9 = phi i8* [ %11, %8 ], [ %6, %5 ]
%10 = getelementptr inbounds i8, i8* %9, i64 1
store i8 %2, i8* %9
%11 = tail call i8* @strchr(i8* %10, i8 signext %1)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %8
13: ; preds = %8, %5, %3
ret void
}