#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 const *);
int getCommandLen(const char *cont, char *Iport, char *str) {
  int len = strlen(cont);
  while (cont[len - 1] == '\r' || cont[len - 1] == '\n') {
    --len;
  }
  len = len - strlen(Iport);
  return len;
}


x86 assembly (clang, -O0):
<getCommandLen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0xd,%ecx
mov    %al,-0x1d(%rbp)
je     1169 <getCommandLen+0x59>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1179 <getCommandLen+0x69>
jmp    1187 <getCommandLen+0x77>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1130 <getCommandLen+0x20>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCommandLen>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ebp
cltq
add    %rbx,%rax
add    $0xffffffffffffffff,%rax
jmp    1137 <getCommandLen+0x27>
nopl   0x0(%rax)
add    $0xffffffff,%ebp
add    $0xffffffffffffffff,%rax
movzbl (%rax),%ecx
cmp    $0xd,%cl
je     1130 <getCommandLen+0x20>
cmp    $0xa,%cl
je     1130 <getCommandLen+0x20>
mov    %r14,%rdi
call   1030 <strlen@plt>
sub    %eax,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @getCommandLen(i8* %0, i8* %1, i8* nocapture readnone %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = sext i32 %4 to i64
br label %6
6: ; preds = %11, %3
%7 = phi i64 [ %5, %3 ], [ %8, %11 ]
%8 = add i64 %7, -1
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
switch i8 %10, label %12 [
i8 13, label %11
i8 10, label %11
]
11: ; preds = %6, %6
br label %6
12: ; preds = %6
%13 = trunc i64 %7 to i32
%14 = tail call i32 @strlen(i8* %1)
%15 = sub nsw i32 %13, %14
ret i32 %15
}