#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 *strchr(char *, char);
char *strstr(char *, char *);
void parse_url(char *url, char **scheme, char **user, char **pass, char **host,
               char **port, char **path) {
  if (url) {
    char *scheme_end = strstr(url, "://");
    if (scheme_end) {
      *scheme_end = '\0';
      *scheme = url;
      url = scheme_end + 3;
    }
    char *at = strchr(url, '@');
    if (at) {
      *at = '\0';
      char *up = url;
      *user = up;
      url = at + 1;
      char *colon = strchr(up, ':');
      if (colon) {
        *colon = '\0';
        *pass = colon + 1;
      }
    }
    char *slash = strchr(url, '/');
    if (slash) {
      *slash = '\0';
      *host = url;
      url = slash + 1;
      *path = url;
    } else {
      *host = url;
    }
    char *colon = strchr(*host, ':');
    if (colon) {
      *colon = '\0';
      *port = colon + 1;
    }
  }
}


x86 assembly (clang, -O0):
<parse_url>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1298 <parse_url+0x178>
mov    -0x8(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     118c <parse_url+0x6c>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x40,%esi
call   1030 <strchr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1207 <parse_url+0xe7>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x48(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1202 <parse_url+0xe2>
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x50(%rbp),%rcx
add    $0x1,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    1207 <parse_url+0xe7>
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     1252 <parse_url+0x132>
mov    -0x58(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
mov    0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    125d <parse_url+0x13d>
mov    -0x8(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     1293 <parse_url+0x173>
mov    -0x60(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x60(%rbp),%rcx
add    $0x1,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
jmp    1298 <parse_url+0x178>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_url>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11f1 <parse_url+0xd1>
mov    %r9,%rbp
mov    %r8,%r12
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%rbx
lea    0xeb3(%rip),%rsi
call   1040 <strstr@plt>
test   %rax,%rax
je     1165 <parse_url+0x45>
movb   $0x0,(%rax)
mov    %rbx,0x0(%r13)
add    $0x3,%rax
mov    %rax,%rbx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11a2 <parse_url+0x82>
mov    %rax,%r13
movb   $0x0,(%rax)
mov    %rbx,(%r14)
add    $0x1,%r13
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11a5 <parse_url+0x85>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,(%r15)
jmp    11a5 <parse_url+0x85>
mov    %rbx,%r13
mov    %r13,%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11d0 <parse_url+0xb0>
mov    0x40(%rsp),%rcx
movb   $0x0,(%rax)
mov    %r13,(%r12)
add    $0x1,%rax
mov    %rax,(%rcx)
mov    (%r12),%r13
jmp    11d4 <parse_url+0xb4>
mov    %r13,(%r12)
mov    %r13,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11f1 <parse_url+0xd1>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,0x0(%rbp)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"://\00"
define void @parse_url(i8* %0, i8** %1, i8** %2, i8** %3, i8** %4, i8** %5, i8** %6) {
%8 = alloca i8*
%9 = alloca i8**
%10 = alloca i8**
%11 = alloca i8**
%12 = alloca i8**
%13 = alloca i8**
%14 = alloca i8**
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i8*
store i8* %0, i8** %8
store i8** %1, i8*** %9
store i8** %2, i8*** %10
store i8** %3, i8*** %11
store i8** %4, i8*** %12
store i8** %5, i8*** %13
store i8** %6, i8*** %14
%21 = load i8*, i8** %8
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %84
23: ; preds = %7
%24 = load i8*, i8** %8
%25 = call i8* @strstr(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %25, i8** %15
%26 = load i8*, i8** %15
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %34
28: ; preds = %23
%29 = load i8*, i8** %15
store i8 0, i8* %29
%30 = load i8*, i8** %8
%31 = load i8**, i8*** %9
store i8* %30, i8** %31
%32 = load i8*, i8** %15
%33 = getelementptr inbounds i8, i8* %32, i64 3
store i8* %33, i8** %8
br label %34
34: ; preds = %28, %23
%35 = load i8*, i8** %8
%36 = call i8* @strchr(i8* %35, i8 signext 64)
store i8* %36, i8** %16
%37 = load i8*, i8** %16
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %56
39: ; preds = %34
%40 = load i8*, i8** %16
store i8 0, i8* %40
%41 = load i8*, i8** %8
store i8* %41, i8** %17
%42 = load i8*, i8** %17
%43 = load i8**, i8*** %10
store i8* %42, i8** %43
%44 = load i8*, i8** %16
%45 = getelementptr inbounds i8, i8* %44, i64 1
store i8* %45, i8** %8
%46 = load i8*, i8** %17
%47 = call i8* @strchr(i8* %46, i8 signext 58)
store i8* %47, i8** %18
%48 = load i8*, i8** %18
%49 = icmp ne i8* %48, null
br i1 %49, label %50, label %55
50: ; preds = %39
%51 = load i8*, i8** %18
store i8 0, i8* %51
%52 = load i8*, i8** %18
%53 = getelementptr inbounds i8, i8* %52, i64 1
%54 = load i8**, i8*** %11
store i8* %53, i8** %54
br label %55
55: ; preds = %50, %39
br label %56
56: ; preds = %55, %34
%57 = load i8*, i8** %8
%58 = call i8* @strchr(i8* %57, i8 signext 47)
store i8* %58, i8** %19
%59 = load i8*, i8** %19
%60 = icmp ne i8* %59, null
br i1 %60, label %61, label %69
61: ; preds = %56
%62 = load i8*, i8** %19
store i8 0, i8* %62
%63 = load i8*, i8** %8
%64 = load i8**, i8*** %12
store i8* %63, i8** %64
%65 = load i8*, i8** %19
%66 = getelementptr inbounds i8, i8* %65, i64 1
store i8* %66, i8** %8
%67 = load i8*, i8** %8
%68 = load i8**, i8*** %14
store i8* %67, i8** %68
br label %72
69: ; preds = %56
%70 = load i8*, i8** %8
%71 = load i8**, i8*** %12
store i8* %70, i8** %71
br label %72
72: ; preds = %69, %61
%73 = load i8**, i8*** %12
%74 = load i8*, i8** %73
%75 = call i8* @strchr(i8* %74, i8 signext 58)
store i8* %75, i8** %20
%76 = load i8*, i8** %20
%77 = icmp ne i8* %76, null
br i1 %77, label %78, label %83
78: ; preds = %72
%79 = load i8*, i8** %20
store i8 0, i8* %79
%80 = load i8*, i8** %20
%81 = getelementptr inbounds i8, i8* %80, i64 1
%82 = load i8**, i8*** %13
store i8* %81, i8** %82
br label %83
83: ; preds = %78, %72
br label %84
84: ; preds = %83, %7
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"://\00"
define void @parse_url(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2, i8** nocapture writeonly %3, i8** nocapture %4, i8** nocapture writeonly %5, i8** nocapture writeonly %6) {
%8 = icmp eq i8* %0, null
br i1 %8, label %38, label %9
9: ; preds = %7
%10 = tail call i8* @strstr(i8* %0, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %9
store i8 0, i8* %10
store i8* %0, i8** %1
%13 = getelementptr inbounds i8, i8* %10, i64 3
br label %14
14: ; preds = %12, %9
%15 = phi i8* [ %13, %12 ], [ %0, %9 ]
%16 = tail call i8* @strchr(i8* %15, i8 signext 64)
%17 = icmp eq i8* %16, null
br i1 %17, label %24, label %18
18: ; preds = %14
store i8 0, i8* %16
store i8* %15, i8** %2
%19 = getelementptr inbounds i8, i8* %16, i64 1
%20 = tail call i8* @strchr(i8* %15, i8 signext 58)
%21 = icmp eq i8* %20, null
br i1 %21, label %24, label %22
22: ; preds = %18
store i8 0, i8* %20
%23 = getelementptr inbounds i8, i8* %20, i64 1
store i8* %23, i8** %3
br label %24
24: ; preds = %18, %22, %14
%25 = phi i8* [ %15, %14 ], [ %19, %22 ], [ %19, %18 ]
%26 = tail call i8* @strchr(i8* dereferenceable(1) %25, i8 signext 47)
%27 = icmp eq i8* %26, null
br i1 %27, label %31, label %28
28: ; preds = %24
store i8 0, i8* %26
store i8* %25, i8** %4
%29 = getelementptr inbounds i8, i8* %26, i64 1
store i8* %29, i8** %6
%30 = load i8*, i8** %4
br label %32
31: ; preds = %24
store i8* %25, i8** %4
br label %32
32: ; preds = %31, %28
%33 = phi i8* [ %25, %31 ], [ %30, %28 ]
%34 = tail call i8* @strchr(i8* dereferenceable(1) %33, i8 signext 58)
%35 = icmp eq i8* %34, null
br i1 %35, label %38, label %36
36: ; preds = %32
store i8 0, i8* %34
%37 = getelementptr inbounds i8, i8* %34, i64 1
store i8* %37, i8** %5
br label %38
38: ; preds = %32, %36, %7
ret void
}