#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ build_find_string_buffer(char *, char *, char *);
scalar_t__ get_line(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sed_this_file(char *, char *, char *, char *);
void findsed(char *find_string, char *search_string, char *replace_string,
             char *testing_string, char *excludedir_string) {
  FILE *p;
  char this_file[512];
  char find_string_buffer[512];
  build_find_string_buffer(find_string_buffer, find_string, excludedir_string);
  p = popen(find_string_buffer, "r");
  while (get_line(this_file, p)) {
    printf("%s\n", this_file);
    sed_this_file(this_file, search_string, replace_string, testing_string);
  }
  pclose(p);
}


x86 assembly (clang, -O0):
<findsed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0x430(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1080 <build_find_string_buffer@plt>
lea    -0x430(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x30(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <get_line@plt>
cmp    $0x0,%rax
je     11f4 <findsed+0x94>
lea    -0x230(%rbp),%rsi
lea    0xe30(%rip),%rdi
call   1040 <printf@plt>
lea    -0x230(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1060 <sed_this_file@plt>
jmp    11aa <findsed+0x4a>
mov    -0x30(%rbp),%rdi
call   1050 <pclose@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findsed>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rsi
lea    0x200(%rsp),%rbx
mov    %rbx,%rdi
mov    %r8,%rdx
call   1080 <build_find_string_buffer@plt>
lea    0xe69(%rip),%rsi
mov    %rbx,%rdi
call   1070 <popen@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    %rax,%rsi
call   1030 <get_line@plt>
test   %rax,%rax
je     11ec <findsed+0x8c>
lea    0xe49(%rip),%r13
mov    %rsp,%rbp
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1060 <sed_this_file@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <get_line@plt>
test   %rax,%rax
jne    11c0 <findsed+0x60>
mov    %rbx,%rdi
call   1050 <pclose@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @findsed(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca [512 x i8]
%13 = alloca [512 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%15 = load i8*, i8** %6
%16 = load i8*, i8** %10
%17 = call i32 @build_find_string_buffer(i8* %14, i8* %15, i8* %16)
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %13, i64 0, i64 0
%19 = call i32* @popen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %11
br label %20
20: ; preds = %25, %5
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%22 = load i32*, i32** %11
%23 = call i64 @get_line(i8* %21, i32* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %33
25: ; preds = %20
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%29 = load i8*, i8** %7
%30 = load i8*, i8** %8
%31 = load i8*, i8** %9
%32 = call i32 @sed_this_file(i8* %28, i8* %29, i8* %30, i8* %31)
br label %20
33: ; preds = %20
%34 = load i32*, i32** %11
%35 = call i32 @pclose(i32* %34)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @findsed(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca [512 x i8]
%7 = alloca [512 x i8]
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%10 = call i32 @build_find_string_buffer(i8* %9, i8* %0, i8* %4)
%11 = call i32* @popen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = call i64 @get_line(i8* %8, i32* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %5, %14
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%16 = call i32 @sed_this_file(i8* %8, i8* %1, i8* %2, i8* %3)
%17 = call i64 @get_line(i8* %8, i32* %11)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %14
19: ; preds = %14, %5
%20 = call i32 @pclose(i32* %11)
ret void
}