#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 *strpbrk(char *, char *);
int Change(char *chaine, char ancien, char nouveau) {
  char *ptr;
  char tmp[2];
  int result = 0;
  tmp[0] = ancien;
  tmp[1] = '\0';
  while ((ptr = strpbrk(chaine, tmp)) != NULL) {
    *ptr = nouveau;
    result = 1;
  }
  return (result);
}


x86 assembly (clang, -O0):
<Change>:
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)
movl   $0x0,-0x20(%rbp)
mov    -0x9(%rbp),%al
mov    %al,-0x1a(%rbp)
movb   $0x0,-0x19(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   1030 <strpbrk@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1168 <Change+0x58>
mov    -0xa(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
movl   $0x1,-0x20(%rbp)
jmp    1138 <Change+0x28>
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Change>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rdi,%rbx
mov    %sil,0xe(%rsp)
movb   $0x0,0xf(%rsp)
lea    0xe(%rsp),%rsi
call   1030 <strpbrk@plt>
test   %rax,%rax
je     115a <Change+0x4a>
lea    0xe(%rsp),%r14
nopl   0x0(%rax,%rax,1)
mov    %bpl,(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strpbrk@plt>
test   %rax,%rax
jne    1140 <Change+0x30>
mov    $0x1,%eax
jmp    115c <Change+0x4c>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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