#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 *calloc(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int strnlen(char *, int);
char *strstr(char *, char *);
int /*<<< orphan*/ usage();
void extract_parts(char *composite, char **name_p, char **proto_p,
                   char **host_p, char **port_p) {
  char *tok, *pristine;
  int pristine_len = strnlen(composite, 255);
  pristine = calloc(pristine_len + 1, sizeof(char));
  strncpy(pristine, composite, pristine_len);
  if ((tok = strchr(composite, '='))) {
    *tok = '\0';
    *name_p = composite;
    *proto_p = tok + 1;
  } else {
    *proto_p = composite;
  }
  if (strncmp("tcp", *proto_p, 3)) {
    fprintf(stderr, "Unsupported protocol (currently only tcp): %s\n",
            pristine);
    usage();
  }
  if ((tok = strstr(*proto_p, "://"))) {
    *tok = '\0';
    *host_p = tok + 3;
  } else {
    fprintf(stderr, "Invailid argument (missing ://): %s\n", pristine);
    usage();
  }
  if ((tok = strchr(*host_p, ':'))) {
    *tok = '\0';
    *port_p = tok + 1;
  } else {
    fprintf(stderr, "Invailid argument (missing port): %s\n", pristine);
    usage();
  }
  free(pristine);
}


x86 assembly (clang, -O0):
<extract_parts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0xff,%esi
call   1070 <strnlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x3c(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x8(%rbp),%rdi
mov    $0x3d,%esi
call   1060 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1223 <extract_parts+0x93>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rcx
add    $0x1,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    122e <extract_parts+0x9e>
mov    -0x8(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xdc4(%rip),%rdi
mov    $0x3,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     1270 <extract_parts+0xe0>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xda0(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x0,%al
call   10a0 <usage@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xdb5(%rip),%rsi
call   10b0 <strstr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     12ac <extract_parts+0x11c>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rcx
add    $0x3,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    12cc <extract_parts+0x13c>
mov    0x2d2d(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xd77(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x0,%al
call   10a0 <usage@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    $0x3a,%esi
call   1060 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1306 <extract_parts+0x176>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rcx
add    $0x1,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
jmp    1326 <extract_parts+0x196>
mov    0x2cd3(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xd42(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x0,%al
call   10a0 <usage@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_parts>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,(%rsp)
mov    %rcx,%r15
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    $0xff,%esi
call   1070 <strnlen@plt>
mov    %eax,%r14d
lea    0x1(%r14),%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1040 <strncpy@plt>
mov    %rbx,%rdi
mov    $0x3d,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     11f7 <extract_parts+0x67>
movb   $0x0,(%rax)
mov    %rbx,0x0(%rbp)
add    $0x1,%rax
mov    %rax,%rbx
mov    %rbx,0x0(%r13)
lea    0xdfe(%rip),%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
je     1233 <extract_parts+0xa3>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
lea    0xde0(%rip),%rsi
mov    %r12,%rdx
call   1090 <fprintf@plt>
xor    %eax,%eax
call   10a0 <usage@plt>
mov    0x0(%r13),%rdi
lea    0xdf5(%rip),%rsi
call   10b0 <strstr@plt>
test   %rax,%rax
je     1254 <extract_parts+0xc4>
movb   $0x0,(%rax)
add    $0x3,%rax
mov    %rax,(%r15)
jmp    1276 <extract_parts+0xe6>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
lea    0xdd3(%rip),%rsi
mov    %r12,%rdx
call   1090 <fprintf@plt>
xor    %eax,%eax
call   10a0 <usage@plt>
mov    (%r15),%rax
mov    %rax,%rdi
mov    $0x3a,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     1298 <extract_parts+0x108>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    (%rsp),%rcx
mov    %rax,(%rcx)
jmp    12b7 <extract_parts+0x127>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
lea    0xdb4(%rip),%rsi
mov    %r12,%rdx
call   1090 <fprintf@plt>
xor    %eax,%eax
call   10a0 <usage@plt>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"tcp\00"
@stderr = global i32 0
@.str.1 = [47 x i8] c"Unsupported protocol (currently only tcp): %s\0A\00"
@.str.2 = [4 x i8] c"://\00"
@.str.3 = [37 x i8] c"Invailid argument (missing ://): %s\0A\00"
@.str.4 = [38 x i8] c"Invailid argument (missing port): %s\0A\00"
define void @extract_parts(i8* %0, i8** %1, i8** %2, i8** %3, i8** %4) {
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8**
%10 = alloca i8**
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i8** %3, i8*** %9
store i8** %4, i8*** %10
%14 = load i8*, i8** %6
%15 = call i32 @strnlen(i8* %14, i32 255)
store i32 %15, i32* %13
%16 = load i32, i32* %13
%17 = add nsw i32 %16, 1
%18 = call i8* @calloc(i32 %17, i32 1)
store i8* %18, i8** %12
%19 = load i8*, i8** %12
%20 = load i8*, i8** %6
%21 = load i32, i32* %13
%22 = call i32 @strncpy(i8* %19, i8* %20, i32 %21)
%23 = load i8*, i8** %6
%24 = call i8* @strchr(i8* %23, i8 signext 61)
store i8* %24, i8** %11
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %33
26: ; preds = %5
%27 = load i8*, i8** %11
store i8 0, i8* %27
%28 = load i8*, i8** %6
%29 = load i8**, i8*** %7
store i8* %28, i8** %29
%30 = load i8*, i8** %11
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8**, i8*** %8
store i8* %31, i8** %32
br label %36
33: ; preds = %5
%34 = load i8*, i8** %6
%35 = load i8**, i8*** %8
store i8* %34, i8** %35
br label %36
36: ; preds = %33, %26
%37 = load i8**, i8*** %8
%38 = load i8*, i8** %37
%39 = call i64 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %38, i32 3)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %36
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %12
%44 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* %43)
%45 = call i32 (...) @usage()
br label %46
46: ; preds = %41, %36
%47 = load i8**, i8*** %8
%48 = load i8*, i8** %47
%49 = call i8* @strstr(i8* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i8* %49, i8** %11
%50 = icmp ne i8* %49, null
br i1 %50, label %51, label %56
51: ; preds = %46
%52 = load i8*, i8** %11
store i8 0, i8* %52
%53 = load i8*, i8** %11
%54 = getelementptr inbounds i8, i8* %53, i64 3
%55 = load i8**, i8*** %9
store i8* %54, i8** %55
br label %61
56: ; preds = %46
%57 = load i32, i32* @stderr
%58 = load i8*, i8** %12
%59 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %58)
%60 = call i32 (...) @usage()
br label %61
61: ; preds = %56, %51
%62 = load i8**, i8*** %9
%63 = load i8*, i8** %62
%64 = call i8* @strchr(i8* %63, i8 signext 58)
store i8* %64, i8** %11
%65 = icmp ne i8* %64, null
br i1 %65, label %66, label %71
66: ; preds = %61
%67 = load i8*, i8** %11
store i8 0, i8* %67
%68 = load i8*, i8** %11
%69 = getelementptr inbounds i8, i8* %68, i64 1
%70 = load i8**, i8*** %10
store i8* %69, i8** %70
br label %76
71: ; preds = %61
%72 = load i32, i32* @stderr
%73 = load i8*, i8** %12
%74 = call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i8* %73)
%75 = call i32 (...) @usage()
br label %76
76: ; preds = %71, %66
%77 = load i8*, i8** %12
%78 = call i32 @free(i8* %77)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"tcp\00"
@stderr = global i32 0
@.str.1 = [47 x i8] c"Unsupported protocol (currently only tcp): %s\0A\00"
@.str.2 = [4 x i8] c"://\00"
@.str.3 = [37 x i8] c"Invailid argument (missing ://): %s\0A\00"
@.str.4 = [38 x i8] c"Invailid argument (missing port): %s\0A\00"
define void @extract_parts(i8* %0, i8** nocapture writeonly %1, i8** nocapture %2, i8** nocapture %3, i8** nocapture writeonly %4) {
%6 = tail call i32 @strnlen(i8* %0, i32 255)
%7 = add nsw i32 %6, 1
%8 = tail call i8* @calloc(i32 %7, i32 1)
%9 = tail call i32 @strncpy(i8* %8, i8* %0, i32 %6)
%10 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 61)
%11 = icmp eq i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %5
store i8 0, i8* %10
store i8* %0, i8** %1
%13 = getelementptr inbounds i8, i8* %10, i64 1
br label %14
14: ; preds = %5, %12
%15 = phi i8* [ %13, %12 ], [ %0, %5 ]
store i8* %15, i8** %2
%16 = tail call i64 @strncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15, i32 3)
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%21 = tail call i32 (...) @usage()
br label %22
22: ; preds = %18, %14
%23 = load i8*, i8** %2
%24 = tail call i8* @strstr(i8* dereferenceable(1) %23, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i8* %24, null
br i1 %25, label %28, label %26
26: ; preds = %22
store i8 0, i8* %24
%27 = getelementptr inbounds i8, i8* %24, i64 3
store i8* %27, i8** %3
br label %33
28: ; preds = %22
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%31 = tail call i32 (...) @usage()
%32 = load i8*, i8** %3
br label %33
33: ; preds = %28, %26
%34 = phi i8* [ %32, %28 ], [ %27, %26 ]
%35 = tail call i8* @strchr(i8* dereferenceable(1) %34, i8 signext 58)
%36 = icmp eq i8* %35, null
br i1 %36, label %39, label %37
37: ; preds = %33
store i8 0, i8* %35
%38 = getelementptr inbounds i8, i8* %35, i64 1
store i8* %38, i8** %4
br label %43
39: ; preds = %33
%40 = load i32, i32* @stderr
%41 = tail call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%42 = tail call i32 (...) @usage()
br label %43
43: ; preds = %39, %37
%44 = tail call i32 @free(i8* %8)
ret void
}