int printstr_serial(char **buf, int *buflen, const char *str) {
  if (!str)
    return snprintf_serial(buf, buflen, "0\"0\" ");
  return snprintf_serial(buf, buflen, "%u\"%s\" ", strlen(str), str);
}


x86 assembly (clang, -O0):
<printstr_serial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    115d <printstr_serial+0x3d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    0xeb2(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf_serial@plt>
mov    %eax,-0x4(%rbp)
jmp    1196 <printstr_serial+0x76>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %rax,%rcx
mov    -0x20(%rbp),%r8
lea    0xe7a(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf_serial@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printstr_serial>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
test   %rdx,%rdx
je     115a <printstr_serial+0x3a>
mov    %rdx,%rbx
mov    %rdx,%rdi
call   1030 <strlen@plt>
lea    0xec4(%rip),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rax,%rcx
mov    %rbx,%r8
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <snprintf_serial@plt>
lea    0xe9f(%rip),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <snprintf_serial@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"0\220\22 \00"
@.str.1 = [8 x i8] c"%u\22%s\22 \00"
define i32 @printstr_serial(i8** %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
store i8** %0, i8*** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
%8 = load i8*, i8** %7
%9 = icmp ne i8* %8, null
br i1 %9, label %14, label %10
10: ; preds = %3
%11 = load i8**, i8*** %5
%12 = load i32*, i32** %6
%13 = call i32 (i8**, i32*, i8*, ...) bitcast (i32 (...)* @snprintf_serial to i32 (i8**, i32*, i8*, ...)*)(i8** %11, i32* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %4
br label %21
14: ; preds = %3
%15 = load i8**, i8*** %5
%16 = load i32*, i32** %6
%17 = load i8*, i8** %7
%18 = call i64 @strlen(i8* %17)
%19 = load i8*, i8** %7
%20 = call i32 (i8**, i32*, i8*, i64, i8*, ...) bitcast (i32 (...)* @snprintf_serial to i32 (i8**, i32*, i8*, i64, i8*, ...)*)(i8** %15, i32* %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %18, i8* %19)
store i32 %20, i32* %4
br label %21
21: ; preds = %14, %10
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
@.str = [6 x i8] c"0\220\22 \00"
@.str.1 = [8 x i8] c"%u\22%s\22 \00"
define i32 @printstr_serial(i8** %0, i32* %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 (i8**, i32*, i8*, ...) bitcast (i32 (...)* @snprintf_serial to i32 (i8**, i32*, i8*, ...)*)(i8** %0, i32* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %10
7: ; preds = %3
%8 = tail call i64 @strlen(i8* %2)
%9 = tail call i32 (i8**, i32*, i8*, i64, i8*, ...) bitcast (i32 (...)* @snprintf_serial to i32 (i8**, i32*, i8*, i64, i8*, ...)*)(i8** %0, i32* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %8, i8* %2)
br label %10
10: ; preds = %7, %5
%11 = phi i32 [ %9, %7 ], [ %6, %5 ]
ret i32 %11
}