#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 *memchr(char const *, char, int);
char *strdupdelim(char const *, char const *);
int /*<<< orphan*/ url_unescape(char *);
int parse_credentials(const char *beg, const char *end, char **user,
                      char **passwd) {
  char *colon;
  const char *userend;
  if (beg == end)
    return 0;
  colon = memchr(beg, ':', end - beg);
  if (colon == beg)
    return 0;
  if (colon) {
    *passwd = strdupdelim(colon + 1, end);
    userend = colon;
    url_unescape(*passwd);
  } else {
    *passwd = NULL;
    userend = end;
  }
  *user = strdupdelim(beg, userend);
  url_unescape(*user);
  return 1;
}


x86 assembly (clang, -O0):
<parse_credentials>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    1162 <parse_credentials+0x32>
movl   $0x0,-0x4(%rbp)
jmp    1217 <parse_credentials+0xe7>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
mov    $0x3a,%esi
call   1040 <memchr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    119b <parse_credentials+0x6b>
movl   $0x0,-0x4(%rbp)
jmp    1217 <parse_credentials+0xe7>
cmpq   $0x0,-0x30(%rbp)
je     11da <parse_credentials+0xaa>
mov    -0x30(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strdupdelim@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
call   1030 <url_unescape@plt>
jmp    11ed <parse_credentials+0xbd>
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <strdupdelim@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1030 <url_unescape@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_credentials>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %ebp,%ebp
cmp    %rsi,%rdi
je     11ad <parse_credentials+0x7d>
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %r15d,%edx
sub    %ebx,%edx
mov    $0x3a,%esi
call   1040 <memchr@plt>
cmp    %rbx,%rax
je     11ad <parse_credentials+0x7d>
mov    %rax,%r13
test   %rax,%rax
je     118a <parse_credentials+0x5a>
mov    %r13,%rdi
add    $0x1,%rdi
mov    %r15,%rsi
call   1050 <strdupdelim@plt>
mov    %rax,(%r12)
mov    %rax,%rdi
call   1030 <url_unescape@plt>
mov    %r13,%r15
jmp    1192 <parse_credentials+0x62>
movq   $0x0,(%r12)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strdupdelim@plt>
mov    %rax,(%r14)
mov    %rax,%rdi
call   1030 <url_unescape@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @parse_credentials(i8* %0, i8* %1, i8** %2, i8** %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca i8**
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8** %2, i8*** %8
store i8** %3, i8*** %9
%12 = load i8*, i8** %6
%13 = load i8*, i8** %7
%14 = icmp eq i8* %12, %13
br i1 %14, label %15, label %16
15: ; preds = %4
store i32 0, i32* %5
br label %53
16: ; preds = %4
%17 = load i8*, i8** %6
%18 = load i8*, i8** %7
%19 = load i8*, i8** %6
%20 = ptrtoint i8* %18 to i64
%21 = ptrtoint i8* %19 to i64
%22 = sub i64 %20, %21
%23 = trunc i64 %22 to i32
%24 = call i8* @memchr(i8* %17, i8 signext 58, i32 %23)
store i8* %24, i8** %10
%25 = load i8*, i8** %10
%26 = load i8*, i8** %6
%27 = icmp eq i8* %25, %26
br i1 %27, label %28, label %29
28: ; preds = %16
store i32 0, i32* %5
br label %53
29: ; preds = %16
%30 = load i8*, i8** %10
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %42
32: ; preds = %29
%33 = load i8*, i8** %10
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = load i8*, i8** %7
%36 = call i8* @strdupdelim(i8* %34, i8* %35)
%37 = load i8**, i8*** %9
store i8* %36, i8** %37
%38 = load i8*, i8** %10
store i8* %38, i8** %11
%39 = load i8**, i8*** %9
%40 = load i8*, i8** %39
%41 = call i32 @url_unescape(i8* %40)
br label %45
42: ; preds = %29
%43 = load i8**, i8*** %9
store i8* null, i8** %43
%44 = load i8*, i8** %7
store i8* %44, i8** %11
br label %45
45: ; preds = %42, %32
%46 = load i8*, i8** %6
%47 = load i8*, i8** %11
%48 = call i8* @strdupdelim(i8* %46, i8* %47)
%49 = load i8**, i8*** %8
store i8* %48, i8** %49
%50 = load i8**, i8*** %8
%51 = load i8*, i8** %50
%52 = call i32 @url_unescape(i8* %51)
store i32 1, i32* %5
br label %53
53: ; preds = %45, %28, %15
%54 = load i32, i32* %5
ret i32 %54
}

LLVM IR (-O2):
define i32 @parse_credentials(i8* %0, i8* %1, i8** nocapture writeonly %2, i8** nocapture writeonly %3) {
%5 = icmp eq i8* %0, %1
br i1 %5, label %24, label %6
6: ; preds = %4
%7 = ptrtoint i8* %1 to i64
%8 = ptrtoint i8* %0 to i64
%9 = sub i64 %7, %8
%10 = trunc i64 %9 to i32
%11 = tail call i8* @memchr(i8* %0, i8 signext 58, i32 %10)
%12 = icmp eq i8* %11, %0
br i1 %12, label %24, label %13
13: ; preds = %6
%14 = icmp eq i8* %11, null
br i1 %14, label %19, label %15
15: ; preds = %13
%16 = getelementptr inbounds i8, i8* %11, i64 1
%17 = tail call i8* @strdupdelim(i8* %16, i8* %1)
store i8* %17, i8** %3
%18 = tail call i32 @url_unescape(i8* %17)
br label %20
19: ; preds = %13
store i8* null, i8** %3
br label %20
20: ; preds = %19, %15
%21 = phi i8* [ %11, %15 ], [ %1, %19 ]
%22 = tail call i8* @strdupdelim(i8* %0, i8* %21)
store i8* %22, i8** %2
%23 = tail call i32 @url_unescape(i8* %22)
br label %24
24: ; preds = %6, %4, %20
%25 = phi i32 [ 1, %20 ], [ 0, %4 ], [ 0, %6 ]
ret i32 %25
}