#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*/ gets(char *);
int /*<<< orphan*/ hideit(char *, char *);
int /*<<< orphan*/ memmove(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strlen(char *);
char *strstr(char *, char *);
main() {
  char s1[100];
  char s2[100];
  char hide[100];
  char *ptr;
  puts("enter s1");
  gets(s1);
  puts("enter s2");
  gets(s2);
  hideit(hide, s2);
  ptr = s1;
  while (ptr = strstr(ptr, s2)) {
    memmove(ptr, hide, strlen(hide));
    ptr++;
  }
  printf("%s\n", s1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
lea    -0x70(%rbp),%rdi
call   1070 <gets@plt>
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
lea    -0xe0(%rbp),%rdi
call   1070 <gets@plt>
lea    -0x150(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1040 <hideit@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x158(%rbp)
mov    -0x158(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1090 <strstr@plt>
mov    %rax,-0x158(%rbp)
cmp    $0x0,%rax
je     1245 <main+0xd5>
mov    -0x158(%rbp),%rax
mov    %rax,-0x168(%rbp)
lea    -0x150(%rbp),%rax
mov    %rax,-0x160(%rbp)
lea    -0x150(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x168(%rbp),%rdi
mov    -0x160(%rbp),%rsi
mov    %eax,%edx
call   1080 <memmove@plt>
mov    -0x158(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x158(%rbp)
jmp    11cd <main+0x5d>
lea    -0x70(%rbp),%rsi
lea    0xdc2(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x150,%rsp
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe0(%rsp),%r14
mov    %r14,%rdi
call   1070 <gets@plt>
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <gets@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1040 <hideit@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     120c <main+0x9c>
mov    %rax,%rbx
mov    %rsp,%r14
lea    0x70(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1080 <memmove@plt>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11e0 <main+0x70>
lea    0xdff(%rip),%rdi
lea    0xe0(%rsp),%rsi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x150,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"enter s1\00"
@.str.1 = [9 x i8] c"enter s2\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca i8*
store i32 0, i32* %1
%6 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%8 = call i32 @gets(i8* %7)
%9 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%14 = call i32 @hideit(i8* %12, i8* %13)
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
store i8* %15, i8** %5
br label %16
16: ; preds = %21, %0
%17 = load i8*, i8** %5
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%19 = call i8* @strstr(i8* %17, i8* %18)
store i8* %19, i8** %5
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %29
21: ; preds = %16
%22 = load i8*, i8** %5
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
%26 = call i32 @memmove(i8* %22, i8* %23, i32 %25)
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %5
br label %16
29: ; preds = %16
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str = [9 x i8] c"enter s1\00"
@.str.1 = [9 x i8] c"enter s2\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @gets(i8* %5)
%11 = call i32 @hideit(i8* %6, i8* %5)
%12 = call i8* @strstr(i8* dereferenceable(1) %4, i8* %5)
%13 = icmp eq i8* %12, null
br i1 %13, label %21, label %14
14: ; preds = %0, %14
%15 = phi i8* [ %19, %14 ], [ %12, %0 ]
%16 = call i32 @strlen(i8* %6)
%17 = call i32 @memmove(i8* %15, i8* %6, i32 %16)
%18 = getelementptr inbounds i8, i8* %15, i64 1
%19 = call i8* @strstr(i8* dereferenceable(1) %18, i8* %5)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %14
21: ; preds = %14, %0
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
ret i32 0
}