#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*/ SEEK_SET;
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(void *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ makeStrFromInt(int, char *);
int /*<<< orphan*/ pastShield(char *);
int strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int /*<<< orphan*/ write(int, char *, int);
int pull(int sock, char *file) {
  FILE *fp;
  if ((fp = fopen(file, "rb")) == NULL) {
    write(sock, "n", 1);
    return 0;
  }
  write(sock, "y", 1);
  int size = 0;
  char sendbuff[256];
  bzero(sendbuff, 256);
  fseek(fp, 0, SEEK_SET);
  while (!feof(fp)) {
    size = (int)fread((void *)sendbuff, sizeof(char), 256, fp);
    if (!(strncmp(sendbuff, "_end_of_file", 256)))
      pastShield(sendbuff);
    char p[3];
    makeStrFromInt(size, p);
    write(sock, p, 3);
    write(sock, sendbuff, size);
  }
  char strLength[3];
  makeStrFromInt(strlen("_end_of_file"), strLength);
  write(sock, strLength, 3);
  write(sock, "_end_of_file", strlen("_end_of_file"));
  fclose(fp);
  return 1;
}


x86 assembly (clang, -O0):
<pull>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1200 <pull+0x50>
mov    -0x8(%rbp),%edi
lea    0xe19(%rip),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
movl   $0x0,-0x4(%rbp)
jmp    1349 <pull+0x199>
mov    -0x8(%rbp),%edi
lea    0xdfb(%rip),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
movl   $0x0,-0x1c(%rbp)
lea    -0x120(%rbp),%rdi
mov    $0x100,%esi
call   10c0 <bzero@plt>
mov    -0x18(%rbp),%rdi
mov    0x2da9(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    125e <pull+0xae>
jmp    12e2 <pull+0x132>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x100,%edx
call   1040 <fread@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x120(%rbp),%rdi
lea    0xd7e(%rip),%rsi
mov    $0x100,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12a8 <pull+0xf8>
lea    -0x120(%rbp),%rdi
call   10d0 <pastShield@plt>
mov    -0x1c(%rbp),%edi
lea    -0x123(%rbp),%rsi
call   1080 <makeStrFromInt@plt>
mov    -0x8(%rbp),%edi
lea    -0x123(%rbp),%rsi
mov    $0x3,%edx
call   1050 <write@plt>
mov    -0x8(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <write@plt>
jmp    1240 <pull+0x90>
lea    0xd1e(%rip),%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
lea    -0x126(%rbp),%rsi
call   1080 <makeStrFromInt@plt>
mov    -0x8(%rbp),%edi
lea    -0x126(%rbp),%rsi
mov    $0x3,%edx
call   1050 <write@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x12c(%rbp)
lea    0xce7(%rip),%rdi
call   1070 <strlen@plt>
mov    -0x12c(%rbp),%edi
mov    %eax,%edx
lea    0xcd3(%rip),%rsi
call   1050 <write@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pull>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rax
mov    %edi,%r15d
lea    0xe32(%rip),%rsi
mov    %rax,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1276 <pull+0xc6>
mov    %rax,%rbp
lea    0xe1c(%rip),%rsi
mov    %r15d,%edi
mov    $0x1,%edx
call   1050 <write@plt>
lea    0x10(%rsp),%rdi
mov    $0x100,%esi
call   10c0 <bzero@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10a0 <fseek@plt>
mov    %rbp,%rdi
call   1090 <feof@plt>
test   %eax,%eax
je     129e <pull+0xee>
lea    0xddc(%rip),%r14
mov    %r14,%rdi
call   1070 <strlen@plt>
lea    0xd(%rsp),%rbx
mov    %eax,%edi
mov    %rbx,%rsi
call   1080 <makeStrFromInt@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1050 <write@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
mov    $0x1,%eax
jmp    128c <pull+0xdc>
lea    0xd86(%rip),%rsi
mov    %r15d,%edi
mov    $0x1,%edx
call   1050 <write@plt>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%rbx
lea    0xd5d(%rip),%r12
lea    0xd(%rsp),%r13
jmp    12f9 <pull+0x149>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %r13,%rsi
call   1080 <makeStrFromInt@plt>
mov    %r15d,%edi
mov    %r13,%rsi
mov    $0x3,%edx
call   1050 <write@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1050 <write@plt>
mov    %rbp,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    1224 <pull+0x74>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x100,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x100,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    12c0 <pull+0x110>
mov    %rbx,%rdi
call   10d0 <pastShield@plt>
jmp    12c0 <pull+0x110>

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

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [2 x i8] c"n\00"
@.str.2 = [2 x i8] c"y\00"
@SEEK_SET = global i32 0
@.str.3 = [13 x i8] c"_end_of_file\00"
define i32 @pull(i32 %0, i8* nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [3 x i8]
%5 = alloca [3 x i8]
%6 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = 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 %41
10: ; preds = %2
%11 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%13 = call i32 @bzero(i8* %12, i32 256)
%14 = load i32, i32* @SEEK_SET
%15 = tail call i32 @fseek(i32* %6, i32 0, i32 %14)
%16 = call i32 @feof(i32* %6)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %33
18: ; preds = %10
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
br label %20
20: ; preds = %18, %27
%21 = call i64 @fread(i8* %12, i32 1, i32 256, i32* %6)
%22 = trunc i64 %21 to i32
%23 = call i32 @strncmp(i8* %12, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 256)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 @pastShield(i8* %12)
br label %27
27: ; preds = %25, %20
%28 = call i32 @makeStrFromInt(i32 %22, i8* %19)
%29 = call i32 @write(i32 %0, i8* %19, i32 3)
%30 = call i32 @write(i32 %0, i8* %12, i32 %22)
%31 = call i32 @feof(i32* %6)
%32 = icmp eq i32 %31, 0
br i1 %32, label %20, label %33
33: ; preds = %27, %10
%34 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%35 = call i32 @strlen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%36 = call i32 @makeStrFromInt(i32 %35, i8* %34)
%37 = call i32 @write(i32 %0, i8* %34, i32 3)
%38 = call i32 @strlen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%39 = call i32 @write(i32 %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%40 = call i32 @fclose(i32* %6)
br label %41
41: ; preds = %33, %8
%42 = phi i32 [ 0, %8 ], [ 1, %33 ]
ret i32 %42
}