#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 *pipe2string(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
void process_get_executable(char **executable, char *process_name,
                            char *application_name) {
  char sys_string[1024];
  char where[256];
  sprintf(where, "process = '%s'", process_name);
  sprintf(sys_string,
          "get_folder_data	application=%s		"
          "			select=command_line	"
          "			folder=process		"
          "			where=\"%s\"		",
          application_name, where);
  *executable = pipe2string(sys_string);
}


x86 assembly (clang, -O0):
<process_get_executable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x520,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x520(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeb7(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x520(%rbp),%rcx
lea    0xea6(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1030 <pipe2string@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x520,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_get_executable>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x508,%rsp
mov    %rdx,%rbx
mov    %rsi,%rdx
mov    %rdi,%r14
lea    0xec2(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <sprintf@plt>
lea    0xebd(%rip),%rsi
lea    0x100(%rsp),%r12
mov    %r12,%rdi
mov    %rbx,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %r12,%rdi
call   1030 <pipe2string@plt>
mov    %rax,(%r14)
add    $0x508,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"process = '%s'\00"
@.str.1 = [90 x i8] c"get_folder_data\09application=%s\09\09\09\09\09select=command_line\09\09\09\09folder=process\09\09\09\09\09where=\22%s\22\09\09\00"
define void @process_get_executable(i8** %0, i8* %1, i8* %2) {
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [1024 x i8]
%8 = alloca [256 x i8]
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%10 = load i8*, i8** %5
%11 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%13 = load i8*, i8** %6
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%15 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %12, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* %14)
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%17 = call i8* @pipe2string(i8* %16)
%18 = load i8**, i8*** %4
store i8* %17, i8** %18
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"process = '%s'\00"
@.str.1 = [90 x i8] c"get_folder_data\09application=%s\09\09\09\09\09select=command_line\09\09\09\09folder=process\09\09\09\09\09where=\22%s\22\09\09\00"
define void @process_get_executable(i8** nocapture writeonly %0, i8* %1, i8* %2) {
%4 = alloca [1024 x i8]
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%8 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %1)
%9 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([90 x i8], [90 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %7)
%10 = call i8* @pipe2string(i8* %6)
store i8* %10, i8** %0
ret void
}