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

/* Variables and functions */
int /*<<< orphan*/ fillbuf(int /*<<< orphan*/, int /*<<< orphan*/, char);
void vfillbuf(struct iovec *iv, int vcnt, char value) {
  int i;
  for (i = 0; i < vcnt; iv++, i++) {
    fillbuf(iv->iov_base, iv->iov_len, (char)value);
  }
}


x86 assembly (clang, -O0):
<vfillbuf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1167 <vfillbuf+0x57>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
movsbl -0xd(%rbp),%edx
call   1030 <fillbuf@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112b <vfillbuf+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vfillbuf>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    1148 <vfillbuf+0x38>
mov    %rdi,%rbx
mov    %esi,%r14d
xor    %ebp,%ebp
movsbl %dl,%r15d
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%esi
mov    0x4(%rbx,%rbp,8),%edi
mov    %r15d,%edx
call   1030 <fillbuf@plt>
add    $0x1,%rbp
cmp    %ebp,%r14d
jne    1130 <vfillbuf+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.iovec = type { i32, i32 }
define void @vfillbuf(%struct.iovec* %0, i32 %1, i8 signext %2) {
%4 = alloca %struct.iovec*
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
store %struct.iovec* %0, %struct.iovec** %4
store i32 %1, i32* %5
store i8 %2, i8* %6
store i32 0, i32* %7
br label %8
8: ; preds = %21, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = load %struct.iovec*, %struct.iovec** %4
%14 = getelementptr inbounds %struct.iovec, %struct.iovec* %13, i32 0, i32 1
%15 = load i32, i32* %14
%16 = load %struct.iovec*, %struct.iovec** %4
%17 = getelementptr inbounds %struct.iovec, %struct.iovec* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = load i8, i8* %6
%20 = call i32 @fillbuf(i32 %15, i32 %18, i8 signext %19)
br label %21
21: ; preds = %12
%22 = load %struct.iovec*, %struct.iovec** %4
%23 = getelementptr inbounds %struct.iovec, %struct.iovec* %22, i32 1
store %struct.iovec* %23, %struct.iovec** %4
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %8
26: ; preds = %8
ret void
}

LLVM IR (-O2):
%struct.iovec = type { i32, i32 }
define void @vfillbuf(%struct.iovec* nocapture %0, i32 %1, i8 signext %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %16
5: ; preds = %3, %5
%6 = phi i32 [ %14, %5 ], [ 0, %3 ]
%7 = phi %struct.iovec* [ %13, %5 ], [ %0, %3 ]
%8 = getelementptr inbounds %struct.iovec, %struct.iovec* %7, i64 0, i32 1
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.iovec, %struct.iovec* %7, i64 0, i32 0
%11 = load i32, i32* %10
%12 = tail call i32 @fillbuf(i32 %9, i32 %11, i8 signext %2)
%13 = getelementptr inbounds %struct.iovec, %struct.iovec* %7, i64 1
%14 = add nuw nsw i32 %6, 1
%15 = icmp eq i32 %14, %1
br i1 %15, label %16, label %5
16: ; preds = %5, %3
ret void
}