#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*/ appaserver_error_starting_argv_append_file(int, char **,
                                                              char *);
char *environ_get_application_name(char *);
int /*<<< orphan*/ execute_dot_process(char *);
scalar_t__ get_line(char *, int /*<<< orphan*/);
int /*<<< orphan*/ piece(char *, char, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ search_replace_string(char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char **argv) {
  char *application;
  char input_string[1024];
  char process_string[1024];
  char replace_application[128];
  int dot_process_tag_length;
  application = environ_get_application_name(argv[0]);
  appaserver_error_starting_argv_append_file(argc, argv, application);
  dot_process_tag_length = strlen(".process=");
  sprintf(replace_application, " %s", application);
  while (get_line(input_string, stdin)) {
    if (strncmp(input_string, ".process=", dot_process_tag_length) == 0) {
      piece(process_string, '=', input_string, 1);
      search_replace_string(process_string, " application",
                            replace_application);
      execute_dot_process(process_string);
    } else {
      printf("%s\n", input_string);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <environ_get_application_name@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   10b0 <appaserver_error_starting_argv_append_file@plt>
lea    0xe20(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x8a4(%rbp)
lea    -0x8a0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe0d(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x420(%rbp),%rdi
mov    0x2dd8(%rip),%rax
mov    (%rax),%esi
call   1050 <get_line@plt>
cmp    $0x0,%rax
je     12a4 <main+0x104>
lea    -0x420(%rbp),%rdi
mov    -0x8a4(%rbp),%edx
lea    0xdcb(%rip),%rsi
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    128c <main+0xec>
lea    -0x820(%rbp),%rdi
lea    -0x420(%rbp),%rdx
mov    $0x3d,%esi
mov    $0x1,%ecx
call   10c0 <piece@plt>
lea    -0x820(%rbp),%rdi
lea    -0x8a0(%rbp),%rdx
lea    0xd98(%rip),%rsi
call   1070 <search_replace_string@plt>
lea    -0x820(%rbp),%rdi
call   1030 <execute_dot_process@plt>
jmp    129f <main+0xff>
lea    -0x420(%rbp),%rsi
lea    0xd81(%rip),%rdi
call   1080 <printf@plt>
jmp    1202 <main+0x62>
xor    %eax,%eax
add    $0x8b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x888,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    (%rsi),%rdi
call   1090 <environ_get_application_name@plt>
mov    %rax,%r14
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   10b0 <appaserver_error_starting_argv_append_file@plt>
lea    0xe2b(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
lea    0xe27(%rip),%rsi
mov    %rsp,%rdi
mov    %r14,%rdx
call   10a0 <sprintf@plt>
mov    0x2df3(%rip),%r13
mov    0x0(%r13),%esi
lea    0x80(%rsp),%rdi
call   1050 <get_line@plt>
test   %rax,%rax
je     128f <main+0xef>
lea    0xdea(%rip),%r14
lea    0x80(%rsp),%rbx
lea    0x480(%rsp),%r15
lea    0xdee(%rip),%r12
jmp    124c <main+0xac>
nop
mov    %r12,%rdi
mov    %rbx,%rsi
call   1080 <printf@plt>
mov    0x0(%r13),%esi
mov    %rbx,%rdi
call   1050 <get_line@plt>
test   %rax,%rax
je     128f <main+0xef>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1230 <main+0x90>
mov    %r15,%rdi
mov    $0x3d,%esi
mov    %rbx,%rdx
mov    $0x1,%ecx
call   10c0 <piece@plt>
mov    %r15,%rdi
lea    0xd91(%rip),%rsi
mov    %rsp,%rdx
call   1070 <search_replace_string@plt>
mov    %r15,%rdi
call   1030 <execute_dot_process@plt>
jmp    123b <main+0x9b>
xor    %eax,%eax
add    $0x888,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c".process=\00"
@.str.1 = [4 x i8] c" %s\00"
@stdin = global i32 0
@.str.2 = [13 x i8] c" application\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
%9 = alloca [128 x i8]
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i8* @environ_get_application_name(i8* %13)
store i8* %14, i8** %6
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = load i8*, i8** %6
%18 = call i32 @appaserver_error_starting_argv_append_file(i32 %15, i8** %16, i8* %17)
%19 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 %19, i32* %10
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%21 = load i8*, i8** %6
%22 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %45, %2
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%25 = load i32, i32* @stdin
%26 = call i64 @get_line(i8* %24, i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %46
28: ; preds = %23
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%30 = load i32, i32* %10
%31 = call i64 @strncmp(i8* %29, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %42
33: ; preds = %28
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%36 = call i32 @piece(i8* %34, i8 signext 61, i8* %35, i32 1)
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%38 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%39 = call i32 @search_replace_string(i8* %37, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %38)
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%41 = call i32 @execute_dot_process(i8* %40)
br label %45
42: ; preds = %28
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%44 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %42, %33
br label %23
46: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c".process=\00"
@.str.1 = [4 x i8] c" %s\00"
@stdin = global i32 0
@.str.2 = [13 x i8] c" application\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [128 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%9 = load i8*, i8** %1
%10 = tail call i8* @environ_get_application_name(i8* %9)
%11 = tail call i32 @appaserver_error_starting_argv_append_file(i32 %0, i8** %1, i8* %10)
%12 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%14 = load i32, i32* @stdin
%15 = call i64 @get_line(i8* %6, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %30, label %17
17: ; preds = %2, %26
%18 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %12)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = call i32 @piece(i8* %7, i8 signext 61, i8* %6, i32 1)
%22 = call i32 @search_replace_string(i8* %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%23 = call i32 @execute_dot_process(i8* %7)
br label %26
24: ; preds = %17
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %6)
br label %26
26: ; preds = %24, %20
%27 = load i32, i32* @stdin
%28 = call i64 @get_line(i8* %6, i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %17
30: ; preds = %26, %2
ret i32 0
}