// File: /workspace/github_cpp_makefile_star2_O1/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 0x10703(%rip), %rdi     # 0x568ec
xorl %eax, %eax
callq 0x2cfe4
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x10036(%rip), %rsi     # 0x56237
leaq 0x10032(%rip), %rdx     # 0x5623a
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x43424
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 0x46259
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x27480
testb %bpl, %bpl
jne 0x4644d
leaq 0x2485f(%rip), %rdi     # 0x6aac8
callq 0x4661e
movq %rsp, %rdi
callq 0x27660
testl %eax, %eax
js 0x46456
xorl %r14d, %r14d
movl (%rsp,%r14,4), %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 0x4643f
movl (%rsp,%r14,4), %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 0x4643f
incq %r14
cmpq $0x1, %r14
je 0x46281
movq 0x168(%rbx), %r15
testq %r15, %r15
je 0x4645f
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 0x45920
movl 0x190(%rbx), %edx
movl 0x194(%rbx), %ecx
leaq 0x2b0(%rsp), %rsi
movq %rsp, %r8
movq %r14, %rdi
callq 0x470ce
movb %r12b, %bpl
shll $0x1e, %ebp
orl $0x28020011, %ebp       # imm = 0x28020011
leaq -0x180e0(%rip), %rdi    # 0x2e272
movq %r15, %rsi
movl %ebp, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x27890
movl %eax, %ebp
leaq 0x2b0(%rsp), %rdi
callq 0x38f36
testl %ebp, %ebp
js 0x46468
je 0x46471
leaq 0x1061e(%rip), %rdi     # 0x569a3
xorl %eax, %eax
callq 0x2cfe4
leaq 0x418(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x45920
leaq 0x90(%rsp), %rdi
movq %rsp, %rcx
movq %r14, %rsi
movl %ebp, %edx
callq 0x2dfd6
leaq 0x418(%rsp), %rdi
callq 0x38f36
leaq 0x8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x47224
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x474aa
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x46401
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x27480
leaq 0x2a0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x46422
movq 0x2a0(%rsp), %rsi
incq %rsi
callq 0x27480
leaq 0x90(%rsp), %rdi
callq 0x38f36
addq $0x580, %rsp            # imm = 0x580
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x104ec(%rip), %rdi     # 0x56932
xorl %eax, %eax
callq 0x2ce45
leaq 0x104a7(%rip), %rdi     # 0x568fb
jmp 0x46446
leaq 0x104de(%rip), %rdi     # 0x5693b
jmp 0x46446
leaq 0x104de(%rip), %rdi     # 0x56944
jmp 0x46446
leaq 0x10519(%rip), %rdi     # 0x56988
jmp 0x46446
leaq 0x1051a(%rip), %rdi     # 0x56992
jmp 0x46446
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x464a3
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x27480
jmp 0x464a3
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x47550
jmp 0x464e6
movq %rax, %rbx
leaq 0x418(%rsp), %rdi
callq 0x38f36
jmp 0x464e6
movq %rax, %rbx
leaq 0x2b0(%rsp), %rdi
callq 0x38f36
jmp 0x464d9
movq %rax, %rbx
movl $0x178, %esi            # imm = 0x178
movq %r14, %rdi
callq 0x27480
movq %rbx, %rdi
callq 0x27830