#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 */
typedef int /*<<< orphan*/ uint32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ strlen(char const *const);
scalar_t__ uint32WriteToFP(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
scalar_t__ write_FP(int /*<<< orphan*/ *, char const *const,
                    int /*<<< orphan*/);
size_t astringWriteToFP(FILE *fp, const char *const *data) {
  size_t count = 0;
  uint32_t length = (*data == NULL) ? 0 : strlen(*data);
  count += uint32WriteToFP(fp, &length);
  count += write_FP(fp, *data, length);
  return count;
}


x86 assembly (clang, -O0):
<astringWriteToFP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1160 <astringWriteToFP+0x30>
xor    %eax,%eax
mov    %eax,-0x20(%rbp)
jmp    116f <astringWriteToFP+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <uint32WriteToFP@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <write_FP@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<astringWriteToFP>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%rdi
test   %rdi,%rdi
je     114e <astringWriteToFP+0x1e>
call   1030 <strlen@plt>
jmp    1150 <astringWriteToFP+0x20>
xor    %eax,%eax
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1050 <uint32WriteToFP@plt>
mov    %rax,%r15
mov    (%rbx),%rsi
mov    0xc(%rsp),%edx
mov    %r14,%rdi
call   1040 <write_FP@plt>
add    %r15,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @astringWriteToFP(i32* %0, i8** %1) {
%3 = alloca i32*
%4 = alloca i8**
%5 = alloca i64
%6 = alloca i32
store i32* %0, i32** %3
store i8** %1, i8*** %4
store i64 0, i64* %5
%7 = load i8**, i8*** %4
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %2
br label %15
11: ; preds = %2
%12 = load i8**, i8*** %4
%13 = load i8*, i8** %12
%14 = call i32 @strlen(i8* %13)
br label %15
15: ; preds = %11, %10
%16 = phi i32 [ 0, %10 ], [ %14, %11 ]
store i32 %16, i32* %6
%17 = load i32*, i32** %3
%18 = call i64 @uint32WriteToFP(i32* %17, i32* %6)
%19 = load i64, i64* %5
%20 = add i64 %19, %18
store i64 %20, i64* %5
%21 = load i32*, i32** %3
%22 = load i8**, i8*** %4
%23 = load i8*, i8** %22
%24 = load i32, i32* %6
%25 = call i64 @write_FP(i32* %21, i8* %23, i32 %24)
%26 = load i64, i64* %5
%27 = add i64 %26, %25
store i64 %27, i64* %5
%28 = load i64, i64* %5
ret i64 %28
}

LLVM IR (-O2):
define i64 @astringWriteToFP(i32* %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = load i8*, i8** %1
%6 = icmp eq i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @strlen(i8* %5)
br label %9
9: ; preds = %2, %7
%10 = phi i32 [ %8, %7 ], [ 0, %2 ]
store i32 %10, i32* %3
%11 = call i64 @uint32WriteToFP(i32* %0, i32* %3)
%12 = load i8*, i8** %1
%13 = load i32, i32* %3
%14 = call i64 @write_FP(i32* %0, i8* %12, i32 %13)
%15 = add i64 %14, %11
ret i64 %15
}