#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 */

/* Variables and functions */
int strlen(char *);
int cindexsize(int files, char *argv[], short optoffset) {
  int i, size = 0;
  for (i = 0; i < files; i++)
    size += strlen(argv[i + 2 + optoffset]) + 1;
  return (size + strlen("WRAP") + (files + 2) * 4 + 4 + 4);
}


x86 assembly (clang, -O0):
<cindexsize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dx,%ax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1173 <cindexsize+0x63>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x2,%ecx
movswl -0x12(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1134 <cindexsize+0x24>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
lea    0xe80(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    -0x4(%rbp),%ecx
add    $0x2,%ecx
shl    $0x2,%ecx
add    %ecx,%eax
add    $0x4,%eax
add    $0x4,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cindexsize>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r14d
test   %edi,%edi
jle    1172 <cindexsize+0x62>
mov    %rsi,%r15
movswq %dx,%rax
mov    %r14d,%r13d
shl    $0x20,%rax
movabs $0x200000000,%rbx
add    %rax,%rbx
xor    %r12d,%r12d
movabs $0x100000000,%rbp
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rax
sar    $0x1d,%rax
mov    (%r15,%rax,1),%rdi
call   1030 <strlen@plt>
add    %eax,%r12d
add    $0x1,%r12d
add    %rbp,%rbx
add    $0xffffffffffffffff,%r13
jne    1150 <cindexsize+0x40>
jmp    1175 <cindexsize+0x65>
xor    %r12d,%r12d
lea    0xe84(%rip),%rdi
call   1030 <strlen@plt>
lea    (%r12,%r14,4),%ecx
add    %ecx,%eax
add    $0x10,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"WRAP\00"
define i32 @cindexsize(i32 %0, i8** %1, i16 signext %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i16
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i16 %2, i16* %6
store i32 0, i32* %8
store i32 0, i32* %7
br label %9
9: ; preds = %27, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %30
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %7
%16 = add nsw i32 %15, 2
%17 = load i16, i16* %6
%18 = sext i16 %17 to i32
%19 = add nsw i32 %16, %18
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %14, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @strlen(i8* %22)
%24 = add nsw i32 %23, 1
%25 = load i32, i32* %8
%26 = add nsw i32 %25, %24
store i32 %26, i32* %8
br label %27
27: ; preds = %13
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %9
30: ; preds = %9
%31 = load i32, i32* %8
%32 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%33 = add nsw i32 %31, %32
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 2
%36 = mul nsw i32 %35, 4
%37 = add nsw i32 %33, %36
%38 = add nsw i32 %37, 4
%39 = add nsw i32 %38, 4
ret i32 %39
}

LLVM IR (-O2):
@.str = [5 x i8] c"WRAP\00"
define i32 @cindexsize(i32 %0, i8** nocapture %1, i16 signext %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %22
5: ; preds = %3
%6 = sext i16 %2 to i64
%7 = add nsw i64 %6, 2
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %20, %9 ]
%11 = phi i32 [ 0, %5 ], [ %19, %9 ]
%12 = add i64 %7, %10
%13 = shl i64 %12, 32
%14 = ashr exact i64 %13, 32
%15 = getelementptr inbounds i8*, i8** %1, i64 %14
%16 = load i8*, i8** %15
%17 = tail call i32 @strlen(i8* %16)
%18 = add i32 %11, 1
%19 = add i32 %18, %17
%20 = add nuw nsw i64 %10, 1
%21 = icmp eq i64 %20, %8
br i1 %21, label %22, label %9
22: ; preds = %9, %3
%23 = phi i32 [ 0, %3 ], [ %19, %9 ]
%24 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%25 = shl i32 %0, 2
%26 = add i32 %25, 16
%27 = add i32 %26, %23
%28 = add i32 %27, %24
ret i32 %28
}