printv(const char *a, __builtin_va_list l) {
  extern write(), strlen();
  while (a) {
    write(1, a, strlen(a));
    write(1, "\n", 1);
    a = __builtin_va_arg(l, __typeof(a));
  }
  return 0;
}


x86 assembly (clang, -O0):
<printv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11ce <printv+0xae>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xe94(%rip),%rsi
mov    %edx,%edi
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
cmp    $0x28,%eax
ja     11a7 <printv+0x87>
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%edx
movslq %edx,%rax
add    0x10(%rcx),%rax
add    $0x8,%edx
mov    %edx,(%rcx)
mov    %rax,-0x30(%rbp)
jmp    11be <printv+0x9e>
mov    -0x20(%rbp),%rcx
mov    0x8(%rcx),%rdx
mov    %rdx,%rax
add    $0x8,%rdx
mov    %rdx,0x8(%rcx)
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1130 <printv+0x10>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printv>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     119b <printv+0x7b>
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xec9(%rip),%r14
jmp    1154 <printv+0x34>
nopl   0x0(%rax)
mov    0x8(%r15),%rax
lea    0x8(%rax),%rcx
mov    %rcx,0x8(%r15)
mov    (%rax),%rbx
test   %rbx,%rbx
je     119b <printv+0x7b>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <strlen@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    (%r15),%ecx
cmp    $0x28,%rcx
ja     1140 <printv+0x20>
mov    %rcx,%rax
add    0x10(%r15),%rax
add    $0x8,%ecx
mov    %ecx,(%r15)
jmp    114c <printv+0x2c>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.__va_list_tag = type { i32, i32, i8*, i8* }
@.str = [2 x i8] c"\0A\00"
define i32 @printv(i8* %0, %struct.__va_list_tag* %1) {
%3 = alloca i8*
%4 = alloca %struct.__va_list_tag*
store i8* %0, i8** %3
store %struct.__va_list_tag* %1, %struct.__va_list_tag** %4
br label %5
5: ; preds = %29, %2
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %32
8: ; preds = %5
%9 = load i8*, i8** %3
%10 = load i8*, i8** %3
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @strlen to i32 (i8*, ...)*)(i8* %10)
%12 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* %9, i32 %11)
%13 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%14 = load %struct.__va_list_tag*, %struct.__va_list_tag** %4
%15 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = icmp ule i32 %16, 40
br i1 %17, label %18, label %24
18: ; preds = %8
%19 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %14, i32 0, i32 3
%20 = load i8*, i8** %19
%21 = getelementptr i8, i8* %20, i32 %16
%22 = bitcast i8* %21 to i8**
%23 = add i32 %16, 8
store i32 %23, i32* %15
br label %29
24: ; preds = %8
%25 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %14, i32 0, i32 2
%26 = load i8*, i8** %25
%27 = bitcast i8* %26 to i8**
%28 = getelementptr i8, i8* %26, i32 8
store i8* %28, i8** %25
br label %29
29: ; preds = %24, %18
%30 = phi i8** [ %22, %18 ], [ %27, %24 ]
%31 = load i8*, i8** %30
store i8* %31, i8** %3
br label %5
32: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
%struct.__va_list_tag = type { i32, i32, i8*, i8* }
@.str = [2 x i8] c"\0A\00"
define i32 @printv(i8* %0, %struct.__va_list_tag* nocapture %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %28, label %4
4: ; preds = %2
%5 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %1, i64 0, i32 0
%6 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %1, i64 0, i32 2
%7 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %1, i64 0, i32 3
br label %8
8: ; preds = %4, %23
%9 = phi i8* [ %0, %4 ], [ %26, %23 ]
%10 = tail call i32 (i8*, ...) bitcast (i32 (...)* @strlen to i32 (i8*, ...)*)(i8* %9)
%11 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* %9, i32 %10)
%12 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%13 = load i32, i32* %5
%14 = icmp ult i32 %13, 41
br i1 %14, label %15, label %20
15: ; preds = %8
%16 = load i8*, i8** %7
%17 = zext i32 %13 to i64
%18 = getelementptr i8, i8* %16, i64 %17
%19 = add nuw nsw i32 %13, 8
store i32 %19, i32* %5
br label %23
20: ; preds = %8
%21 = load i8*, i8** %6
%22 = getelementptr i8, i8* %21, i64 8
store i8* %22, i8** %6
br label %23
23: ; preds = %20, %15
%24 = phi i8* [ %18, %15 ], [ %21, %20 ]
%25 = bitcast i8* %24 to i8**
%26 = load i8*, i8** %25
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %8
28: ; preds = %23, %2
ret i32 0
}