#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 size_t uint32_t;

/* Variables and functions */
scalar_t__ strlen(char *const);
uint32_t __string_encoded_array_size(char *const *s, uint32_t elements) {
  uint32_t size = 0, element;
  for (element = 0; element < elements; ++element)
    size += (4) + strlen(s[element]) + (1);
  return size;
}


x86 assembly (clang, -O0):
<__string_encoded_array_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1170 <__string_encoded_array_size+0x60>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
add    $0x4,%rax
add    $0x1,%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1130 <__string_encoded_array_size+0x20>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__string_encoded_array_size>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     114b <__string_encoded_array_size+0x3b>
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
call   1030 <strlen@plt>
add    %rax,%r12
add    $0x5,%r12
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1130 <__string_encoded_array_size+0x20>
jmp    114e <__string_encoded_array_size+0x3e>
xor    %r12d,%r12d
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @__string_encoded_array_size(i8** %0, i64 %1) {
%3 = alloca i8**
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i8** %0, i8*** %3
store i64 %1, i64* %4
store i64 0, i64* %5
store i64 0, i64* %6
br label %7
7: ; preds = %21, %2
%8 = load i64, i64* %6
%9 = load i64, i64* %4
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = load i8**, i8*** %3
%13 = load i64, i64* %6
%14 = getelementptr inbounds i8*, i8** %12, i64 %13
%15 = load i8*, i8** %14
%16 = call i64 @strlen(i8* %15)
%17 = add nsw i64 4, %16
%18 = add nsw i64 %17, 1
%19 = load i64, i64* %5
%20 = add i64 %19, %18
store i64 %20, i64* %5
br label %21
21: ; preds = %11
%22 = load i64, i64* %6
%23 = add i64 %22, 1
store i64 %23, i64* %6
br label %7
24: ; preds = %7
%25 = load i64, i64* %5
ret i64 %25
}

LLVM IR (-O2):
define i64 @__string_encoded_array_size(i8** nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %14, label %4
4: ; preds = %2, %4
%5 = phi i64 [ %12, %4 ], [ 0, %2 ]
%6 = phi i64 [ %11, %4 ], [ 0, %2 ]
%7 = getelementptr inbounds i8*, i8** %0, i64 %5
%8 = load i8*, i8** %7
%9 = tail call i64 @strlen(i8* dereferenceable(1) %8)
%10 = add i64 %6, 5
%11 = add i64 %10, %9
%12 = add nuw i64 %5, 1
%13 = icmp eq i64 %12, %1
br i1 %13, label %14, label %4
14: ; preds = %4, %2
%15 = phi i64 [ 0, %2 ], [ %11, %4 ]
ret i64 %15
}