#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 atoi(char *);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ deleteShield(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(void *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ readn(int, char *, int);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ write(int, char *, int);
int push(int sock, char *path) {
  int size;
  FILE *fp;
  if ((fp = fopen(path, "wb")) == NULL) {
    write(sock, "n", 1);
    return 0;
  }
  write(sock, "y", 1);
  char buffer[256];
  bzero(buffer, 256);
  readn(sock, buffer, 3);
  size = atoi(buffer);
  bzero(buffer, 256);
  readn(sock, buffer, size);
  while (strncmp(buffer, "_end_of_file", 256)) {
    if (!(strncmp(buffer, "/_end_of_file", 256)))
      deleteShield(buffer);
    fwrite((void *)buffer, sizeof(char), size, fp);
    bzero(buffer, 256);
    readn(sock, buffer, 3);
    size = atoi(buffer);
    bzero(buffer, 256);
    readn(sock, buffer, size);
  }
  fflush(fp);
  fclose(fp);
  return 1;
}


x86 assembly (clang, -O0):
<push>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11f0 <push+0x50>
mov    -0x8(%rbp),%edi
lea    0xe29(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
movl   $0x0,-0x4(%rbp)
jmp    1338 <push+0x198>
mov    -0x8(%rbp),%edi
lea    0xe0b(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
lea    -0x120(%rbp),%rdi
mov    $0x100,%esi
call   10a0 <bzero@plt>
mov    -0x8(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    $0x3,%edx
call   1060 <readn@plt>
lea    -0x120(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    -0x120(%rbp),%rdi
mov    $0x100,%esi
call   10a0 <bzero@plt>
mov    -0x8(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <readn@plt>
lea    -0x120(%rbp),%rdi
lea    0xd9f(%rip),%rsi
mov    $0x100,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     131f <push+0x17f>
lea    -0x120(%rbp),%rdi
lea    0xd7c(%rip),%rsi
mov    $0x100,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12ab <push+0x10b>
lea    -0x120(%rbp),%rdi
call   1080 <deleteShield@plt>
lea    -0x120(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   10c0 <fwrite@plt>
lea    -0x120(%rbp),%rdi
mov    $0x100,%esi
call   10a0 <bzero@plt>
mov    -0x8(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    $0x3,%edx
call   1060 <readn@plt>
lea    -0x120(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    -0x120(%rbp),%rdi
mov    $0x100,%esi
call   10a0 <bzero@plt>
mov    -0x8(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <readn@plt>
jmp    125b <push+0xbb>
mov    -0x20(%rbp),%rdi
call   1070 <fflush@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<push>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%rax
mov    %edi,%r13d
lea    0xe42(%rip),%rsi
mov    %rax,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1301 <push+0x161>
mov    %rax,%r15
lea    0xe2c(%rip),%rsi
mov    %r13d,%edi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   10a0 <bzero@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1060 <readn@plt>
mov    %rbx,%rdi
call   10b0 <atoi@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    $0x100,%esi
call   10a0 <bzero@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1060 <readn@plt>
lea    0xdd7(%rip),%rsi
mov    %rbx,%rdi
mov    $0x100,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12ea <push+0x14a>
lea    0xdb9(%rip),%r12
mov    %rsp,%rbx
lea    0xdb0(%rip),%r14
jmp    12c8 <push+0x128>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r15,%rcx
call   10c0 <fwrite@plt>
mov    %rbx,%rdi
mov    $0x100,%esi
call   10a0 <bzero@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1060 <readn@plt>
mov    %rbx,%rdi
call   10b0 <atoi@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    $0x100,%esi
call   10a0 <bzero@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1060 <readn@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x100,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12ea <push+0x14a>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x100,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1260 <push+0xc0>
mov    %rbx,%rdi
call   1080 <deleteShield@plt>
jmp    1260 <push+0xc0>
mov    %r15,%rdi
call   1070 <fflush@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    $0x1,%eax
jmp    1317 <push+0x177>
lea    0xcfb(%rip),%rsi
mov    %r13d,%edi
mov    $0x1,%edx
call   1040 <write@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"wb\00"
@.str.1 = [2 x i8] c"n\00"
@.str.2 = [2 x i8] c"y\00"
@.str.3 = [13 x i8] c"_end_of_file\00"
@.str.4 = [14 x i8] c"/_end_of_file\00"
define i32 @push(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca [256 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %7
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* %4
%14 = call i32 @write(i32 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
store i32 0, i32* %3
br label %65
15: ; preds = %2
%16 = load i32, i32* %4
%17 = call i32 @write(i32 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%19 = call i32 @bzero(i8* %18, i32 256)
%20 = load i32, i32* %4
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%22 = call i32 @readn(i32 %20, i8* %21, i32 3)
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %6
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%26 = call i32 @bzero(i8* %25, i32 256)
%27 = load i32, i32* %4
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%29 = load i32, i32* %6
%30 = call i32 @readn(i32 %27, i8* %28, i32 %29)
br label %31
31: ; preds = %42, %15
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%33 = call i64 @strncmp(i8* %32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 256)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %60
35: ; preds = %31
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%37 = call i64 @strncmp(i8* %36, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 256)
%38 = icmp ne i64 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %35
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%41 = call i32 @deleteShield(i8* %40)
br label %42
42: ; preds = %39, %35
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%44 = load i32, i32* %6
%45 = load i32*, i32** %7
%46 = call i32 @fwrite(i8* %43, i32 1, i32 %44, i32* %45)
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%48 = call i32 @bzero(i8* %47, i32 256)
%49 = load i32, i32* %4
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%51 = call i32 @readn(i32 %49, i8* %50, i32 3)
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%53 = call i32 @atoi(i8* %52)
store i32 %53, i32* %6
%54 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%55 = call i32 @bzero(i8* %54, i32 256)
%56 = load i32, i32* %4
%57 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%58 = load i32, i32* %6
%59 = call i32 @readn(i32 %56, i8* %57, i32 %58)
br label %31
60: ; preds = %31
%61 = load i32*, i32** %7
%62 = call i32 @fflush(i32* %61)
%63 = load i32*, i32** %7
%64 = call i32 @fclose(i32* %63)
store i32 1, i32* %3
br label %65
65: ; preds = %60, %12
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@.str = [3 x i8] c"wb\00"
@.str.1 = [2 x i8] c"n\00"
@.str.2 = [2 x i8] c"y\00"
@.str.3 = [13 x i8] c"_end_of_file\00"
@.str.4 = [14 x i8] c"/_end_of_file\00"
define i32 @push(i32 %0, i8* nocapture %1) {
%3 = alloca [256 x i8]
%4 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %36
8: ; preds = %2
%9 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%11 = call i32 @bzero(i8* %10, i32 256)
%12 = call i32 @readn(i32 %0, i8* %10, i32 3)
%13 = call i32 @atoi(i8* %10)
%14 = call i32 @bzero(i8* %10, i32 256)
%15 = call i32 @readn(i32 %0, i8* %10, i32 %13)
%16 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 256)
%17 = icmp eq i64 %16, 0
br i1 %17, label %33, label %18
18: ; preds = %8, %24
%19 = phi i32 [ %28, %24 ], [ %13, %8 ]
%20 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 256)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @deleteShield(i8* %10)
br label %24
24: ; preds = %22, %18
%25 = call i32 @fwrite(i8* %10, i32 1, i32 %19, i32* %4)
%26 = call i32 @bzero(i8* %10, i32 256)
%27 = call i32 @readn(i32 %0, i8* %10, i32 3)
%28 = call i32 @atoi(i8* %10)
%29 = call i32 @bzero(i8* %10, i32 256)
%30 = call i32 @readn(i32 %0, i8* %10, i32 %28)
%31 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 256)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %18
33: ; preds = %24, %8
%34 = call i32 @fflush(i32* %4)
%35 = call i32 @fclose(i32* %4)
br label %36
36: ; preds = %33, %6
%37 = phi i32 [ 0, %6 ], [ 1, %33 ]
ret i32 %37
}