#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*/ SIGSTOP;
int /*<<< orphan*/ execve(char *, char **, char **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ raise(int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
void do_shell(char *executable, int wfd, int rfd) {
  char arg1[10], arg2[10];
  char *newargv[] = {executable, NULL, NULL, NULL};
  char *newenviron[] = {NULL};
  sprintf(arg1, "%05d", wfd);
  sprintf(arg2, "%05d", rfd);
  newargv[1] = arg1;
  newargv[2] = arg2;
  raise(SIGSTOP);
  execve(executable, newargv, newenviron);
  perror("scheduler: child: execve");
  exit(1);
}


x86 assembly (clang, -O0):
<do_shell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    -0x1a(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe58(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x24(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe45(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x1a(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x24(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
mov    -0x8(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x58(%rbp),%rdx
call   1050 <execve@plt>
lea    0xe0f(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<do_shell>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %edx,%r12d
mov    %esi,%edx
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
mov    %rdi,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xe7f(%rip),%r14
lea    0x46(%rsp),%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <sprintf@plt>
lea    0x3c(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1060 <sprintf@plt>
mov    %r15,0x18(%rsp)
mov    %rbp,0x20(%rsp)
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <execve@plt>
lea    0xe30(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%05d\00"
@SIGSTOP = global i32 0
@.str.1 = [25 x i8] c"scheduler: child: execve\00"
define void @do_shell(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [10 x i8]
%8 = alloca [10 x i8]
%9 = alloca [4 x i8*]
%10 = alloca [1 x i8*]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = bitcast [4 x i8*]* %9 to i8*
%12 = getelementptr inbounds [4 x i8*], [4 x i8*]* %9, i64 0, i64 0
%13 = load i8*, i8** %4
store i8* %13, i8** %12
%14 = getelementptr inbounds i8*, i8** %12, i64 1
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = bitcast [1 x i8*]* %10 to i8*
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%19 = load i32, i32* %5
%20 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%22 = load i32, i32* %6
%23 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%25 = getelementptr inbounds [4 x i8*], [4 x i8*]* %9, i64 0, i64 1
store i8* %24, i8** %25
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%27 = getelementptr inbounds [4 x i8*], [4 x i8*]* %9, i64 0, i64 2
store i8* %26, i8** %27
%28 = load i32, i32* @SIGSTOP
%29 = call i32 @raise(i32 %28)
%30 = load i8*, i8** %4
%31 = getelementptr inbounds [4 x i8*], [4 x i8*]* %9, i64 0, i64 0
%32 = getelementptr inbounds [1 x i8*], [1 x i8*]* %10, i64 0, i64 0
%33 = call i32 @execve(i8* %30, i8** %31, i8** %32)
%34 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [5 x i8] c"%05d\00"
@SIGSTOP = global i32 0
@.str.1 = [25 x i8] c"scheduler: child: execve\00"
define void @do_shell(i8* %0, i32 %1, i32 %2) {
%4 = alloca [10 x i8]
%5 = alloca [10 x i8]
%6 = alloca [4 x i8*]
%7 = alloca [1 x i8*]
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%10 = bitcast [4 x i8*]* %6 to i8*
%11 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 2
%12 = bitcast i8** %11 to i8*
%13 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 0
store i8* %0, i8** %13
%14 = bitcast [1 x i8*]* %7 to i8*
%15 = bitcast [1 x i8*]* %7 to i64*
store i64 0, i64* %15
%16 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %1)
%17 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %2)
%18 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 1
store i8* %8, i8** %18
%19 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 2
store i8* %9, i8** %19
%20 = load i32, i32* @SIGSTOP
%21 = call i32 @raise(i32 %20)
%22 = getelementptr inbounds [1 x i8*], [1 x i8*]* %7, i64 0, i64 0
%23 = call i32 @execve(i8* %0, i8** %13, i8** %22)
%24 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
}