#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int tar_gz(char *arc) {
  FILE *pi, *po;
  int c, cnt = 0;
  char buf[512];
  sprintf(buf, "gunzip -c %s 2>/dev/null", arc);
  if ((pi = popen(buf, "r")) == NULL) {
    fprintf(stderr, "pipe Akimahen !!\n");
    return -2;
  }
  strcpy(buf, "tar xf - >/dev/null 2>&1");
  if ((po = popen(buf, "w")) == NULL) {
    fprintf(stderr, "pipe Akimahen !!\n");
    pclose(pi);
    return -3;
  }
  while ((c = getc(pi)) != EOF) {
    fputc(c, po);
    ++cnt;
  }
  pclose(po);
  pclose(pi);
  return ((cnt < 512) ? -1 : 0);
}


x86 assembly (clang, -O0):
<tar_gz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x28(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe68(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x230(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11df <tar_gz+0x6f>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    129f <tar_gz+0x12f>
lea    -0x230(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x230(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1070 <popen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    123d <tar_gz+0xcd>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
lea    0xdf8(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <pclose@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    129f <tar_gz+0x12f>
jmp    1242 <tar_gz+0xd2>
mov    -0x18(%rbp),%rdi
call   1090 <getc@plt>
mov    %eax,-0x24(%rbp)
mov    0x2d93(%rip),%rcx
cmp    (%rcx),%eax
je     1277 <tar_gz+0x107>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1050 <fputc@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1242 <tar_gz+0xd2>
mov    -0x20(%rbp),%rdi
call   1040 <pclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <pclose@plt>
mov    -0x28(%rbp),%edx
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    $0x200,%edx
cmovl  %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tar_gz>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %rdi,%rdx
lea    0xe77(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1080 <sprintf@plt>
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
call   1070 <popen@plt>
test   %rax,%rax
je     1236 <tar_gz+0xc6>
mov    %rax,%r14
lea    0xe77(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
call   1070 <popen@plt>
test   %rax,%rax
je     1253 <tar_gz+0xe3>
mov    %rax,%rbx
mov    %r14,%rdi
call   1090 <getc@plt>
mov    0x2dfd(%rip),%r12
mov    $0xffffffff,%r15d
cmp    (%r12),%eax
je     1224 <tar_gz+0xb4>
mov    $0xffffffff,%ebp
nopl   0x0(%rax)
mov    %eax,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
mov    %r14,%rdi
call   1090 <getc@plt>
add    $0x1,%ebp
cmp    (%r12),%eax
jne    1200 <tar_gz+0x90>
cmp    $0x1ff,%ebp
sbb    %r15d,%r15d
mov    %rbx,%rdi
call   1040 <pclose@plt>
mov    %r14,%rdi
call   1040 <pclose@plt>
jmp    1276 <tar_gz+0x106>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
lea    0xdd5(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xfffffffe,%r15d
jmp    1276 <tar_gz+0x106>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
lea    0xdb8(%rip),%rsi
call   1060 <fprintf@plt>
mov    %r14,%rdi
call   1040 <pclose@plt>
mov    $0xfffffffd,%r15d
mov    %r15d,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"gunzip -c %s 2>/dev/null\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [18 x i8] c"pipe Akimahen !!\0A\00"
@.str.3 = [25 x i8] c"tar xf - >/dev/null 2>&1\00"
@.str.4 = [2 x i8] c"w\00"
@EOF = global i32 0
define i32 @tar_gz(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [512 x i8]
store i8* %0, i8** %3
store i32 0, i32* %7
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%10 = load i8*, i8** %3
%11 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%13 = call i32* @popen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %4
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %1
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 -2, i32* %2
br label %50
18: ; preds = %1
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%20 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%22 = call i32* @popen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %22, i32** %5
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %29
24: ; preds = %18
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%27 = load i32*, i32** %4
%28 = call i32 @pclose(i32* %27)
store i32 -3, i32* %2
br label %50
29: ; preds = %18
br label %30
30: ; preds = %35, %29
%31 = load i32*, i32** %4
%32 = call i32 @getc(i32* %31)
store i32 %32, i32* %6
%33 = load i32, i32* @EOF
%34 = icmp ne i32 %32, %33
br i1 %34, label %35, label %41
35: ; preds = %30
%36 = load i32, i32* %6
%37 = load i32*, i32** %5
%38 = call i32 @fputc(i32 %36, i32* %37)
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %30
41: ; preds = %30
%42 = load i32*, i32** %5
%43 = call i32 @pclose(i32* %42)
%44 = load i32*, i32** %4
%45 = call i32 @pclose(i32* %44)
%46 = load i32, i32* %7
%47 = icmp slt i32 %46, 512
%48 = zext i1 %47 to i64
%49 = select i1 %47, i32 -1, i32 0
store i32 %49, i32* %2
br label %50
50: ; preds = %41, %24, %15
%51 = load i32, i32* %2
ret i32 %51
}

LLVM IR (-O2):
@.str = [25 x i8] c"gunzip -c %s 2>/dev/null\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [18 x i8] c"pipe Akimahen !!\0A\00"
@.str.3 = [25 x i8] c"tar xf - >/dev/null 2>&1\00"
@.str.4 = [2 x i8] c"w\00"
@EOF = global i32 0
define i32 @tar_gz(i8* %0) {
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = call i32* @popen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %37
10: ; preds = %1
%11 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32* @popen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = call i32 @getc(i32* %5)
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %33, label %22
18: ; preds = %10
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @pclose(i32* %5)
br label %37
22: ; preds = %14, %22
%23 = phi i32 [ %27, %22 ], [ %15, %14 ]
%24 = phi i32 [ %26, %22 ], [ 0, %14 ]
%25 = call i32 @fputc(i32 %23, i32* %12)
%26 = add nuw nsw i32 %24, 1
%27 = call i32 @getc(i32* %5)
%28 = load i32, i32* @EOF
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %22
30: ; preds = %22
%31 = icmp ult i32 %24, 511
%32 = sext i1 %31 to i32
br label %33
33: ; preds = %30, %14
%34 = phi i32 [ -1, %14 ], [ %32, %30 ]
%35 = call i32 @pclose(i32* %12)
%36 = call i32 @pclose(i32* %5)
br label %37
37: ; preds = %33, %18, %7
%38 = phi i32 [ -2, %7 ], [ -3, %18 ], [ %34, %33 ]
ret i32 %38
}