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

/* Variables and functions */
int BUFSIZ;
int _tar_error(char const *, int);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fputc(char, int /*<<< orphan*/ *);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
size_t fwrite(char *, int, size_t, int /*<<< orphan*/ *);
int _doc_normal(FILE *fp, char const *archive, FILE *fp2,
                char const *filename) {
  int ret = 0;
  size_t read;
  size_t cnt;
  char buf[BUFSIZ];
  for (cnt = 0; (read = fread(buf, sizeof(*buf), sizeof(buf), fp2)) != 0;
       cnt += read)
    if (fwrite(buf, sizeof(*buf), read, fp) != read) {
      ret = _tar_error(archive, 1);
      break;
    }
  if (ret == 0 && read == 0 && !feof(fp2))
    return _tar_error(filename, 1);
  for (cnt = 512 - (cnt % 512); cnt > 0 && fputc('\0', fp) == '\0'; cnt--)
    ;
  return (cnt == 0) ? 0 : _tar_error(archive, 1);
}


x86 assembly (clang, -O0):
<_doc_normal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x68(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x50(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x68(%rbp),%rax
mov    %eax,%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     1219 <_doc_normal+0xc9>
mov    -0x60(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1070 <fwrite@plt>
cmp    -0x38(%rbp),%rax
je     1203 <_doc_normal+0xb3>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   1030 <_tar_error@plt>
mov    %eax,-0x2c(%rbp)
jmp    1219 <_doc_normal+0xc9>
jmp    1208 <_doc_normal+0xb8>
mov    -0x38(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    11a7 <_doc_normal+0x57>
cmpl   $0x0,-0x2c(%rbp)
jne    125d <_doc_normal+0x10d>
cmpq   $0x0,-0x38(%rbp)
jne    125d <_doc_normal+0x10d>
mov    -0x20(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
jne    125d <_doc_normal+0x10d>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
call   1030 <_tar_error@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
jmp    12f4 <_doc_normal+0x1a4>
mov    -0x40(%rbp),%rcx
and    $0x1ff,%rcx
mov    $0x200,%eax
sub    %rcx,%rax
mov    %rax,-0x40(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x40(%rbp)
mov    %al,-0x69(%rbp)
jbe    129b <_doc_normal+0x14b>
mov    -0x10(%rbp),%rsi
xor    %edi,%edi
call   1050 <fputc@plt>
movsbl %al,%eax
cmp    $0x0,%eax
sete   %al
mov    %al,-0x69(%rbp)
mov    -0x69(%rbp),%al
test   $0x1,%al
jne    12ab <_doc_normal+0x15b>
jmp    12c1 <_doc_normal+0x171>
jmp    12b0 <_doc_normal+0x160>
mov    -0x40(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x40(%rbp)
jmp    1274 <_doc_normal+0x124>
cmpq   $0x0,-0x40(%rbp)
jne    12d6 <_doc_normal+0x186>
xor    %eax,%eax
mov    %eax,-0x70(%rbp)
jmp    12e7 <_doc_normal+0x197>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   1030 <_tar_error@plt>
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_doc_normal>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,-0x40(%rbp)
mov    %rdx,%rcx
mov    %rsi,-0x30(%rbp)
mov    %rdi,%rbx
mov    0x2e6a(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%r14
mov    %rdx,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %r14,%rdi
mov    $0x1,%esi
mov    %rdx,%r13
mov    %rcx,-0x38(%rbp)
call   1040 <fread@plt>
test   %rax,%rax
je     11e9 <_doc_normal+0x99>
mov    %rax,%r15
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
cmp    %r15,%rax
jne    11ff <_doc_normal+0xaf>
add    %r15,%r12
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r13d,%edx
mov    -0x38(%rbp),%rcx
call   1040 <fread@plt>
mov    %rax,%r15
test   %rax,%rax
jne    11b0 <_doc_normal+0x60>
jmp    11ec <_doc_normal+0x9c>
xor    %r12d,%r12d
mov    -0x38(%rbp),%rdi
call   1060 <feof@plt>
test   %eax,%eax
mov    -0x40(%rbp),%rdi
jne    120d <_doc_normal+0xbd>
jmp    1248 <_doc_normal+0xf8>
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
call   1030 <_tar_error@plt>
or     $0xfffffffffffffe00,%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
test   %al,%al
jne    1244 <_doc_normal+0xf4>
inc    %r12
jne    1220 <_doc_normal+0xd0>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    -0x30(%rbp),%rdi
mov    $0x1,%esi
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <_tar_error@plt>

LLVM IR (-O0):
@BUFSIZ = global i32 0
define i32 @_doc_normal(i32* %0, i8* %1, i32* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
store i32* %0, i32** %6
store i8* %1, i8** %7
store i32* %2, i32** %8
store i8* %3, i8** %9
store i32 0, i32* %10
%16 = load i32, i32* @BUFSIZ
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %13
%19 = alloca i8, i64 %17
store i64 %17, i64* %14
store i64 0, i64* %12
br label %20
20: ; preds = %35, %4
%21 = trunc i64 %17 to i32
%22 = load i32*, i32** %8
%23 = call i64 @fread(i8* %19, i32 1, i32 %21, i32* %22)
store i64 %23, i64* %11
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %39
25: ; preds = %20
%26 = load i64, i64* %11
%27 = load i32*, i32** %6
%28 = call i64 @fwrite(i8* %19, i32 1, i64 %26, i32* %27)
%29 = load i64, i64* %11
%30 = icmp ne i64 %28, %29
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = load i8*, i8** %7
%33 = call i32 @_tar_error(i8* %32, i32 1)
store i32 %33, i32* %10
br label %39
34: ; preds = %25
br label %35
35: ; preds = %34
%36 = load i64, i64* %11
%37 = load i64, i64* %12
%38 = add i64 %37, %36
store i64 %38, i64* %12
br label %20
39: ; preds = %31, %20
%40 = load i32, i32* %10
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %52
42: ; preds = %39
%43 = load i64, i64* %11
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %52
45: ; preds = %42
%46 = load i32*, i32** %8
%47 = call i32 @feof(i32* %46)
%48 = icmp ne i32 %47, 0
br i1 %48, label %52, label %49
49: ; preds = %45
%50 = load i8*, i8** %9
%51 = call i32 @_tar_error(i8* %50, i32 1)
store i32 %51, i32* %5
store i32 1, i32* %15
br label %79
52: ; preds = %45, %42, %39
%53 = load i64, i64* %12
%54 = urem i64 %53, 512
%55 = sub i64 512, %54
store i64 %55, i64* %12
br label %56
56: ; preds = %67, %52
%57 = load i64, i64* %12
%58 = icmp ugt i64 %57, 0
br i1 %58, label %59, label %64
59: ; preds = %56
%60 = load i32*, i32** %6
%61 = call signext i8 @fputc(i8 signext 0, i32* %60)
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 0
br label %64
64: ; preds = %59, %56
%65 = phi i1 [ false, %56 ], [ %63, %59 ]
br i1 %65, label %66, label %70
66: ; preds = %64
br label %67
67: ; preds = %66
%68 = load i64, i64* %12
%69 = add i64 %68, -1
store i64 %69, i64* %12
br label %56
70: ; preds = %64
%71 = load i64, i64* %12
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %70
br label %77
74: ; preds = %70
%75 = load i8*, i8** %7
%76 = call i32 @_tar_error(i8* %75, i32 1)
br label %77
77: ; preds = %74, %73
%78 = phi i32 [ 0, %73 ], [ %76, %74 ]
store i32 %78, i32* %5
store i32 1, i32* %15
br label %79
79: ; preds = %77, %49
%80 = load i8*, i8** %13
%81 = load i32, i32* %5
ret i32 %81
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
define i32 @_doc_normal(i32* nocapture %0, i8* %1, i32* nocapture %2, i8* %3) {
%5 = load i32, i32* @BUFSIZ
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = call i64 @fread(i8* %7, i32 1, i32 %5, i32* %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %21, label %13
10: ; preds = %13
%11 = call i64 @fread(i8* %7, i32 1, i32 %5, i32* %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %4, %10
%14 = phi i64 [ %11, %10 ], [ %8, %4 ]
%15 = phi i64 [ %18, %10 ], [ 0, %4 ]
%16 = call i64 @fwrite(i8* %7, i32 1, i64 %14, i32* %0)
%17 = icmp eq i64 %16, %14
%18 = add i64 %14, %15
br i1 %17, label %10, label %19
19: ; preds = %13
%20 = tail call i32 @_tar_error(i8* %1, i32 1)
br label %25
21: ; preds = %10, %4
%22 = phi i64 [ 0, %4 ], [ %18, %10 ]
%23 = tail call i32 @feof(i32* %2)
%24 = icmp eq i32 %23, 0
br i1 %24, label %36, label %25
25: ; preds = %21, %19
%26 = phi i64 [ %15, %19 ], [ %22, %21 ]
%27 = and i64 %26, 511
%28 = sub nuw nsw i64 512, %27
br label %31
29: ; preds = %31
%30 = icmp eq i64 %35, 0
br i1 %30, label %39, label %31
31: ; preds = %25, %29
%32 = phi i64 [ %35, %29 ], [ %28, %25 ]
%33 = tail call signext i8 @fputc(i8 signext 0, i32* %0)
%34 = icmp eq i8 %33, 0
%35 = add nsw i64 %32, -1
br i1 %34, label %29, label %36
36: ; preds = %31, %21
%37 = phi i8* [ %3, %21 ], [ %1, %31 ]
%38 = tail call i32 @_tar_error(i8* %37, i32 1)
br label %39
39: ; preds = %29, %36
%40 = phi i32 [ %38, %36 ], [ 0, %29 ]
ret i32 %40
}