#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 */

/* Variables and functions */
int read(int, char *, int);
int write_buffer(int, char *, int);
int forward_ssh_data(int from_sock, int to_sock) {
  int bytes_read;
  char buffer[16384];
  if ((bytes_read = read(from_sock, buffer, 16384)) <= 0) {
    return -1;
  }
  if (write_buffer(to_sock, buffer, bytes_read) == -1) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<forward_ssh_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4010,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x4010(%rbp),%rsi
mov    $0x4000,%edx
call   1040 <read@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jg     115d <forward_ssh_data+0x3d>
movl   $0xffffffff,-0x4(%rbp)
jmp    118b <forward_ssh_data+0x6b>
mov    -0xc(%rbp),%edi
lea    -0x4010(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1030 <write_buffer@plt>
cmp    $0xffffffff,%eax
jne    1184 <forward_ssh_data+0x64>
movl   $0xffffffff,-0x4(%rbp)
jmp    118b <forward_ssh_data+0x6b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<forward_ssh_data>:
push   %rbx
sub    $0x4000,%rsp
mov    %esi,%ebx
mov    %rsp,%rsi
mov    $0x4000,%edx
call   1040 <read@plt>
test   %eax,%eax
jle    1155 <forward_ssh_data+0x35>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1030 <write_buffer@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
sete   %al
neg    %eax
jmp    115a <forward_ssh_data+0x3a>
mov    $0xffffffff,%eax
add    $0x4000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @forward_ssh_data(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [16384 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = load i32, i32* %4
%9 = getelementptr inbounds [16384 x i8], [16384 x i8]* %7, i64 0, i64 0
%10 = call i32 @read(i32 %8, i8* %9, i32 16384)
store i32 %10, i32* %6
%11 = icmp sle i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 -1, i32* %3
br label %21
13: ; preds = %2
%14 = load i32, i32* %5
%15 = getelementptr inbounds [16384 x i8], [16384 x i8]* %7, i64 0, i64 0
%16 = load i32, i32* %6
%17 = call i32 @write_buffer(i32 %14, i8* %15, i32 %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %20
19: ; preds = %13
store i32 -1, i32* %3
br label %21
20: ; preds = %13
store i32 0, i32* %3
br label %21
21: ; preds = %20, %19, %12
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
define i32 @forward_ssh_data(i32 %0, i32 %1) {
%3 = alloca [16384 x i8]
%4 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 0
%5 = call i32 @read(i32 %0, i8* %4, i32 16384)
%6 = icmp slt i32 %5, 1
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = call i32 @write_buffer(i32 %1, i8* %4, i32 %5)
%9 = icmp eq i32 %8, -1
%10 = sext i1 %9 to i32
br label %11
11: ; preds = %7, %2
%12 = phi i32 [ -1, %2 ], [ %10, %7 ]
ret i32 %12
}