#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 */
struct iovec {
  char *iov_base;
  int iov_len;
};

/* Variables and functions */
int strlen(char *);
int /*<<< orphan*/ writev(int, struct iovec *, int);
void sendline(int sock, char *dataline) {
  struct iovec iov[2];
  iov[0].iov_base = dataline;
  iov[0].iov_len = strlen(dataline);
  iov[1].iov_base = "\r\n";
  iov[1].iov_len = 2;
  writev(sock, iov, 2);
}


x86 assembly (clang, -O0):
<sendline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x28(%rbp)
lea    0xeb6(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x2,%edx
call   1030 <writev@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendline>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
mov    %rsi,(%rsp)
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,0x8(%rsp)
lea    0xec2(%rip),%rax
mov    %rax,0x10(%rsp)
movl   $0x2,0x18(%rsp)
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x2,%edx
call   1030 <writev@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.iovec = type { i8*, i32 }
@.str = [3 x i8] c"\0D\0A\00"
define void @sendline(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [2 x %struct.iovec]
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %5, i64 0, i64 0
%8 = getelementptr inbounds %struct.iovec, %struct.iovec* %7, i32 0, i32 0
store i8* %6, i8** %8
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %5, i64 0, i64 0
%12 = getelementptr inbounds %struct.iovec, %struct.iovec* %11, i32 0, i32 1
store i32 %10, i32* %12
%13 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %5, i64 0, i64 1
%14 = getelementptr inbounds %struct.iovec, %struct.iovec* %13, i32 0, i32 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %14
%15 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %5, i64 0, i64 1
%16 = getelementptr inbounds %struct.iovec, %struct.iovec* %15, i32 0, i32 1
store i32 2, i32* %16
%17 = load i32, i32* %3
%18 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %5, i64 0, i64 0
%19 = call i32 @writev(i32 %17, %struct.iovec* %18, i32 2)
ret void
}

LLVM IR (-O2):
%struct.iovec = type { i8*, i32 }
@.str = [3 x i8] c"\0D\0A\00"
define void @sendline(i32 %0, i8* %1) {
%3 = alloca [2 x %struct.iovec]
%4 = bitcast [2 x %struct.iovec]* %3 to i8*
%5 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %3, i64 0, i64 0
%6 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %3, i64 0, i64 0, i32 0
store i8* %1, i8** %6
%7 = tail call i32 @strlen(i8* %1)
%8 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %3, i64 0, i64 0, i32 1
store i32 %7, i32* %8
%9 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %3, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [2 x %struct.iovec], [2 x %struct.iovec]* %3, i64 0, i64 1, i32 1
store i32 2, i32* %10
%11 = call i32 @writev(i32 %0, %struct.iovec* %5, i32 2)
ret void
}