#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*/ delete_string(char *);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
char *replace(char *, char *, char *);
int main(int argc, char **argv) {
  char userbuffer[2048] = {0};
  puts("Please, enter some string:\n");
  gets(userbuffer);
  char *replaced = replace(userbuffer, "=", "****");
  printf("Replaced string: %s\n", replaced);
  delete_string(replaced);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1060 <memset@plt>
lea    0xe6d(%rip),%rdi
call   1030 <puts@plt>
lea    -0x810(%rbp),%rdi
call   1070 <gets@plt>
lea    -0x810(%rbp),%rdi
lea    0xe6a(%rip),%rsi
lea    0xe65(%rip),%rdx
call   1080 <replace@plt>
mov    %rax,-0x818(%rbp)
mov    -0x818(%rbp),%rsi
lea    0xe50(%rip),%rdi
call   1050 <printf@plt>
mov    -0x818(%rbp),%rdi
call   1040 <delete_string@plt>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x800,%rsp
mov    %rsp,%rbx
mov    $0x800,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1070 <gets@plt>
lea    0xe87(%rip),%rsi
lea    0xe82(%rip),%rdx
mov    %rbx,%rdi
call   1080 <replace@plt>
mov    %rax,%rbx
lea    0xe75(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <delete_string@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Please, enter some string:\0A\00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [5 x i8] c"****\00"
@.str.3 = [21 x i8] c"Replaced string: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2048 x i8]
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [2048 x i8]* %6 to i8*
%9 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%13 = call i8* @replace(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %7
%17 = call i32 @delete_string(i8* %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Please, enter some string:\0A\00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [5 x i8] c"****\00"
@.str.3 = [21 x i8] c"Replaced string: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %4)
%7 = call i8* @replace(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%9 = call i32 @delete_string(i8* %7)
ret i32 0
}