#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;
  size_t iov_len;
};
struct fetch_connect {
  int dummy;
};

/* Variables and functions */
scalar_t__ __UNCONST(char const *);
int fetch_writev(struct fetch_connect *, struct iovec *, int);
int fetch_write(struct fetch_connect *conn, const char *str, size_t len) {
  struct iovec iov[1];
  iov[0].iov_base = (char *)__UNCONST(str);
  iov[0].iov_len = len;
  return fetch_writev(conn, iov, 1);
}


x86 assembly (clang, -O0):
<fetch_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <__UNCONST@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x1,%edx
call   1030 <fetch_writev@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fetch_write>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <__UNCONST@plt>
mov    %rax,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %rsp,%rsi
mov    %r14,%rdi
mov    $0x1,%edx
call   1030 <fetch_writev@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.fetch_connect = type { i32 }
%struct.iovec = type { i8*, i64 }
define i32 @fetch_write(%struct.fetch_connect* %0, i8* %1, i64 %2) {
%4 = alloca %struct.fetch_connect*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [1 x %struct.iovec]
store %struct.fetch_connect* %0, %struct.fetch_connect** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load i8*, i8** %5
%9 = call i64 @__UNCONST(i8* %8)
%10 = inttoptr i64 %9 to i8*
%11 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %7, i64 0, i64 0
%12 = getelementptr inbounds %struct.iovec, %struct.iovec* %11, i32 0, i32 0
store i8* %10, i8** %12
%13 = load i64, i64* %6
%14 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %7, i64 0, i64 0
%15 = getelementptr inbounds %struct.iovec, %struct.iovec* %14, i32 0, i32 1
store i64 %13, i64* %15
%16 = load %struct.fetch_connect*, %struct.fetch_connect** %4
%17 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %7, i64 0, i64 0
%18 = call i32 @fetch_writev(%struct.fetch_connect* %16, %struct.iovec* %17, i32 1)
ret i32 %18
}

LLVM IR (-O2):
%struct.fetch_connect = type { i32 }
%struct.iovec = type { i8*, i64 }
define i32 @fetch_write(%struct.fetch_connect* %0, i8* %1, i64 %2) {
%4 = alloca [1 x %struct.iovec]
%5 = bitcast [1 x %struct.iovec]* %4 to i8*
%6 = tail call i64 @__UNCONST(i8* %1)
%7 = inttoptr i64 %6 to i8*
%8 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %4, i64 0, i64 0
%9 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %4, i64 0, i64 0, i32 0
store i8* %7, i8** %9
%10 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %4, i64 0, i64 0, i32 1
store i64 %2, i64* %10
%11 = call i32 @fetch_writev(%struct.fetch_connect* %0, %struct.iovec* %8, i32 1)
ret i32 %11
}