#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*/ setresgid(int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/);
int /*<<< orphan*/ setresuid(int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int system(char *);
int main(int argc, char **argv) {
  char command[4096];
  char container_name[256];
  char container_image[256];
  char mount_dir1[1024];
  char mount_dir2[1024];
  snprintf(container_name, (size_t)256, "%s", argv[1]);
  snprintf(container_image, (size_t)256, "%s", argv[2]);
  snprintf(mount_dir1, (size_t)1024, "%s", argv[3]);
  snprintf(mount_dir2, (size_t)1024, "%s", argv[4]);
  int ret;
  setresuid(0, 0, 0);
  setresgid(0, 0, 0);
  sprintf(command, "/usr/bin/docker stop -t 1 %s", container_name);
  ret = system(command);
  sprintf(command, "/usr/bin/docker rm %s", container_name);
  ret = system(command);
  sprintf(command,
          "/usr/bin/docker run --net=none --name %s -d -v /dev/log:/dev/log -v "
          "%s -v %s -i -t %s",
          container_name, mount_dir1, mount_dir2, container_image);
  ret = system(command);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1110(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0x100,%esi
lea    0xe96(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x1210(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
mov    $0x100,%esi
lea    0xe76(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x1610(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
mov    $0x400,%esi
lea    0xe56(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x1a10(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rcx
mov    $0x400,%esi
lea    0xe36(%rip),%rdx
call   1060 <snprintf@plt>
xor    %edx,%edx
mov    %edx,%edi
mov    %edx,%esi
call   1030 <setresuid@plt>
xor    %edx,%edx
mov    %edx,%edi
mov    %edx,%esi
call   1040 <setresgid@plt>
lea    -0x1010(%rbp),%rdi
lea    -0x1110(%rbp),%rdx
lea    0xdec(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x1010(%rbp),%rdi
call   1050 <system@plt>
mov    %eax,-0x1a14(%rbp)
lea    -0x1010(%rbp),%rdi
lea    -0x1110(%rbp),%rdx
lea    0xddb(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x1010(%rbp),%rdi
call   1050 <system@plt>
mov    %eax,-0x1a14(%rbp)
lea    -0x1010(%rbp),%rdi
lea    -0x1110(%rbp),%rdx
lea    -0x1610(%rbp),%rcx
lea    -0x1a10(%rbp),%r8
lea    -0x1210(%rbp),%r9
lea    0xdae(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x1010(%rbp),%rdi
call   1050 <system@plt>
mov    %eax,-0x1a14(%rbp)
mov    -0x1a14(%rbp),%eax
add    $0x1a20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a08,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rcx
lea    0xeab(%rip),%rbp
lea    0x100(%rsp),%r13
mov    $0x100,%esi
mov    %r13,%rdi
mov    %rbp,%rdx
call   1060 <snprintf@plt>
mov    0x10(%rbx),%rcx
mov    %rsp,%r14
mov    $0x100,%esi
mov    %r14,%rdi
mov    %rbp,%rdx
call   1060 <snprintf@plt>
mov    0x18(%rbx),%rcx
lea    0x600(%rsp),%r15
mov    $0x400,%esi
mov    %r15,%rdi
mov    %rbp,%rdx
call   1060 <snprintf@plt>
mov    0x20(%rbx),%rcx
lea    0x200(%rsp),%r12
mov    $0x400,%esi
mov    %r12,%rdi
mov    %rbp,%rdx
call   1060 <snprintf@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <setresuid@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <setresgid@plt>
lea    0xe0d(%rip),%rsi
lea    0xa00(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
lea    0xe06(%rip),%rsi
mov    %rbx,%rdi
mov    %r13,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
lea    0xe00(%rip),%rsi
mov    %rbx,%rdi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %r12,%r8
mov    %r14,%r9
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
add    $0x1a08,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [29 x i8] c"/usr/bin/docker stop -t 1 %s\00"
@.str.2 = [22 x i8] c"/usr/bin/docker rm %s\00"
@.str.3 = [86 x i8] c"/usr/bin/docker run --net=none --name %s -d -v /dev/log:/dev/log -v %s -v %s -i -t %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4096 x i8]
%7 = alloca [256 x i8]
%8 = alloca [256 x i8]
%9 = alloca [1024 x i8]
%10 = alloca [1024 x i8]
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @snprintf(i8* %12, i64 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @snprintf(i8* %17, i64 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 3
%25 = load i8*, i8** %24
%26 = call i32 @snprintf(i8* %22, i64 1024, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 4
%30 = load i8*, i8** %29
%31 = call i32 @snprintf(i8* %27, i64 1024, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %30)
%32 = call i32 @setresuid(i32 0, i32 0, i32 0)
%33 = call i32 @setresgid(i32 0, i32 0, i32 0)
%34 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%36 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %34, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%38 = call i32 @system(i8* %37)
store i32 %38, i32* %11
%39 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%41 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %40)
%42 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%43 = call i32 @system(i8* %42)
store i32 %43, i32* %11
%44 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%49 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %44, i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.3, i64 0, i64 0), i8* %45, i8* %46, i8* %47, i8* %48)
%50 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%51 = call i32 @system(i8* %50)
store i32 %51, i32* %11
%52 = load i32, i32* %11
ret i32 %52
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [29 x i8] c"/usr/bin/docker stop -t 1 %s\00"
@.str.2 = [22 x i8] c"/usr/bin/docker rm %s\00"
@.str.3 = [86 x i8] c"/usr/bin/docker run --net=none --name %s -d -v /dev/log:/dev/log -v %s -v %s -i -t %s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @snprintf(i8* %9, i64 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = call i32 @snprintf(i8* %10, i64 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds i8*, i8** %1, i64 3
%20 = load i8*, i8** %19
%21 = call i32 @snprintf(i8* %11, i64 1024, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds i8*, i8** %1, i64 4
%23 = load i8*, i8** %22
%24 = call i32 @snprintf(i8* %12, i64 1024, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = call i32 @setresuid(i32 0, i32 0, i32 0)
%26 = call i32 @setresgid(i32 0, i32 0, i32 0)
%27 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%28 = call i32 @system(i8* %8)
%29 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%30 = call i32 @system(i8* %8)
%31 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @.str.3, i64 0, i64 0), i8* %9, i8* %11, i8* %12, i8* %10)
%32 = call i32 @system(i8* %8)
ret i32 %32
}