#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*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strcpy_prool(char *, char *);
char *strstr(char *, char *);
void filter_string(char str[]) {
  char *set;
  if (set = strstr(str, "TYPE=STRI65")) {
    printf("filter_string `%s`\n", str);
    strcpy(set, "TYPE=S6");
    strcpy_prool(set + 7, set + 11);
    printf("->`%s'\n", str);
  }
}


x86 assembly (clang, -O0):
<filter_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11af <filter_string+0x6f>
mov    -0x8(%rbp),%rsi
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
add    $0x7,%rdi
mov    -0x10(%rbp),%rsi
add    $0xb,%rsi
call   1050 <strcpy_prool@plt>
mov    -0x8(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_string>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xeb2(%rip),%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     119f <filter_string+0x5f>
mov    %rax,%rbx
lea    0xeaa(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0x7(%rbx),%rdi
add    $0xb,%rbx
mov    %rbx,%rsi
call   1050 <strcpy_prool@plt>
lea    0xe98(%rip),%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"TYPE=STRI65\00"
@.str.1 = [20 x i8] c"filter_string `%s`\0A\00"
@.str.2 = [8 x i8] c"TYPE=S6\00"
@.str.3 = [8 x i8] c"->`%s'\0A\00"
define void @filter_string(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @strstr(i8* %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %19
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %3
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 7
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 11
%16 = call i32 @strcpy_prool(i8* %13, i8* %15)
%17 = load i8*, i8** %2
%18 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %7, %1
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"TYPE=STRI65\00"
@.str.1 = [20 x i8] c"filter_string `%s`\0A\00"
@.str.2 = [8 x i8] c"TYPE=S6\00"
@.str.3 = [8 x i8] c"->`%s'\0A\00"
define void @filter_string(i8* %0) {
%2 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%7 = getelementptr inbounds i8, i8* %2, i64 7
%8 = getelementptr inbounds i8, i8* %2, i64 11
%9 = tail call i32 @strcpy_prool(i8* %7, i8* %8)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %11
11: ; preds = %4, %1
ret void
}