#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 */
char *do_nofail(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ malloc(int);
int /*<<< orphan*/ memcpy(char *, char const *const, int);
char *strchr(char const *const, char);
int /*<<< orphan*/ strdup(char const *const);
char tolower(char);
void split_server_port(const char *const input, char **server, char **port) {
  char *p;
  if (*input == '[' && (p = strchr(input, ']'))) {
    char *s;
    int len = p - input - 1;
    *server = s = do_nofail((malloc(len + 1)),
                            "/scratch/repos/new/home/jordi_armengol_estape/"
                            "c-scraper/outputs/2022-01-22/02-19-57/repos/mrash/"
                            "psad/refs/heads/master/deps/whois/whois.c",
                            1231);
    memcpy(s, input + 1, len);
    *(s + len) = '\0';
    p = strchr(p, ':');
    if (p && *(p + 1) != '\0')
      *port = do_nofail((strdup(p + 1)),
                        "/scratch/repos/new/home/jordi_armengol_estape/"
                        "c-scraper/outputs/2022-01-22/02-19-57/repos/mrash/"
                        "psad/refs/heads/master/deps/whois/whois.c",
                        1237);
  } else if ((p = strchr(input, ':')) && strchr(p + 1, ':')) {
    *server = do_nofail((strdup(input)),
                        "/scratch/repos/new/home/jordi_armengol_estape/"
                        "c-scraper/outputs/2022-01-22/02-19-57/repos/mrash/"
                        "psad/refs/heads/master/deps/whois/whois.c",
                        1240);
  } else if ((p = strchr(input, ':'))) {
    char *s;
    int len = p - input;
    *server = s = do_nofail((malloc(len + 1)),
                            "/scratch/repos/new/home/jordi_armengol_estape/"
                            "c-scraper/outputs/2022-01-22/02-19-57/repos/mrash/"
                            "psad/refs/heads/master/deps/whois/whois.c",
                            1245);
    memcpy(s, input, len);
    *(s + len) = '\0';
    p++;
    if (*p != '\0')
      *port = do_nofail((strdup(p)),
                        "/scratch/repos/new/home/jordi_armengol_estape/"
                        "c-scraper/outputs/2022-01-22/02-19-57/repos/mrash/"
                        "psad/refs/heads/master/deps/whois/whois.c",
                        1251);
  } else {
    *server = do_nofail((strdup(input)),
                        "/scratch/repos/new/home/jordi_armengol_estape/"
                        "c-scraper/outputs/2022-01-22/02-19-57/repos/mrash/"
                        "psad/refs/heads/master/deps/whois/whois.c",
                        1253);
  }
  for (p = (char *)*server; *p; p++)
    *p = tolower(*p);
}


x86 assembly (clang, -O0):
<split_server_port>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    125b <split_server_port+0xfb>
mov    -0x8(%rbp),%rdi
mov    $0x5d,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     125b <split_server_port+0xfb>
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %eax,%edi
lea    0xe3a(%rip),%rsi
mov    $0x4cf,%edx
call   1070 <do_nofail@plt>
mov    %rax,%rcx
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x1,%rsi
mov    -0x2c(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1256 <split_server_port+0xf6>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1256 <split_server_port+0xf6>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1080 <strdup@plt>
mov    %eax,%edi
lea    0xdbe(%rip),%rsi
mov    $0x4d5,%edx
call   1070 <do_nofail@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    13a7 <split_server_port+0x247>
mov    -0x8(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     12be <split_server_port+0x15e>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     12be <split_server_port+0x15e>
mov    -0x8(%rbp),%rdi
call   1080 <strdup@plt>
mov    %eax,%edi
lea    0xd5b(%rip),%rsi
mov    $0x4d8,%edx
call   1070 <do_nofail@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    13a2 <split_server_port+0x242>
mov    -0x8(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1377 <split_server_port+0x217>
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %eax,%edi
lea    0xd04(%rip),%rsi
mov    $0x4dd,%edx
call   1070 <do_nofail@plt>
mov    %rax,%rcx
mov    %rcx,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x3c(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1372 <split_server_port+0x212>
mov    -0x20(%rbp),%rdi
call   1080 <strdup@plt>
mov    %eax,%edi
lea    0xca2(%rip),%rsi
mov    $0x4e3,%edx
call   1070 <do_nofail@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    139d <split_server_port+0x23d>
mov    -0x8(%rbp),%rdi
call   1080 <strdup@plt>
mov    %eax,%edi
lea    0xc77(%rip),%rsi
mov    $0x4e5,%edx
call   1070 <do_nofail@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    13a2 <split_server_port+0x242>
jmp    13a7 <split_server_port+0x247>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     13e4 <split_server_port+0x284>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1050 <tolower@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    13b2 <split_server_port+0x252>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_server_port>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
cmpb   $0x5b,(%rdi)
jne    1206 <split_server_port+0xa6>
mov    %r12,%rdi
mov    $0x5d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1206 <split_server_port+0xa6>
mov    %rax,%r13
mov    %r12,%rbx
not    %rbx
add    %rax,%rbx
lea    0x1(%rbx),%edi
call   1060 <malloc@plt>
lea    0xe56(%rip),%rsi
mov    %eax,%edi
mov    $0x4cf,%edx
call   1070 <do_nofail@plt>
mov    %rax,%rbp
mov    %rax,(%r15)
add    $0x1,%r12
mov    %rax,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1040 <memcpy@plt>
movslq %ebx,%rax
movb   $0x0,0x0(%rbp,%rax,1)
mov    %r13,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     12ae <split_server_port+0x14e>
mov    %rax,%rbx
cmpb   $0x0,0x1(%rax)
je     12ae <split_server_port+0x14e>
add    $0x1,%rbx
mov    $0x4d5,%ebp
jmp    1293 <split_server_port+0x133>
mov    %r12,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1288 <split_server_port+0x128>
mov    %rax,%r13
lea    0x1(%rax),%rbx
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    $0x4d8,%ebp
test   %rax,%rax
jne    128d <split_server_port+0x12d>
mov    %r13,%rbp
sub    %r12,%rbp
lea    0x1(%rbp),%edi
call   1060 <malloc@plt>
lea    0xdb5(%rip),%rsi
mov    %eax,%edi
mov    $0x4dd,%edx
call   1070 <do_nofail@plt>
mov    %r14,(%rsp)
mov    %rax,%r14
mov    %rax,(%r15)
mov    %rax,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1040 <memcpy@plt>
movslq %ebp,%rax
movb   $0x0,(%r14,%rax,1)
mov    (%rsp),%r14
mov    $0x4e3,%ebp
cmpb   $0x0,0x1(%r13)
jne    1293 <split_server_port+0x133>
jmp    12ae <split_server_port+0x14e>
mov    $0x4e5,%ebp
mov    %r12,%rbx
mov    %r15,%r14
mov    %rbx,%rdi
call   1080 <strdup@plt>
lea    0xd5e(%rip),%rsi
mov    %eax,%edi
mov    %ebp,%edx
call   1070 <do_nofail@plt>
mov    %rax,(%r14)
mov    (%r15),%rbx
mov    (%rbx),%al
test   %al,%al
je     12d6 <split_server_port+0x176>
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1050 <tolower@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    12c0 <split_server_port+0x160>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mrash/psad/refs/heads/master/deps/whois/whois.c\00"
define void @split_server_port(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 91
br i1 %15, label %16, label %59
16: ; preds = %3
%17 = load i8*, i8** %4
%18 = call i8* @strchr(i8* %17, i8 signext 93)
store i8* %18, i8** %7
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %59
20: ; preds = %16
%21 = load i8*, i8** %7
%22 = load i8*, i8** %4
%23 = ptrtoint i8* %21 to i64
%24 = ptrtoint i8* %22 to i64
%25 = sub i64 %23, %24
%26 = sub nsw i64 %25, 1
%27 = trunc i64 %26 to i32
store i32 %27, i32* %9
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
%30 = call i32 @malloc(i32 %29)
%31 = call i8* @do_nofail(i32 %30, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 1231)
store i8* %31, i8** %8
%32 = load i8**, i8*** %5
store i8* %31, i8** %32
%33 = load i8*, i8** %8
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = load i32, i32* %9
%37 = call i32 @memcpy(i8* %33, i8* %35, i32 %36)
%38 = load i8*, i8** %8
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 0, i8* %41
%42 = load i8*, i8** %7
%43 = call i8* @strchr(i8* %42, i8 signext 58)
store i8* %43, i8** %7
%44 = load i8*, i8** %7
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %58
46: ; preds = %20
%47 = load i8*, i8** %7
%48 = getelementptr inbounds i8, i8* %47, i64 1
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %58
52: ; preds = %46
%53 = load i8*, i8** %7
%54 = getelementptr inbounds i8, i8* %53, i64 1
%55 = call i32 @strdup(i8* %54)
%56 = call i8* @do_nofail(i32 %55, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 1237)
%57 = load i8**, i8*** %6
store i8* %56, i8** %57
br label %58
58: ; preds = %52, %46, %20
br label %116
59: ; preds = %16, %3
%60 = load i8*, i8** %4
%61 = call i8* @strchr(i8* %60, i8 signext 58)
store i8* %61, i8** %7
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %73
63: ; preds = %59
%64 = load i8*, i8** %7
%65 = getelementptr inbounds i8, i8* %64, i64 1
%66 = call i8* @strchr(i8* %65, i8 signext 58)
%67 = icmp ne i8* %66, null
br i1 %67, label %68, label %73
68: ; preds = %63
%69 = load i8*, i8** %4
%70 = call i32 @strdup(i8* %69)
%71 = call i8* @do_nofail(i32 %70, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 1240)
%72 = load i8**, i8*** %5
store i8* %71, i8** %72
br label %115
73: ; preds = %63, %59
%74 = load i8*, i8** %4
%75 = call i8* @strchr(i8* %74, i8 signext 58)
store i8* %75, i8** %7
%76 = icmp ne i8* %75, null
br i1 %76, label %77, label %109
77: ; preds = %73
%78 = load i8*, i8** %7
%79 = load i8*, i8** %4
%80 = ptrtoint i8* %78 to i64
%81 = ptrtoint i8* %79 to i64
%82 = sub i64 %80, %81
%83 = trunc i64 %82 to i32
store i32 %83, i32* %11
%84 = load i32, i32* %11
%85 = add nsw i32 %84, 1
%86 = call i32 @malloc(i32 %85)
%87 = call i8* @do_nofail(i32 %86, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 1245)
store i8* %87, i8** %10
%88 = load i8**, i8*** %5
store i8* %87, i8** %88
%89 = load i8*, i8** %10
%90 = load i8*, i8** %4
%91 = load i32, i32* %11
%92 = call i32 @memcpy(i8* %89, i8* %90, i32 %91)
%93 = load i8*, i8** %10
%94 = load i32, i32* %11
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8, i8* %93, i64 %95
store i8 0, i8* %96
%97 = load i8*, i8** %7
%98 = getelementptr inbounds i8, i8* %97, i32 1
store i8* %98, i8** %7
%99 = load i8*, i8** %7
%100 = load i8, i8* %99
%101 = sext i8 %100 to i32
%102 = icmp ne i32 %101, 0
br i1 %102, label %103, label %108
103: ; preds = %77
%104 = load i8*, i8** %7
%105 = call i32 @strdup(i8* %104)
%106 = call i8* @do_nofail(i32 %105, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 1251)
%107 = load i8**, i8*** %6
store i8* %106, i8** %107
br label %108
108: ; preds = %103, %77
br label %114
109: ; preds = %73
%110 = load i8*, i8** %4
%111 = call i32 @strdup(i8* %110)
%112 = call i8* @do_nofail(i32 %111, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 1253)
%113 = load i8**, i8*** %5
store i8* %112, i8** %113
br label %114
114: ; preds = %109, %108
br label %115
115: ; preds = %114, %68
br label %116
116: ; preds = %115, %58
%117 = load i8**, i8*** %5
%118 = load i8*, i8** %117
store i8* %118, i8** %7
br label %119
119: ; preds = %128, %116
%120 = load i8*, i8** %7
%121 = load i8, i8* %120
%122 = icmp ne i8 %121, 0
br i1 %122, label %123, label %131
123: ; preds = %119
%124 = load i8*, i8** %7
%125 = load i8, i8* %124
%126 = call signext i8 @tolower(i8 signext %125)
%127 = load i8*, i8** %7
store i8 %126, i8* %127
br label %128
128: ; preds = %123
%129 = load i8*, i8** %7
%130 = getelementptr inbounds i8, i8* %129, i32 1
store i8* %130, i8** %7
br label %119
131: ; preds = %119
ret void
}

LLVM IR (-O2):
@.str = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/mrash/psad/refs/heads/master/deps/whois/whois.c\00"
define void @split_server_port(i8* %0, i8** nocapture %1, i8** nocapture writeonly %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 91
br i1 %5, label %6, label %29
6: ; preds = %3
%7 = tail call i8* @strchr(i8* %0, i8 signext 93)
%8 = icmp eq i8* %7, null
br i1 %8, label %29, label %9
9: ; preds = %6
%10 = ptrtoint i8* %7 to i64
%11 = ptrtoint i8* %0 to i64
%12 = xor i64 %11, -1
%13 = add i64 %10, %12
%14 = trunc i64 %13 to i32
%15 = add nsw i32 %14, 1
%16 = tail call i32 @malloc(i32 %15)
%17 = tail call i8* @do_nofail(i32 %16, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 1231)
store i8* %17, i8** %1
%18 = getelementptr inbounds i8, i8* %0, i64 1
%19 = tail call i32 @memcpy(i8* %17, i8* %18, i32 %14)
%20 = shl i64 %13, 32
%21 = ashr exact i64 %20, 32
%22 = getelementptr inbounds i8, i8* %17, i64 %21
store i8 0, i8* %22
%23 = tail call i8* @strchr(i8* %7, i8 signext 58)
%24 = icmp eq i8* %23, null
br i1 %24, label %56, label %25
25: ; preds = %9
%26 = getelementptr inbounds i8, i8* %23, i64 1
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %56, label %50
29: ; preds = %6, %3
%30 = tail call i8* @strchr(i8* %0, i8 signext 58)
%31 = icmp eq i8* %30, null
br i1 %31, label %50, label %32
32: ; preds = %29
%33 = getelementptr inbounds i8, i8* %30, i64 1
%34 = tail call i8* @strchr(i8* %33, i8 signext 58)
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %50
36: ; preds = %32
%37 = ptrtoint i8* %30 to i64
%38 = ptrtoint i8* %0 to i64
%39 = sub i64 %37, %38
%40 = trunc i64 %39 to i32
%41 = add nsw i32 %40, 1
%42 = tail call i32 @malloc(i32 %41)
%43 = tail call i8* @do_nofail(i32 %42, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 1245)
store i8* %43, i8** %1
%44 = tail call i32 @memcpy(i8* %43, i8* %0, i32 %40)
%45 = shl i64 %39, 32
%46 = ashr exact i64 %45, 32
%47 = getelementptr inbounds i8, i8* %43, i64 %46
store i8 0, i8* %47
%48 = load i8, i8* %33
%49 = icmp eq i8 %48, 0
br i1 %49, label %56, label %50
50: ; preds = %29, %36, %32, %25
%51 = phi i8* [ %26, %25 ], [ %0, %32 ], [ %33, %36 ], [ %0, %29 ]
%52 = phi i32 [ 1237, %25 ], [ 1240, %32 ], [ 1251, %36 ], [ 1253, %29 ]
%53 = phi i8** [ %2, %25 ], [ %1, %32 ], [ %2, %36 ], [ %1, %29 ]
%54 = tail call i32 @strdup(i8* %51)
%55 = tail call i8* @do_nofail(i32 %54, i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 %52)
store i8* %55, i8** %53
br label %56
56: ; preds = %50, %36, %9, %25
%57 = load i8*, i8** %1
%58 = load i8, i8* %57
%59 = icmp eq i8 %58, 0
br i1 %59, label %67, label %60
60: ; preds = %56, %60
%61 = phi i8 [ %65, %60 ], [ %58, %56 ]
%62 = phi i8* [ %64, %60 ], [ %57, %56 ]
%63 = tail call signext i8 @tolower(i8 signext %61)
store i8 %63, i8* %62
%64 = getelementptr inbounds i8, i8* %62, i64 1
%65 = load i8, i8* %64
%66 = icmp eq i8 %65, 0
br i1 %66, label %67, label %60
67: ; preds = %60, %56
ret void
}