#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 /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
void transmit_file(int s, FILE *file) {
  char buf[9000];
  fgets(buf, sizeof(buf), file);
  while (!feof(file)) {
    send(s, buf, strlen(buf), 0);
    fgets(buf, sizeof(buf), file);
  }
}


x86 assembly (clang, -O0):
<transmit_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2350,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x2340(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2328,%esi
call   1050 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1185 <transmit_file+0x45>
jmp    11d8 <transmit_file+0x98>
mov    -0x4(%rbp),%eax
mov    %eax,-0x234c(%rbp)
lea    -0x2340(%rbp),%rax
mov    %rax,-0x2348(%rbp)
lea    -0x2340(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x234c(%rbp),%edi
mov    -0x2348(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
lea    -0x2340(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2328,%esi
call   1050 <fgets@plt>
jmp    1167 <transmit_file+0x27>
add    $0x2350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transmit_file>:
push   %rbp
push   %r14
push   %rbx
sub    $0x2330,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %rsp,%rdi
mov    $0x2328,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11a3 <transmit_file+0x63>
mov    %rsp,%rbp
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %rbp,%rdi
mov    $0x2328,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     1170 <transmit_file+0x30>
add    $0x2330,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @transmit_file(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca [9000 x i8]
store i32 %0, i32* %3
store i32* %1, i32** %4
%6 = getelementptr inbounds [9000 x i8], [9000 x i8]* %5, i64 0, i64 0
%7 = load i32*, i32** %4
%8 = call i32 @fgets(i8* %6, i32 9000, i32* %7)
br label %9
9: ; preds = %14, %2
%10 = load i32*, i32** %4
%11 = call i32 @feof(i32* %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %23
14: ; preds = %9
%15 = load i32, i32* %3
%16 = getelementptr inbounds [9000 x i8], [9000 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [9000 x i8], [9000 x i8]* %5, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = call i32 @send(i32 %15, i8* %16, i32 %18, i32 0)
%20 = getelementptr inbounds [9000 x i8], [9000 x i8]* %5, i64 0, i64 0
%21 = load i32*, i32** %4
%22 = call i32 @fgets(i8* %20, i32 9000, i32* %21)
br label %9
23: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @transmit_file(i32 %0, i32* nocapture %1) {
%3 = alloca [9000 x i8]
%4 = getelementptr inbounds [9000 x i8], [9000 x i8]* %3, i64 0, i64 0
%5 = call i32 @fgets(i8* %4, i32 9000, i32* %1)
%6 = call i32 @feof(i32* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %2, %8
%9 = call i32 @strlen(i8* %4)
%10 = call i32 @send(i32 %0, i8* %4, i32 %9, i32 0)
%11 = call i32 @fgets(i8* %4, i32 9000, i32* %1)
%12 = call i32 @feof(i32* %1)
%13 = icmp eq i32 %12, 0
br i1 %13, label %8, label %14
14: ; preds = %8, %2
ret void
}