#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 /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ write(int, char *, int);
int smtp_sendData(int socket) {
  char buf[1024];
  int len;
  do {
    len = read(0, buf, 1024);
    write(socket, buf, len);
    memset(buf, 0, 1024);
  } while (len == 1024);
  write(socket, "\r\n.\r\n", 5);
}


x86 assembly (clang, -O0):
<smtp_sendData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x410(%rbp),%rsi
xor    %edi,%edi
mov    $0x400,%edx
call   1050 <read@plt>
mov    %eax,-0x414(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    -0x414(%rbp),%edx
call   1030 <write@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
cmpl   $0x400,-0x414(%rbp)
je     113e <smtp_sendData+0xe>
mov    -0x8(%rbp),%edi
lea    0xe67(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smtp_sendData>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %edi,%r14d
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1050 <read@plt>
mov    %eax,%ebp
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
cmp    $0x400,%ebp
je     1150 <smtp_sendData+0x20>
lea    0xe74(%rip),%rsi
mov    %r14d,%edi
mov    $0x5,%edx
call   1030 <write@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"\0D\0A.\0D\0A\00"
define i32 @smtp_sendData(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1024 x i8]
%5 = alloca i32
store i32 %0, i32* %3
br label %6
6: ; preds = %15, %1
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = call i32 @read(i32 0, i8* %7, i32 1024)
store i32 %8, i32* %5
%9 = load i32, i32* %3
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%11 = load i32, i32* %5
%12 = call i32 @write(i32 %9, i8* %10, i32 %11)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%14 = call i32 @memset(i8* %13, i32 0, i32 1024)
br label %15
15: ; preds = %6
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 1024
br i1 %17, label %6, label %18
18: ; preds = %15
%19 = load i32, i32* %3
%20 = call i32 @write(i32 %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@.str = [6 x i8] c"\0D\0A.\0D\0A\00"
define i32 @smtp_sendData(i32 %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %4, %1
%5 = call i32 @read(i32 0, i8* %3, i32 1024)
%6 = call i32 @write(i32 %0, i8* %3, i32 %5)
%7 = call i32 @memset(i8* %3, i32 0, i32 1024)
%8 = icmp eq i32 %5, 1024
br i1 %8, label %4, label %9
9: ; preds = %4
%10 = call i32 @write(i32 %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
ret i32 undef
}