#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 ejudge_invoke_process(char **, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/, unsigned char **,
                          unsigned char **);
int /*<<< orphan*/ error(char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned char *);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ stderr;
int unpack_tar(const unsigned char *path, const unsigned char *dir) {
  int r;
  unsigned char *out = 0, *err = 0;
  char *cmds[6];
  cmds[0] = "/bin/tar";
  cmds[1] = "xf";
  cmds[2] = (char *)path;
  cmds[3] = "-C";
  cmds[4] = (char *)dir;
  cmds[5] = 0;
  r = ejudge_invoke_process(cmds, NULL, NULL, NULL, NULL, 0, &out, &err);
  if (r != 0) {
    error("archiver exit code: %d", r);
    fprintf(stderr, "%s", err);
    r = -1;
  }
  free(out);
  free(err);
  return r;
}


x86 assembly (clang, -O0):
<unpack_tar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe99(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xe97(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    0xe87(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%r8d
xor    %r9d,%r9d
lea    -0x20(%rbp),%r10
lea    -0x28(%rbp),%rax
mov    %r8,%rsi
mov    %r8,%rdx
mov    %r8,%rcx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1060 <ejudge_invoke_process@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1200 <unpack_tar+0xc0>
mov    -0x14(%rbp),%esi
lea    0xe34(%rip),%rdi
call   1050 <error@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe32(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unpack_tar>:
push   %rbx
sub    $0x40,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xea3(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xea0(%rip),%rax
mov    %rax,0x18(%rsp)
mov    %rdi,0x20(%rsp)
lea    0xe92(%rip),%rax
mov    %rax,0x28(%rsp)
mov    %rsi,0x30(%rsp)
movq   $0x0,0x38(%rsp)
mov    %rsp,%rax
lea    0x8(%rsp),%r10
xor    %ebx,%ebx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   %rax
push   %r10
call   1060 <ejudge_invoke_process@plt>
add    $0x10,%rsp
test   %eax,%eax
je     11e4 <unpack_tar+0xa4>
lea    0xe50(%rip),%rdi
mov    %eax,%esi
call   1050 <error@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rdx
lea    0xe4c(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"/bin/tar\00"
@.str.1 = [3 x i8] c"xf\00"
@.str.2 = [3 x i8] c"-C\00"
@.str.3 = [23 x i8] c"archiver exit code: %d\00"
@stderr = global i32 0
@.str.4 = [3 x i8] c"%s\00"
define i32 @unpack_tar(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [6 x i8*]
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8* null, i8** %6
store i8* null, i8** %7
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i64 0, i64 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %10
%11 = load i8*, i8** %3
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i64 0, i64 2
store i8* %11, i8** %12
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i64 0, i64 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %13
%14 = load i8*, i8** %4
%15 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i64 0, i64 4
store i8* %14, i8** %15
%16 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i64 0, i64 5
store i8* null, i8** %16
%17 = getelementptr inbounds [6 x i8*], [6 x i8*]* %8, i64 0, i64 0
%18 = call i32 @ejudge_invoke_process(i8** %17, i32* null, i32* null, i32* null, i32* null, i32 0, i8** %6, i8** %7)
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %2
%22 = load i32, i32* %5
%23 = call i32 @error(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %7
%26 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %25)
store i32 -1, i32* %5
br label %27
27: ; preds = %21, %2
%28 = load i8*, i8** %6
%29 = call i32 @free(i8* %28)
%30 = load i8*, i8** %7
%31 = call i32 @free(i8* %30)
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
@.str = [9 x i8] c"/bin/tar\00"
@.str.1 = [3 x i8] c"xf\00"
@.str.2 = [3 x i8] c"-C\00"
@.str.3 = [23 x i8] c"archiver exit code: %d\00"
@stderr = global i32 0
@.str.4 = [3 x i8] c"%s\00"
define i32 @unpack_tar(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [6 x i8*]
%6 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%7 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%8 = bitcast [6 x i8*]* %5 to i8*
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 2
store i8* %0, i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 4
store i8* %1, i8** %13
%14 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 5
store i8* null, i8** %14
%15 = call i32 @ejudge_invoke_process(i8** %9, i32* null, i32* null, i32* null, i32* null, i32 0, i8** %3, i8** %4)
%16 = icmp eq i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %2
%18 = call i32 @error(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %4
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %17, %2
%23 = phi i32 [ -1, %17 ], [ 0, %2 ]
%24 = load i8*, i8** %3
%25 = call i32 @free(i8* %24)
%26 = load i8*, i8** %4
%27 = call i32 @free(i8* %26)
ret i32 %23
}