#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 */
scalar_t__ isdigit(char);
int /*<<< orphan*/ memmove(char *, char *, int);
char *strchr(char *, char);
int strlen(char *);
void WSA_RemovePortNumberFromURL(char *szWebServiceAddress) {
  char *szInput = szWebServiceAddress;
  char *szPortOffset_begin = NULL;
  char *szPortOffset_end = NULL;
  int iEndSize = 0;
  if (!szWebServiceAddress || !(*szWebServiceAddress))
    return;
  do {
    szPortOffset_begin = strchr(szInput, ':');
    if (!szPortOffset_begin)
      return;
    if (isdigit(szPortOffset_begin[1]))
      break;
    szInput = (szPortOffset_begin + 1);
  } while (*szInput);
  if (!(*szInput))
    return;
  szPortOffset_end = strchr(szPortOffset_begin, '/');
  if (!szPortOffset_end)
    szPortOffset_end = strchr(szPortOffset_begin, '\\');
  if (!szPortOffset_end) {
    (*szPortOffset_begin) = '\0';
    return;
  }
  iEndSize = strlen(szPortOffset_end);
  memmove(szPortOffset_begin, szPortOffset_end, iEndSize);
  szPortOffset_begin[iEndSize] = '\0';
}


x86 assembly (clang, -O0):
<WSA_RemovePortNumberFromURL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1183 <WSA_RemovePortNumberFromURL+0x43>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1188 <WSA_RemovePortNumberFromURL+0x48>
jmp    1264 <WSA_RemovePortNumberFromURL+0x124>
jmp    118d <WSA_RemovePortNumberFromURL+0x4d>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11af <WSA_RemovePortNumberFromURL+0x6f>
jmp    1264 <WSA_RemovePortNumberFromURL+0x124>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11cb <WSA_RemovePortNumberFromURL+0x8b>
jmp    11e4 <WSA_RemovePortNumberFromURL+0xa4>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    118d <WSA_RemovePortNumberFromURL+0x4d>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11f6 <WSA_RemovePortNumberFromURL+0xb6>
jmp    1264 <WSA_RemovePortNumberFromURL+0x124>
mov    -0x18(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1225 <WSA_RemovePortNumberFromURL+0xe5>
mov    -0x18(%rbp),%rdi
mov    $0x5c,%esi
call   1050 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    123c <WSA_RemovePortNumberFromURL+0xfc>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    1264 <WSA_RemovePortNumberFromURL+0x124>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1060 <memmove@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WSA_RemovePortNumberFromURL>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     11e1 <WSA_RemovePortNumberFromURL+0xa1>
mov    %rdi,%r14
cmpb   $0x0,(%rdi)
je     11e1 <WSA_RemovePortNumberFromURL+0xa1>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11e1 <WSA_RemovePortNumberFromURL+0xa1>
mov    %rax,%rbx
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1191 <WSA_RemovePortNumberFromURL+0x51>
add    $0x1,%rbx
cmpb   $0x0,(%rbx)
mov    %rbx,%r14
jne    1160 <WSA_RemovePortNumberFromURL+0x20>
jmp    11e1 <WSA_RemovePortNumberFromURL+0xa1>
cmpb   $0x0,(%r14)
je     11e1 <WSA_RemovePortNumberFromURL+0xa1>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,%r14
test   %rax,%rax
jne    11c1 <WSA_RemovePortNumberFromURL+0x81>
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1050 <strchr@plt>
mov    %rax,%r14
test   %rax,%rax
je     11de <WSA_RemovePortNumberFromURL+0x9e>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <memmove@plt>
movslq %ebp,%rax
add    %rax,%rbx
movb   $0x0,(%rbx)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @WSA_RemovePortNumberFromURL(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
store i8* %7, i8** %3
store i8* null, i8** %4
store i8* null, i8** %5
store i32 0, i32* %6
%8 = load i8*, i8** %2
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %10, %1
br label %65
15: ; preds = %10
br label %16
16: ; preds = %32, %15
%17 = load i8*, i8** %3
%18 = call i8* @strchr(i8* %17, i8 signext 58)
store i8* %18, i8** %4
%19 = load i8*, i8** %4
%20 = icmp ne i8* %19, null
br i1 %20, label %22, label %21
21: ; preds = %16
br label %65
22: ; preds = %16
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8, i8* %24
%26 = call i64 @isdigit(i8 signext %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %22
br label %36
29: ; preds = %22
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i64 1
store i8* %31, i8** %3
br label %32
32: ; preds = %29
%33 = load i8*, i8** %3
%34 = load i8, i8* %33
%35 = icmp ne i8 %34, 0
br i1 %35, label %16, label %36
36: ; preds = %32, %28
%37 = load i8*, i8** %3
%38 = load i8, i8* %37
%39 = icmp ne i8 %38, 0
br i1 %39, label %41, label %40
40: ; preds = %36
br label %65
41: ; preds = %36
%42 = load i8*, i8** %4
%43 = call i8* @strchr(i8* %42, i8 signext 47)
store i8* %43, i8** %5
%44 = load i8*, i8** %5
%45 = icmp ne i8* %44, null
br i1 %45, label %49, label %46
46: ; preds = %41
%47 = load i8*, i8** %4
%48 = call i8* @strchr(i8* %47, i8 signext 92)
store i8* %48, i8** %5
br label %49
49: ; preds = %46, %41
%50 = load i8*, i8** %5
%51 = icmp ne i8* %50, null
br i1 %51, label %54, label %52
52: ; preds = %49
%53 = load i8*, i8** %4
store i8 0, i8* %53
br label %65
54: ; preds = %49
%55 = load i8*, i8** %5
%56 = call i32 @strlen(i8* %55)
store i32 %56, i32* %6
%57 = load i8*, i8** %4
%58 = load i8*, i8** %5
%59 = load i32, i32* %6
%60 = call i32 @memmove(i8* %57, i8* %58, i32 %59)
%61 = load i8*, i8** %4
%62 = load i32, i32* %6
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %61, i64 %63
store i8 0, i8* %64
br label %65
65: ; preds = %54, %52, %40, %21, %14
ret void
}

LLVM IR (-O2):
define void @WSA_RemovePortNumberFromURL(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %35, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %35, label %6
6: ; preds = %3, %15
%7 = phi i8* [ %11, %15 ], [ %0, %3 ]
%8 = tail call i8* @strchr(i8* %7, i8 signext 58)
%9 = icmp eq i8* %8, null
br i1 %9, label %35, label %10
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %8, i64 1
%12 = load i8, i8* %11
%13 = tail call i64 @isdigit(i8 signext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i8, i8* %11
%17 = icmp eq i8 %16, 0
br i1 %17, label %35, label %6
18: ; preds = %10
%19 = load i8, i8* %7
%20 = icmp eq i8 %19, 0
br i1 %20, label %35, label %21
21: ; preds = %18
%22 = tail call i8* @strchr(i8* %8, i8 signext 47)
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = tail call i8* @strchr(i8* %8, i8 signext 92)
%26 = icmp eq i8* %25, null
br i1 %26, label %33, label %27
27: ; preds = %21, %24
%28 = phi i8* [ %25, %24 ], [ %22, %21 ]
%29 = tail call i32 @strlen(i8* %28)
%30 = tail call i32 @memmove(i8* %8, i8* %28, i32 %29)
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds i8, i8* %8, i64 %31
br label %33
33: ; preds = %24, %27
%34 = phi i8* [ %32, %27 ], [ %8, %24 ]
store i8 0, i8* %34
br label %35
35: ; preds = %15, %6, %33, %18, %1, %3
ret void
}