#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 *, int);
int /*<<< orphan*/ strcpy(char *, char *);
size_t strlen(char *);
char *strrchr(char *, char);
void parseIpPort(char *cont, char *str) {
  int len = strlen(cont);
  while (cont[len - 1] == '\r' || cont[len - 1] == '\n') {
    --len;
  }
  memcpy(str, cont, len);
  str[len] = '\0';
  char *temp = strrchr(str, '\n');
  temp += 1;
  strcpy(str, temp);
  str[strlen(str)] = '\0';
  return;
}


x86 assembly (clang, -O0):
<parseIpPort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0xd,%ecx
mov    %al,-0x21(%rbp)
je     1195 <parseIpPort+0x55>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11a5 <parseIpPort+0x65>
jmp    11b3 <parseIpPort+0x73>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    115c <parseIpPort+0x1c>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <memcpy@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseIpPort>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %rax,%rbx
shl    $0x20,%rbx
movslq %eax,%rcx
add    %r14,%rcx
add    $0xffffffffffffffff,%rcx
movabs $0xffffffff00000000,%rsi
ff ff ff
jmp    117a <parseIpPort+0x3a>
nopl   (%rax)
add    %rsi,%rbx
add    $0xffffffff,%eax
add    $0xffffffffffffffff,%rcx
movzbl (%rcx),%edx
cmp    $0xd,%dl
je     1170 <parseIpPort+0x30>
cmp    $0xa,%dl
je     1170 <parseIpPort+0x30>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <memcpy@plt>
sar    $0x20,%rbx
movb   $0x0,(%r15,%rbx,1)
mov    %r15,%rdi
mov    $0xa,%esi
call   1050 <strrchr@plt>
lea    0x1(%rax),%rsi
mov    %r15,%rdi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
movb   $0x0,(%r15,%rax,1)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @parseIpPort(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = trunc i64 %8 to i32
store i32 %9, i32* %5
br label %10
10: ; preds = %30, %2
%11 = load i8*, i8** %3
%12 = load i32, i32* %5
%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** %3
%21 = load i32, i32* %5
%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* %5
%32 = add nsw i32 %31, -1
store i32 %32, i32* %5
br label %10
33: ; preds = %28
%34 = load i8*, i8** %4
%35 = load i8*, i8** %3
%36 = load i32, i32* %5
%37 = call i32 @memcpy(i8* %34, i8* %35, i32 %36)
%38 = load i8*, i8** %4
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 0, i8* %41
%42 = load i8*, i8** %4
%43 = call i8* @strrchr(i8* %42, i8 signext 10)
store i8* %43, i8** %6
%44 = load i8*, i8** %6
%45 = getelementptr inbounds i8, i8* %44, i64 1
store i8* %45, i8** %6
%46 = load i8*, i8** %4
%47 = load i8*, i8** %6
%48 = call i32 @strcpy(i8* %46, i8* %47)
%49 = load i8*, i8** %4
%50 = load i8*, i8** %4
%51 = call i64 @strlen(i8* %50)
%52 = getelementptr inbounds i8, i8* %49, i64 %51
store i8 0, i8* %52
ret void
}

LLVM IR (-O2):
define void @parseIpPort(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = shl i64 %3, 32
%5 = ashr exact i64 %4, 32
br label %6
6: ; preds = %11, %2
%7 = phi i64 [ %5, %2 ], [ %8, %11 ]
%8 = add nsw 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 @memcpy(i8* %1, i8* %0, i32 %13)
%15 = shl i64 %7, 32
%16 = ashr exact i64 %15, 32
%17 = getelementptr inbounds i8, i8* %1, i64 %16
store i8 0, i8* %17
%18 = tail call i8* @strrchr(i8* dereferenceable(1) %1, i8 signext 10)
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = tail call i32 @strcpy(i8* %1, i8* %19)
%21 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%22 = getelementptr inbounds i8, i8* %1, i64 %21
store i8 0, i8* %22
ret void
}