#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 /*<<< orphan*/ create_dir(char *, int);
int /*<<< orphan*/ *create_file(char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
size_t fwrite(char *, int, size_t, int /*<<< orphan*/ *);
scalar_t__ is_end_of_archive(char *);
int parseoct(char *, int);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ verify_checksum(char *);
void untar(FILE *a, const char *path) {
  char buff[512];
  FILE *f = NULL;
  size_t bytes_read;
  int filesize;
  printf("Extracting from %s\n", path);
  for (;;) {
    bytes_read = fread(buff, 1, 512, a);
    if (bytes_read < 512) {
      fprintf(stderr, "Short read on %s: expected 512, got %d\n", path,
              (int)bytes_read);
      return;
    }
    if (is_end_of_archive(buff)) {
      printf("End of %s\n", path);
      return;
    }
    if (!verify_checksum(buff)) {
      fprintf(stderr, "Checksum failure\n");
      return;
    }
    filesize = parseoct(buff + 124, 12);
    switch (buff[156]) {
    case '1':
      printf(" Ignoring hardlink %s\n", buff);
      break;
    case '2':
      printf(" Ignoring symlink %s\n", buff);
      break;
    case '3':
      printf(" Ignoring character device %s\n", buff);
      break;
    case '4':
      printf(" Ignoring block device %s\n", buff);
      break;
    case '5':
      printf(" Extracting dir %s\n", buff);
      create_dir(buff, parseoct(buff + 100, 8));
      filesize = 0;
      break;
    case '6':
      printf(" Ignoring FIFO %s\n", buff);
      break;
    default:
      printf(" Extracting file %s\n", buff);
      f = create_file(buff, parseoct(buff + 100, 8));
      break;
    }
    while (filesize > 0) {
      bytes_read = fread(buff, 1, 512, a);
      if (bytes_read < 512) {
        fprintf(stderr, "Short read on %s: Expected 512, got %d\n", path,
                (int)bytes_read);
        return;
      }
      if (filesize < 512)
        bytes_read = filesize;
      if (f != NULL) {
        if (fwrite(buff, 1, bytes_read, f) != bytes_read) {
          fprintf(stderr, "Failed write\n");
          fclose(f);
          f = NULL;
        }
      }
      filesize -= bytes_read;
    }
    if (f != NULL) {
      fclose(f);
      f = NULL;
    }
  }
}


x86 assembly (clang, -O0):
<untar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x218(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe4f(%rip),%rdi
call   1050 <printf@plt>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x200,%edx
call   1030 <fread@plt>
mov    %rax,-0x220(%rbp)
cmpq   $0x200,-0x220(%rbp)
jae    1229 <untar+0x89>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x220(%rbp),%rax
mov    %eax,%ecx
lea    0xe0f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1523 <untar+0x383>
lea    -0x210(%rbp),%rdi
call   1080 <is_end_of_archive@plt>
cmp    $0x0,%rax
je     1254 <untar+0xb4>
mov    -0x10(%rbp),%rsi
lea    0xe0a(%rip),%rdi
call   1050 <printf@plt>
jmp    1523 <untar+0x383>
lea    -0x210(%rbp),%rdi
call   1090 <verify_checksum@plt>
cmp    $0x0,%eax
jne    1285 <untar+0xe5>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
lea    0xde6(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1523 <untar+0x383>
lea    -0x194(%rbp),%rdi
mov    $0xc,%esi
call   10c0 <parseoct@plt>
mov    %eax,-0x224(%rbp)
movsbl -0x174(%rbp),%eax
add    $0xffffffcf,%eax
mov    %eax,%ecx
mov    %rcx,-0x230(%rbp)
sub    $0x5,%eax
ja     139a <untar+0x1fa>
mov    -0x230(%rbp),%rax
lea    0xd3a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x210(%rbp),%rsi
lea    0xd94(%rip),%rdi
call   1050 <printf@plt>
jmp    13e5 <untar+0x245>
lea    -0x210(%rbp),%rsi
lea    0xd93(%rip),%rdi
call   1050 <printf@plt>
jmp    13e5 <untar+0x245>
lea    -0x210(%rbp),%rsi
lea    0xd91(%rip),%rdi
call   1050 <printf@plt>
jmp    13e5 <untar+0x245>
lea    -0x210(%rbp),%rsi
lea    0xd98(%rip),%rdi
call   1050 <printf@plt>
jmp    13e5 <untar+0x245>
lea    -0x210(%rbp),%rsi
lea    0xd9b(%rip),%rdi
call   1050 <printf@plt>
lea    -0x210(%rbp),%rax
mov    %rax,-0x238(%rbp)
lea    -0x210(%rbp),%rdi
add    $0x64,%rdi
mov    $0x8,%esi
call   10c0 <parseoct@plt>
mov    -0x238(%rbp),%rdi
mov    %eax,%esi
call   1070 <create_dir@plt>
movl   $0x0,-0x224(%rbp)
jmp    13e5 <untar+0x245>
lea    -0x210(%rbp),%rsi
lea    0xd5c(%rip),%rdi
call   1050 <printf@plt>
jmp    13e5 <untar+0x245>
lea    -0x210(%rbp),%rsi
lea    0xd57(%rip),%rdi
call   1050 <printf@plt>
lea    -0x210(%rbp),%rax
mov    %rax,-0x240(%rbp)
lea    -0x210(%rbp),%rdi
add    $0x64,%rdi
mov    $0x8,%esi
call   10c0 <parseoct@plt>
mov    -0x240(%rbp),%rdi
mov    %eax,%esi
call   10a0 <create_file@plt>
mov    %rax,-0x218(%rbp)
jmp    13ea <untar+0x24a>
cmpl   $0x0,-0x224(%rbp)
jle    14f9 <untar+0x359>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x200,%edx
call   1030 <fread@plt>
mov    %rax,-0x220(%rbp)
cmpq   $0x200,-0x220(%rbp)
jae    1452 <untar+0x2b2>
mov    0x2bb0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x220(%rbp),%rax
mov    %eax,%ecx
lea    0xcce(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1523 <untar+0x383>
cmpl   $0x200,-0x224(%rbp)
jge    1470 <untar+0x2d0>
movslq -0x224(%rbp),%rax
mov    %rax,-0x220(%rbp)
cmpq   $0x0,-0x218(%rbp)
je     14dd <untar+0x33d>
lea    -0x210(%rbp),%rdi
mov    -0x220(%rbp),%rdx
mov    -0x218(%rbp),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
cmp    -0x220(%rbp),%rax
je     14d8 <untar+0x338>
mov    0x2b2f(%rip),%rax
mov    (%rax),%edi
lea    0xc82(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x218(%rbp),%rdi
call   1040 <fclose@plt>
movq   $0x0,-0x218(%rbp)
jmp    14dd <untar+0x33d>
mov    -0x220(%rbp),%rcx
movslq -0x224(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x224(%rbp)
jmp    13ea <untar+0x24a>
cmpq   $0x0,-0x218(%rbp)
je     151e <untar+0x37e>
mov    -0x218(%rbp),%rdi
call   1040 <fclose@plt>
movq   $0x0,-0x218(%rbp)
jmp    11ce <untar+0x2e>
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<untar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe5a(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x200,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x200,%rax
jae    11fa <untar+0x5a>
mov    0x2df9(%rip),%rcx
mov    (%rcx),%edi
lea    0xe3c(%rip),%rsi
mov    %r14,%rdx
mov    %eax,%ecx
jmp    13b8 <untar+0x218>
mov    %rsp,%r13
mov    %r13,%rdi
call   1080 <is_end_of_archive@plt>
test   %rax,%rax
jne    13d1 <untar+0x231>
mov    %r13,%rdi
call   1090 <verify_checksum@plt>
test   %eax,%eax
je     13e2 <untar+0x242>
lea    0x7c(%rsp),%rdi
mov    $0xc,%esi
call   10c0 <parseoct@plt>
mov    %eax,%r12d
movsbl 0x9c(%rsp),%eax
add    $0xffffffcf,%eax
cmp    $0x5,%eax
ja     125c <untar+0xbc>
lea    0xdb9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe1a(%rip),%rdi
jmp    12e0 <untar+0x140>
lea    0xe9c(%rip),%rdi
mov    %r13,%rsi
call   1050 <printf@plt>
lea    0x64(%rsp),%rdi
mov    $0x8,%esi
call   10c0 <parseoct@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   10a0 <create_file@plt>
mov    %rax,%r15
jmp    12f6 <untar+0x156>
lea    0xdf8(%rip),%rdi
jmp    12e0 <untar+0x140>
lea    0xe05(%rip),%rdi
jmp    12e0 <untar+0x140>
lea    0xe1b(%rip),%rdi
jmp    12e0 <untar+0x140>
lea    0xe2d(%rip),%rdi
mov    %r13,%rsi
call   1050 <printf@plt>
lea    0x64(%rsp),%rdi
mov    $0x8,%esi
call   10c0 <parseoct@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1070 <create_dir@plt>
jmp    137d <untar+0x1dd>
lea    0xe14(%rip),%rdi
nopl   0x0(%rax,%rax,1)
mov    %r13,%rsi
call   1050 <printf@plt>
xor    %r15d,%r15d
jmp    12f6 <untar+0x156>
nopl   (%rax)
xor    %r15d,%r15d
sub    %ebp,%r12d
test   %r12d,%r12d
jle    1370 <untar+0x1d0>
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x200,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %rax,%rbp
cmp    $0x1ff,%rax
jbe    13a3 <untar+0x203>
cmp    $0x200,%r12d
mov    %r12d,%eax
cmovb  %rax,%rbp
test   %r15,%r15
je     12f0 <untar+0x150>
mov    %r13,%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
mov    %r15,%rcx
call   10b0 <fwrite@plt>
cmp    %rbp,%rax
je     12f3 <untar+0x153>
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
lea    0xde2(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    12f0 <untar+0x150>
nopl   0x0(%rax,%rax,1)
test   %r15,%r15
je     137d <untar+0x1dd>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x200,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x200,%rax
jae    11fd <untar+0x5d>
jmp    11e0 <untar+0x40>
mov    0x2c36(%rip),%rax
mov    (%rax),%edi
lea    0xd61(%rip),%rsi
mov    %r14,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc7c(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
jmp    13bf <untar+0x21f>
mov    0x2bf7(%rip),%rax
mov    (%rax),%edi
lea    0xc6d(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    13bf <untar+0x21f>

LLVM IR (-O0):
@.str = [20 x i8] c"Extracting from %s\0A\00"
@stderr = global i32 0
@.str.1 = [40 x i8] c"Short read on %s: expected 512, got %d\0A\00"
@.str.2 = [11 x i8] c"End of %s\0A\00"
@.str.3 = [18 x i8] c"Checksum failure\0A\00"
@.str.4 = [23 x i8] c" Ignoring hardlink %s\0A\00"
@.str.5 = [22 x i8] c" Ignoring symlink %s\0A\00"
@.str.6 = [31 x i8] c" Ignoring character device %s\0A\00"
@.str.7 = [27 x i8] c" Ignoring block device %s\0A\00"
@.str.8 = [20 x i8] c" Extracting dir %s\0A\00"
@.str.9 = [19 x i8] c" Ignoring FIFO %s\0A\00"
@.str.10 = [21 x i8] c" Extracting file %s\0A\00"
@.str.11 = [40 x i8] c"Short read on %s: Expected 512, got %d\0A\00"
@.str.12 = [14 x i8] c"Failed write\0A\00"
define void @untar(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca [512 x i8]
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
store i32* null, i32** %6
%9 = load i8*, i8** %4
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %125, %2
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%13 = load i32*, i32** %3
%14 = call i64 @fread(i8* %12, i32 1, i32 512, i32* %13)
store i64 %14, i64* %7
%15 = load i64, i64* %7
%16 = icmp ult i64 %15, 512
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %4
%20 = load i64, i64* %7
%21 = trunc i64 %20 to i32
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %19, i32 %21)
br label %126
23: ; preds = %11
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%25 = call i64 @is_end_of_archive(i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i8*, i8** %4
%29 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %126
30: ; preds = %23
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%32 = call i32 @verify_checksum(i8* %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %126
37: ; preds = %30
%38 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%39 = getelementptr inbounds i8, i8* %38, i64 124
%40 = call i32 @parseoct(i8* %39, i32 12)
store i32 %40, i32* %8
%41 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 156
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
switch i32 %43, label %67 [
i32 49, label %44
i32 50, label %47
i32 51, label %50
i32 52, label %53
i32 53, label %56
i32 54, label %64
]
44: ; preds = %37
%45 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%46 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %45)
br label %75
47: ; preds = %37
%48 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%49 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %48)
br label %75
50: ; preds = %37
%51 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%52 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %51)
br label %75
53: ; preds = %37
%54 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%55 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* %54)
br label %75
56: ; preds = %37
%57 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%58 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %57)
%59 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%60 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%61 = getelementptr inbounds i8, i8* %60, i64 100
%62 = call i32 @parseoct(i8* %61, i32 8)
%63 = call i32 @create_dir(i8* %59, i32 %62)
store i32 0, i32* %8
br label %75
64: ; preds = %37
%65 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%66 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* %65)
br label %75
67: ; preds = %37
%68 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%69 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* %68)
%70 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%71 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%72 = getelementptr inbounds i8, i8* %71, i64 100
%73 = call i32 @parseoct(i8* %72, i32 8)
%74 = call i32* @create_file(i8* %70, i32 %73)
store i32* %74, i32** %6
br label %75
75: ; preds = %67, %64, %56, %53, %50, %47, %44
br label %76
76: ; preds = %113, %75
%77 = load i32, i32* %8
%78 = icmp sgt i32 %77, 0
br i1 %78, label %79, label %119
79: ; preds = %76
%80 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%81 = load i32*, i32** %3
%82 = call i64 @fread(i8* %80, i32 1, i32 512, i32* %81)
store i64 %82, i64* %7
%83 = load i64, i64* %7
%84 = icmp ult i64 %83, 512
br i1 %84, label %85, label %91
85: ; preds = %79
%86 = load i32, i32* @stderr
%87 = load i8*, i8** %4
%88 = load i64, i64* %7
%89 = trunc i64 %88 to i32
%90 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0), i8* %87, i32 %89)
br label %126
91: ; preds = %79
%92 = load i32, i32* %8
%93 = icmp slt i32 %92, 512
br i1 %93, label %94, label %97
94: ; preds = %91
%95 = load i32, i32* %8
%96 = sext i32 %95 to i64
store i64 %96, i64* %7
br label %97
97: ; preds = %94, %91
%98 = load i32*, i32** %6
%99 = icmp ne i32* %98, null
br i1 %99, label %100, label %113
100: ; preds = %97
%101 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%102 = load i64, i64* %7
%103 = load i32*, i32** %6
%104 = call i64 @fwrite(i8* %101, i32 1, i64 %102, i32* %103)
%105 = load i64, i64* %7
%106 = icmp ne i64 %104, %105
br i1 %106, label %107, label %112
107: ; preds = %100
%108 = load i32, i32* @stderr
%109 = call i32 (i32, i8*, ...) @fprintf(i32 %108, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0))
%110 = load i32*, i32** %6
%111 = call i32 @fclose(i32* %110)
store i32* null, i32** %6
br label %112
112: ; preds = %107, %100
br label %113
113: ; preds = %112, %97
%114 = load i64, i64* %7
%115 = load i32, i32* %8
%116 = sext i32 %115 to i64
%117 = sub i64 %116, %114
%118 = trunc i64 %117 to i32
store i32 %118, i32* %8
br label %76
119: ; preds = %76
%120 = load i32*, i32** %6
%121 = icmp ne i32* %120, null
br i1 %121, label %122, label %125
122: ; preds = %119
%123 = load i32*, i32** %6
%124 = call i32 @fclose(i32* %123)
store i32* null, i32** %6
br label %125
125: ; preds = %122, %119
br label %11
126: ; preds = %85, %34, %27, %17
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Extracting from %s\0A\00"
@stderr = global i32 0
@.str.1 = [40 x i8] c"Short read on %s: expected 512, got %d\0A\00"
@.str.2 = [11 x i8] c"End of %s\0A\00"
@.str.3 = [18 x i8] c"Checksum failure\0A\00"
@.str.4 = [23 x i8] c" Ignoring hardlink %s\0A\00"
@.str.5 = [22 x i8] c" Ignoring symlink %s\0A\00"
@.str.6 = [31 x i8] c" Ignoring character device %s\0A\00"
@.str.7 = [27 x i8] c" Ignoring block device %s\0A\00"
@.str.8 = [20 x i8] c" Extracting dir %s\0A\00"
@.str.9 = [19 x i8] c" Ignoring FIFO %s\0A\00"
@.str.10 = [21 x i8] c" Extracting file %s\0A\00"
@.str.11 = [40 x i8] c"Short read on %s: Expected 512, got %d\0A\00"
@.str.12 = [14 x i8] c"Failed write\0A\00"
define void @untar(i32* nocapture %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %1)
%6 = call i64 @fread(i8* %4, i32 1, i32 512, i32* %0)
%7 = icmp ult i64 %6, 512
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 124
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 156
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 100
br label %17
12: ; preds = %84, %2
%13 = phi i64 [ %6, %2 ], [ %85, %84 ]
%14 = load i32, i32* @stderr
%15 = trunc i64 %13 to i32
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %15)
br label %87
17: ; preds = %8, %84
%18 = call i64 @is_end_of_archive(i8* %4)
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %1)
br label %87
22: ; preds = %17
%23 = call i32 @verify_checksum(i8* %4)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %87
28: ; preds = %22
%29 = call i32 @parseoct(i8* %9, i32 12)
%30 = load i8, i8* %10
%31 = sext i8 %30 to i32
switch i32 %31, label %46 [
i32 49, label %32
i32 50, label %34
i32 51, label %36
i32 52, label %38
i32 53, label %40
i32 54, label %44
]
32: ; preds = %28
%33 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %4)
br label %50
34: ; preds = %28
%35 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %4)
br label %50
36: ; preds = %28
%37 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %4)
br label %50
38: ; preds = %28
%39 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8* %4)
br label %50
40: ; preds = %28
%41 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %4)
%42 = call i32 @parseoct(i8* %11, i32 8)
%43 = call i32 @create_dir(i8* %4, i32 %42)
br label %84
44: ; preds = %28
%45 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* %4)
br label %50
46: ; preds = %28
%47 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* %4)
%48 = call i32 @parseoct(i8* %11, i32 8)
%49 = call i32* @create_file(i8* %4, i32 %48)
br label %50
50: ; preds = %46, %44, %38, %36, %34, %32
%51 = phi i32* [ %49, %46 ], [ null, %44 ], [ null, %38 ], [ null, %36 ], [ null, %34 ], [ null, %32 ]
%52 = icmp sgt i32 %29, 0
br i1 %52, label %53, label %79
53: ; preds = %50, %74
%54 = phi i32 [ %77, %74 ], [ %29, %50 ]
%55 = phi i32* [ %75, %74 ], [ %51, %50 ]
%56 = call i64 @fread(i8* %4, i32 1, i32 512, i32* %0)
%57 = icmp ult i64 %56, 512
br i1 %57, label %58, label %62
58: ; preds = %53
%59 = load i32, i32* @stderr
%60 = trunc i64 %56 to i32
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0), i8* %1, i32 %60)
br label %87
62: ; preds = %53
%63 = icmp ult i32 %54, 512
%64 = zext i32 %54 to i64
%65 = select i1 %63, i64 %64, i64 %56
%66 = icmp eq i32* %55, null
br i1 %66, label %74, label %67
67: ; preds = %62
%68 = call i64 @fwrite(i8* %4, i32 1, i64 %65, i32* %55)
%69 = icmp eq i64 %68, %65
br i1 %69, label %74, label %70
70: ; preds = %67
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0))
%73 = call i32 @fclose(i32* %55)
br label %74
74: ; preds = %67, %70, %62
%75 = phi i32* [ null, %70 ], [ %55, %67 ], [ null, %62 ]
%76 = trunc i64 %65 to i32
%77 = sub i32 %54, %76
%78 = icmp sgt i32 %77, 0
br i1 %78, label %53, label %79
79: ; preds = %74, %50
%80 = phi i32* [ %51, %50 ], [ %75, %74 ]
%81 = icmp eq i32* %80, null
br i1 %81, label %84, label %82
82: ; preds = %79
%83 = call i32 @fclose(i32* %80)
br label %84
84: ; preds = %40, %82, %79
%85 = call i64 @fread(i8* %4, i32 1, i32 512, i32* %0)
%86 = icmp ult i64 %85, 512
br i1 %86, label %12, label %17
87: ; preds = %58, %25, %20, %12
ret void
}