#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 /*<<< orphan*/ memcpy(char *, char const *, int);
int strlen(char const *);
void parseCommand(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);
  memcpy(str, cont, len);
  str[len] = '\0';
  return;
}


x86 assembly (clang, -O0):
<parseCommand>:
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     1179 <parseCommand+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    1189 <parseCommand+0x69>
jmp    1197 <parseCommand+0x77>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1140 <parseCommand+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    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseCommand>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ebp
cltq
add    %rbx,%rax
add    $0xffffffffffffffff,%rax
jmp    1157 <parseCommand+0x37>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0xffffffff,%ebp
add    $0xffffffffffffffff,%rax
movzbl (%rax),%ecx
cmp    $0xd,%cl
je     1150 <parseCommand+0x30>
cmp    $0xa,%cl
je     1150 <parseCommand+0x30>
mov    %r15,%rdi
call   1030 <strlen@plt>
sub    %eax,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <memcpy@plt>
movslq %ebp,%rax
movb   $0x0,(%r14,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @parseCommand(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 i8*, i8** %6
%39 = load i8*, i8** %4
%40 = load i32, i32* %7
%41 = call i32 @memcpy(i8* %38, i8* %39, i32 %40)
%42 = load i8*, i8** %6
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
store i8 0, i8* %45
ret void
}

LLVM IR (-O2):
define void @parseCommand(i8* %0, i8* %1, i8* %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
%16 = tail call i32 @memcpy(i8* %2, i8* %0, i32 %15)
%17 = sext i32 %15 to i64
%18 = getelementptr inbounds i8, i8* %2, i64 %17
store i8 0, i8* %18
ret void
}