#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 cek_tipe_file(char *);
int /*<<< orphan*/ execute_cgi(int, char *, char **, char **);
scalar_t__ malloc(int);
char **prepare_environment(char *, char *, char *, char *);
int /*<<< orphan*/ send_error(int, int, char *);
int /*<<< orphan*/ send_str(int, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void proses_script(int socket, char *method, char *pathasli, char *path,
                   char *query_string) {
  char **param;
  char **env;
  if (cek_tipe_file(pathasli) != 2) {
    send_error(socket, 404, path);
    return;
  }
  param = (char **)malloc(sizeof(char *) * 1);
  param[0] = (char *)malloc(sizeof(char) * 256);
  strcpy(param[0], pathasli);
  env = prepare_environment(method, pathasli, path, query_string);
  send_str(socket, "HTTP/1.0 200 OK\r\n");
  execute_cgi(socket, pathasli, param, env);
}


x86 assembly (clang, -O0):
<proses_script>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <cek_tipe_file@plt>
cmp    $0x2,%eax
je     11b3 <proses_script+0x43>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    $0x194,%esi
call   1070 <send_error@plt>
jmp    1221 <proses_script+0xb1>
mov    $0x8,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    $0x100,%edi
call   1080 <malloc@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1040 <prepare_environment@plt>
mov    %rax,-0x38(%rbp)
mov    -0x4(%rbp),%edi
lea    0xdf8(%rip),%rsi
call   1050 <send_str@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
call   1090 <execute_cgi@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proses_script>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r15
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %edi,%ebp
mov    %rdx,%rdi
call   1060 <cek_tipe_file@plt>
cmp    $0x2,%eax
jne    11fc <proses_script+0x8c>
mov    $0x8,%edi
call   1080 <malloc@plt>
mov    %rax,%r13
mov    $0x100,%edi
call   1080 <malloc@plt>
mov    %rax,0x0(%r13)
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1040 <prepare_environment@plt>
mov    %rax,%r14
lea    0xe29(%rip),%rsi
mov    %ebp,%edi
call   1050 <send_str@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <execute_cgi@plt>
mov    %ebp,%edi
mov    $0x194,%esi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <send_error@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"HTTP/1.0 200 OK\0D\0A\00"
define void @proses_script(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8**
%12 = alloca i8**
store i32 %0, i32* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%13 = load i8*, i8** %8
%14 = call i32 @cek_tipe_file(i8* %13)
%15 = icmp ne i32 %14, 2
br i1 %15, label %16, label %20
16: ; preds = %5
%17 = load i32, i32* %6
%18 = load i8*, i8** %9
%19 = call i32 @send_error(i32 %17, i32 404, i8* %18)
br label %44
20: ; preds = %5
%21 = call i64 @malloc(i32 8)
%22 = inttoptr i64 %21 to i8**
store i8** %22, i8*** %11
%23 = call i64 @malloc(i32 256)
%24 = inttoptr i64 %23 to i8*
%25 = load i8**, i8*** %11
%26 = getelementptr inbounds i8*, i8** %25, i64 0
store i8* %24, i8** %26
%27 = load i8**, i8*** %11
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = load i8*, i8** %8
%31 = call i32 @strcpy(i8* %29, i8* %30)
%32 = load i8*, i8** %7
%33 = load i8*, i8** %8
%34 = load i8*, i8** %9
%35 = load i8*, i8** %10
%36 = call i8** @prepare_environment(i8* %32, i8* %33, i8* %34, i8* %35)
store i8** %36, i8*** %12
%37 = load i32, i32* %6
%38 = call i32 @send_str(i32 %37, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%39 = load i32, i32* %6
%40 = load i8*, i8** %8
%41 = load i8**, i8*** %11
%42 = load i8**, i8*** %12
%43 = call i32 @execute_cgi(i32 %39, i8* %40, i8** %41, i8** %42)
br label %44
44: ; preds = %20, %16
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"HTTP/1.0 200 OK\0D\0A\00"
define void @proses_script(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = tail call i32 @cek_tipe_file(i8* %2)
%7 = icmp eq i32 %6, 2
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @send_error(i32 %0, i32 404, i8* %3)
br label %19
10: ; preds = %5
%11 = tail call i64 @malloc(i32 8)
%12 = inttoptr i64 %11 to i8**
%13 = tail call i64 @malloc(i32 256)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %12
%15 = tail call i32 @strcpy(i8* %14, i8* %2)
%16 = tail call i8** @prepare_environment(i8* %1, i8* %2, i8* %3, i8* %4)
%17 = tail call i32 @send_str(i32 %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%18 = tail call i32 @execute_cgi(i32 %0, i8* %2, i8** %12, i8** %16)
br label %19
19: ; preds = %10, %8
ret void
}