void f4(char x[64], char *y, __builtin_va_list ap) {
  char buf[128], *p = buf;
  snprintf(x, sizeof(x), "%s", y);
  vsnprintf(x, sizeof(x), "%s", ap);
  snprintf(p, sizeof(p), "%s", y);
  vsnprintf(p, sizeof(p), "%s", ap);
  snprintf(buf, sizeof(buf), "%s", y);
  vsnprintf(buf, sizeof(buf), "%s", ap);
  snprintf(p, sizeof(buf), "%s", y);
  vsnprintf(p, sizeof(buf), "%s", ap);
}


x86 assembly (clang, -O0):
<f4>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x8,%esi
lea    0xea7(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x8,%esi
lea    0xe8c(%rip),%rdx
call   1030 <vsnprintf@plt>
mov    -0xa8(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x8,%esi
lea    0xe70(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0xa8(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x8,%esi
lea    0xe52(%rip),%rdx
call   1030 <vsnprintf@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x80,%esi
lea    0xe36(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x80,%esi
lea    0xe18(%rip),%rdx
call   1030 <vsnprintf@plt>
mov    -0xa8(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x80,%esi
lea    0xdfc(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0xa8(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x80,%esi
lea    0xdde(%rip),%rdx
call   1030 <vsnprintf@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f4>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%rbx
lea    0xec0(%rip),%r14
mov    $0x8,%esi
mov    %r14,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    $0x8,%esi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
call   1030 <vsnprintf@plt>
mov    %rsp,%r12
mov    $0x8,%esi
mov    %r12,%rdi
mov    %r14,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    $0x8,%esi
mov    %r12,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
call   1030 <vsnprintf@plt>
mov    $0x80,%esi
mov    %r12,%rdi
mov    %r14,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    $0x80,%esi
mov    %r12,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
call   1030 <vsnprintf@plt>
mov    $0x80,%esi
mov    %r12,%rdi
mov    %r14,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    $0x80,%esi
mov    %r12,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
call   1030 <vsnprintf@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.__va_list_tag = type { i32, i32, i8*, i8* }
@.str = [3 x i8] c"%s\00"
define void @f4(i8* %0, i8* %1, %struct.__va_list_tag* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.__va_list_tag*
%7 = alloca [128 x i8]
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store %struct.__va_list_tag* %2, %struct.__va_list_tag** %6
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
store i8* %9, i8** %8
%10 = load i8*, i8** %4
%11 = load i8*, i8** %5
%12 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %10, i64 8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %4
%14 = load %struct.__va_list_tag*, %struct.__va_list_tag** %6
%15 = call i32 @vsnprintf(i8* %13, i64 8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.__va_list_tag* %14)
%16 = load i8*, i8** %8
%17 = load i8*, i8** %5
%18 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %16, i64 8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %8
%20 = load %struct.__va_list_tag*, %struct.__va_list_tag** %6
%21 = call i32 @vsnprintf(i8* %19, i64 8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.__va_list_tag* %20)
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%23 = load i8*, i8** %5
%24 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %22, i64 128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%26 = load %struct.__va_list_tag*, %struct.__va_list_tag** %6
%27 = call i32 @vsnprintf(i8* %25, i64 128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.__va_list_tag* %26)
%28 = load i8*, i8** %8
%29 = load i8*, i8** %5
%30 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %28, i64 128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = load i8*, i8** %8
%32 = load %struct.__va_list_tag*, %struct.__va_list_tag** %6
%33 = call i32 @vsnprintf(i8* %31, i64 128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.__va_list_tag* %32)
ret void
}

LLVM IR (-O2):
%struct.__va_list_tag = type { i32, i32, i8*, i8* }
@.str = [3 x i8] c"%s\00"
define void @f4(i8* nocapture %0, i8* %1, %struct.__va_list_tag* %2) {
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%6 = tail call i32 (i8*, i64, i8*, ...) @snprintf(i8* dereferenceable(1) %0, i64 8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%7 = tail call i32 @vsnprintf(i8* %0, i64 8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.__va_list_tag* %2)
%8 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %5, i64 8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%9 = call i32 @vsnprintf(i8* %5, i64 8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.__va_list_tag* %2)
%10 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %5, i64 128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%11 = call i32 @vsnprintf(i8* %5, i64 128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.__va_list_tag* %2)
%12 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %5, i64 128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%13 = call i32 @vsnprintf(i8* %5, i64 128, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.__va_list_tag* %2)
ret void
}