#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*/ create_info_about_client(int, int, int, int, int);
int /*<<< orphan*/ do_fork_exec(char *, int *, int *, int *, int *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ read_all_vchan_ext(char *, int);
int /*<<< orphan*/ stderr;
void handle_exec(int client_id, int len) {
  char buf[len];
  int pid, stdin_fd, stdout_fd, stderr_fd;
  read_all_vchan_ext(buf, len);
  do_fork_exec(buf, &pid, &stdin_fd, &stdout_fd, &stderr_fd);
  create_info_about_client(client_id, pid, stdin_fd, stdout_fd, stderr_fd);
  fprintf(stderr, "executed %s pid %d\n", buf, pid);
}


x86 assembly (clang, -O0):
<handle_exec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
call   1030 <read_all_vchan_ext@plt>
mov    -0x30(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
lea    -0x28(%rbp),%r8
call   1060 <do_fork_exec@plt>
mov    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
call   1050 <create_info_about_client@plt>
mov    -0x30(%rbp),%rdx
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%ecx
lea    0xe3f(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_exec>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r14d
mov    %esi,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1030 <read_all_vchan_ext@plt>
lea    -0x14(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
lea    -0x18(%rbp),%r8
mov    %rbx,%rdi
call   1060 <do_fork_exec@plt>
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    %r14d,%edi
call   1050 <create_info_about_client@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%ecx
lea    0xe57(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"executed %s pid %d\0A\00"
define void @handle_exec(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%11 = load i32, i32* %4
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %5
%14 = alloca i8, i64 %12
store i64 %12, i64* %6
%15 = load i32, i32* %4
%16 = call i32 @read_all_vchan_ext(i8* %14, i32 %15)
%17 = call i32 @do_fork_exec(i8* %14, i32* %7, i32* %8, i32* %9, i32* %10)
%18 = load i32, i32* %3
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = load i32, i32* %9
%22 = load i32, i32* %10
%23 = call i32 @create_info_about_client(i32 %18, i32 %19, i32 %20, i32 %21, i32 %22)
%24 = load i32, i32* @stderr
%25 = load i32, i32* %7
%26 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %14, i32 %25)
%27 = load i8*, i8** %5
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"executed %s pid %d\0A\00"
define void @handle_exec(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = zext i32 %1 to i64
%8 = alloca i8, i64 %7
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = call i32 @read_all_vchan_ext(i8* %8, i32 %1)
%14 = call i32 @do_fork_exec(i8* %8, i32* %3, i32* %4, i32* %5, i32* %6)
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = call i32 @create_info_about_client(i32 %0, i32 %15, i32 %16, i32 %17, i32 %18)
%20 = load i32, i32* @stderr
%21 = load i32, i32* %3
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %21)
ret void
}