#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*/ *, unsigned char const *,
                          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_zip(const unsigned char *path, const unsigned char *dir) {
  int r;
  unsigned char *out = 0, *err = 0;
  char *cmds[4];
  cmds[0] = "/usr/bin/7z";
  cmds[1] = "x";
  cmds[2] = (char *)path;
  cmds[3] = 0;
  r = ejudge_invoke_process(cmds, NULL, dir, 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_zip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe99(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r8d
xor    %r9d,%r9d
lea    -0x20(%rbp),%r10
lea    -0x28(%rbp),%rax
mov    %r8,%rsi
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     11ee <unpack_zip+0xae>
mov    -0x14(%rbp),%esi
lea    0xe45(%rip),%rdi
call   1050 <error@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe43(%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    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unpack_zip>:
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rdx
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xea0(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xea0(%rip),%rax
mov    %rax,0x18(%rsp)
mov    %rdi,0x20(%rsp)
movq   $0x0,0x28(%rsp)
mov    %rsp,%rax
lea    0x8(%rsp),%r10
xor    %ebx,%ebx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
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     11d4 <unpack_zip+0x94>
lea    0xe5f(%rip),%rdi
mov    %eax,%esi
call   1050 <error@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%rdx
lea    0xe5b(%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    $0x30,%rsp
pop    %rbx
ret

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

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