#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 *);
unsigned int _getMsgOverHeadLen(char *command, char *target, char *ctcp,
                                char *usernick) {
  unsigned int len = 9 + 1 + 50 + 1;
  len += strlen("\r\n") + strlen(usernick);
  if (ctcp)
    len += strlen(ctcp) + (strlen("\x01") << 1) + 1;
  return len;
}


x86 assembly (clang, -O0):
<_getMsgOverHeadLen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x3d,-0x24(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118a <_getMsgOverHeadLen+0x7a>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
lea    0xe91(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
shl    $0x1,%ecx
add    %ecx,%eax
add    $0x1,%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_getMsgOverHeadLen>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r14
lea    0xedc(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1030 <strlen@plt>
add    %eax,%ebx
add    $0x3d,%ebx
test   %r14,%r14
je     115b <_getMsgOverHeadLen+0x4b>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0xeb5(%rip),%rdi
call   1030 <strlen@plt>
add    %ebp,%ebx
lea    (%rbx,%rax,2),%ebx
add    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [2 x i8] c"\01\00"
define i32 @_getMsgOverHeadLen(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i32 61, i32* %9
%10 = call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %8
%12 = call i32 @strlen(i8* %11)
%13 = add nsw i32 %10, %12
%14 = load i32, i32* %9
%15 = add i32 %14, %13
store i32 %15, i32* %9
%16 = load i8*, i8** %7
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %27
18: ; preds = %4
%19 = load i8*, i8** %7
%20 = call i32 @strlen(i8* %19)
%21 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = shl i32 %21, 1
%23 = add nsw i32 %20, %22
%24 = add nsw i32 %23, 1
%25 = load i32, i32* %9
%26 = add i32 %25, %24
store i32 %26, i32* %9
br label %27
27: ; preds = %18, %4
%28 = load i32, i32* %9
ret i32 %28
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [2 x i8] c"\01\00"
define i32 @_getMsgOverHeadLen(i8* nocapture readnone %0, i8* nocapture readnone %1, i8* %2, i8* %3) {
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @strlen(i8* %3)
%7 = add i32 %5, 61
%8 = add i32 %7, %6
%9 = icmp eq i8* %2, null
br i1 %9, label %17, label %10
10: ; preds = %4
%11 = tail call i32 @strlen(i8* %2)
%12 = tail call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = shl i32 %12, 1
%14 = add i32 %8, 1
%15 = add i32 %14, %11
%16 = add i32 %15, %13
br label %17
17: ; preds = %10, %4
%18 = phi i32 [ %16, %10 ], [ %8, %4 ]
ret i32 %18
}