#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 */
scalar_t__ character_exists(char *, char);
int /*<<< orphan*/ format_initial_capital(char *, char *);
scalar_t__ get_line(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ piece(char *, char, char *, int);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void execute_dot_process(char *process_string) {
  char input_buffer[1024];
  char format_buffer[1024];
  char key_buffer[1024];
  FILE *input_pipe;
  input_pipe = popen(process_string, "r");
  while (get_line(input_buffer, input_pipe)) {
    if (character_exists(input_buffer, '^')) {
      piece(format_buffer, '^', input_buffer, 0);
      format_initial_capital(format_buffer, format_buffer);
      piece(key_buffer, '^', input_buffer, 1);
    } else {
      format_initial_capital(format_buffer, input_buffer);
      strcpy(key_buffer, input_buffer);
    }
    printf("<option value=\"%s\">%s\n", key_buffer, format_buffer);
  }
  pclose(input_pipe);
}


x86 assembly (clang, -O0):
<execute_dot_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1090 <popen@plt>
mov    %rax,-0xc18(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0xc18(%rbp),%rsi
call   1040 <get_line@plt>
cmp    $0x0,%rax
je     1272 <execute_dot_process+0xf2>
lea    -0x410(%rbp),%rdi
mov    $0x5e,%esi
call   1060 <character_exists@plt>
cmp    $0x0,%rax
je     122d <execute_dot_process+0xad>
lea    -0x810(%rbp),%rdi
lea    -0x410(%rbp),%rdx
mov    $0x5e,%esi
xor    %ecx,%ecx
call   10a0 <piece@plt>
lea    -0x810(%rbp),%rdi
lea    -0x810(%rbp),%rsi
call   1080 <format_initial_capital@plt>
lea    -0xc10(%rbp),%rdi
lea    -0x410(%rbp),%rdx
mov    $0x5e,%esi
mov    $0x1,%ecx
call   10a0 <piece@plt>
jmp    1253 <execute_dot_process+0xd3>
lea    -0x810(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1080 <format_initial_capital@plt>
lea    -0xc10(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xc10(%rbp),%rsi
lea    -0x810(%rbp),%rdx
lea    0xd9a(%rip),%rdi
call   1050 <printf@plt>
jmp    11a6 <execute_dot_process+0x26>
mov    -0xc18(%rbp),%rdi
call   1070 <pclose@plt>
add    $0xc20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_dot_process>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc00,%rsp
lea    0xe69(%rip),%rsi
call   1090 <popen@plt>
mov    %rax,%r14
mov    %rsp,%rdi
mov    %rax,%rsi
call   1040 <get_line@plt>
test   %rax,%rax
je     1247 <execute_dot_process+0xc7>
mov    %rsp,%rbx
lea    0x800(%rsp),%r15
lea    0x400(%rsp),%r12
lea    0xe35(%rip),%r13
jmp    1201 <execute_dot_process+0x81>
nop
mov    %rbx,%rsi
call   1080 <format_initial_capital@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <get_line@plt>
test   %rax,%rax
je     1247 <execute_dot_process+0xc7>
mov    %rbx,%rdi
mov    $0x5e,%esi
call   1060 <character_exists@plt>
mov    %r15,%rdi
test   %rax,%rax
je     11d0 <execute_dot_process+0x50>
mov    $0x5e,%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   10a0 <piece@plt>
mov    %r15,%rdi
mov    %r15,%rsi
call   1080 <format_initial_capital@plt>
mov    %r12,%rdi
mov    $0x5e,%esi
mov    %rbx,%rdx
mov    $0x1,%ecx
call   10a0 <piece@plt>
jmp    11e3 <execute_dot_process+0x63>
mov    %r14,%rdi
call   1070 <pclose@plt>
add    $0xc00,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [23 x i8] c"<option value=\22%s\22>%s\0A\00"
define void @execute_dot_process(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca i32*
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32* @popen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %6
br label %9
9: ; preds = %35, %1
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%11 = load i32*, i32** %6
%12 = call i64 @get_line(i8* %10, i32* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %39
14: ; preds = %9
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%16 = call i64 @character_exists(i8* %15, i8 signext 94)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%21 = call i32 @piece(i8* %19, i8 signext 94, i8* %20, i32 0)
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%24 = call i32 @format_initial_capital(i8* %22, i8* %23)
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%27 = call i32 @piece(i8* %25, i8 signext 94, i8* %26, i32 1)
br label %35
28: ; preds = %14
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%31 = call i32 @format_initial_capital(i8* %29, i8* %30)
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%34 = call i32 @strcpy(i8* %32, i8* %33)
br label %35
35: ; preds = %28, %18
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%38 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %36, i8* %37)
br label %9
39: ; preds = %9
%40 = load i32*, i32** %6
%41 = call i32 @pclose(i32* %40)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [23 x i8] c"<option value=\22%s\22>%s\0A\00"
define void @execute_dot_process(i8* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%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 = tail call i32* @popen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = call i64 @get_line(i8* %5, i32* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %25, label %11
11: ; preds = %1, %21
%12 = call i64 @character_exists(i8* %5, i8 signext 94)
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = call i32 @piece(i8* %6, i8 signext 94, i8* %5, i32 0)
%16 = call i32 @format_initial_capital(i8* %6, i8* %6)
%17 = call i32 @piece(i8* %7, i8 signext 94, i8* %5, i32 1)
br label %21
18: ; preds = %11
%19 = call i32 @format_initial_capital(i8* %6, i8* %5)
%20 = call i32 @strcpy(i8* %7, i8* %5)
br label %21
21: ; preds = %18, %14
%22 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* %6)
%23 = call i64 @get_line(i8* %5, i32* %8)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %11
25: ; preds = %21, %1
%26 = call i32 @pclose(i32* %8)
ret void
}