// File: /workspace/github_cpp_makefile_star2_O3/establishment[P]sandman/src/lib.hpp
// Function: Jailer::Run()
void Run() {
        Msg("Start running\n");

        if (!Base::DirExists("box")) {
            Die("Box directory not found, did you run 'isolate --init'?");
        }

        cg.prepare();  /// creates cgroup if it's not created

        /// This code will live here. Life is hard.
        /// setup pipes
        int errorPipes[2];
        if (pipe(errorPipes) < 0)
            Die("pipe: %m");

        /// close errorPipes when clone ends
        for (int i = 0; i < 2; i++)
            if (fcntl(errorPipes[i], F_SETFD, fcntl(errorPipes[i], F_GETFD) | FD_CLOEXEC) < 0 ||
                fcntl(errorPipes[i], F_SETFL, fcntl(errorPipes[i], F_GETFL) | O_NONBLOCK) < 0)
                Die("fcntl on pipe: %m");

        /// sanity check
        if (isolatedProcessStack == nullptr) {
            Die("Must provide a pointer to stack if the jailer is used as a library.");
        }

        int processPid =
            clone(ProcessInitialiser::ASyncStart,  /// Function to execute as the body of the new process
                  isolatedProcessStack,            /// stack for the new process (argv is the start of stack)
                  SIGCHLD | CLONE_NEWIPC | (config.shareNetwork ? 0 : CLONE_NEWNET) | CLONE_NEWNS | CLONE_NEWPID,
                  new ProcessInitialiser(config, uid, gid, errorPipes));  /// pass config for initialiser

        if (processPid < 0) {
            Die("clone: %m");
        }

        if (!processPid) {
            Die("clone returned 0");
        }

        Msg("Start waiting for process\n");

        ProcessKeeper keeper(config, processPid, errorPipes);
        RunStats finalStats = keeper.startKeeper();
        PrintStats(finalStats);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x580, %rsp            # imm = 0x580
movq %rdi, %rbx
leaq 0x10d67(%rip), %rdi     # 0x568ec
xorl %eax, %eax
callq 0x2ceee
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1069a(%rip), %rsi     # 0x56237
leaq 0x10696(%rip), %rdx     # 0x5623a
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x42cf8
movq (%r14), %rdi
leaq 0x90(%rsp), %r15
movq %r15, %rsi
callq 0x273f0
testl %eax, %eax
sets %al
movl 0x18(%r15), %ecx
andl $0xf000, %ecx           # imm = 0xF000
cmpl $0x4000, %ecx           # imm = 0x4000
setne %bpl
orb %al, %bpl
movq (%r14), %rdi
cmpq %r12, %rdi
je 0x45bf5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x27480
testb %bpl, %bpl
jne 0x45df5
leaq 0x24ec3(%rip), %rdi     # 0x6aac8
callq 0x45fc6
movq %rsp, %r14
movq %r14, %rdi
callq 0x27660
testl %eax, %eax
js 0x45dfe
leaq 0x4(%rsp), %r15
movb $0x1, %r12b
movl (%r14), %ebp
movl %ebp, %edi
movl $0x1, %esi
xorl %eax, %eax
callq 0x27290
orl $0x1, %eax
movl %ebp, %edi
movl $0x2, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x27290
testl %eax, %eax
js 0x45de7
movl (%r14), %ebp
movl %ebp, %edi
movl $0x3, %esi
xorl %eax, %eax
callq 0x27290
orl $0x800, %eax            # imm = 0x800
movl %ebp, %edi
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x27290
testl %eax, %eax
js 0x45de7
movq %r15, %r14
testb $0x1, %r12b
movl $0x0, %r12d
jne 0x45c25
movq 0x168(%rbx), %r15
testq %r15, %r15
je 0x45e07
xorl %ebp, %ebp
cmpl $0x0, 0xe0(%rbx)
sete %r12b
movl $0x178, %edi            # imm = 0x178
callq 0x27470
movq %rax, %r14
leaq 0x2b0(%rsp), %rdi
movq %rbx, %rsi
callq 0x452b4
movl 0x190(%rbx), %edx
movl 0x194(%rbx), %ecx
leaq 0x2b0(%rsp), %rsi
movq %rsp, %r8
movq %r14, %rdi
callq 0x46a76
movb %r12b, %bpl
shll $0x1e, %ebp
orl $0x28020011, %ebp       # imm = 0x28020011
leaq -0x17b86(%rip), %rdi    # 0x2e174
movq %r15, %rsi
movl %ebp, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x27890
movl %eax, %ebp
leaq 0x2b0(%rsp), %rdi
callq 0x38890
testl %ebp, %ebp
js 0x45e10
je 0x45e19
leaq 0x10c76(%rip), %rdi     # 0x569a3
xorl %eax, %eax
callq 0x2ceee
leaq 0x418(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x452b4
leaq 0x90(%rsp), %rdi
movq %rsp, %rcx
movq %r14, %rsi
movl %ebp, %edx
callq 0x2ded8
leaq 0x418(%rsp), %rdi
callq 0x38890
leaq 0x8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x46bcc
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x46e52
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x45da9
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x27480
leaq 0x2a0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x45dca
movq 0x2a0(%rsp), %rsi
incq %rsi
callq 0x27480
leaq 0x90(%rsp), %rdi
callq 0x38890
addq $0x580, %rsp            # imm = 0x580
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10b44(%rip), %rdi     # 0x56932
xorl %eax, %eax
callq 0x2cd4f
leaq 0x10aff(%rip), %rdi     # 0x568fb
jmp 0x45dee
leaq 0x10b36(%rip), %rdi     # 0x5693b
jmp 0x45dee
leaq 0x10b36(%rip), %rdi     # 0x56944
jmp 0x45dee
leaq 0x10b71(%rip), %rdi     # 0x56988
jmp 0x45dee
leaq 0x10b72(%rip), %rdi     # 0x56992
jmp 0x45dee
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x45e4b
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x27480
jmp 0x45e4b
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x46ef8
jmp 0x45e8e
movq %rax, %rbx
leaq 0x418(%rsp), %rdi
callq 0x38890
jmp 0x45e8e
movq %rax, %rbx
leaq 0x2b0(%rsp), %rdi
callq 0x38890
jmp 0x45e81
movq %rax, %rbx
movl $0x178, %esi            # imm = 0x178
movq %r14, %rdi
callq 0x27480
movq %rbx, %rdi
callq 0x27830