#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 */
int /*<<< orphan*/ free(char *);
char *strchr(char *, char);
char *strdup(char const *);
int split_user_passwd(const char *in, char **user, char **passwd) {
  char *pass, *tmp = strdup(in);
  int ret = 0;
  if (!tmp)
    return 0;
  pass = strchr(tmp, ':');
  if (!pass)
    goto fail;
  *pass = 0;
  pass++;
  *user = strdup(tmp);
  *passwd = strdup(pass);
  if (*user && *passwd)
    ret = 1;
fail:
  free(tmp);
  return ret;
}


x86 assembly (clang, -O0):
<split_user_passwd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    116f <split_user_passwd+0x3f>
movl   $0x0,-0x4(%rbp)
jmp    1201 <split_user_passwd+0xd1>
mov    -0x30(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1191 <split_user_passwd+0x61>
jmp    11f2 <split_user_passwd+0xc2>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11ed <split_user_passwd+0xbd>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11ed <split_user_passwd+0xbd>
movl   $0x1,-0x34(%rbp)
jmp    11f2 <split_user_passwd+0xc2>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_user_passwd>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
call   1050 <strdup@plt>
test   %rax,%rax
je     1190 <split_user_passwd+0x60>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1194 <split_user_passwd+0x64>
mov    %rax,%rbp
movb   $0x0,(%rax)
add    $0x1,%rbp
mov    %rbx,%rdi
call   1050 <strdup@plt>
mov    %rax,(%r14)
mov    %rbp,%rdi
call   1050 <strdup@plt>
mov    %rax,(%r15)
cmpq   $0x0,(%r14)
setne  %cl
test   %rax,%rax
setne  %al
and    %cl,%al
movzbl %al,%ebp
jmp    1196 <split_user_passwd+0x66>
xor    %ebp,%ebp
jmp    119e <split_user_passwd+0x6e>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @split_user_passwd(i8* %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%11 = load i8*, i8** %5
%12 = call i8* @strdup(i8* %11)
store i8* %12, i8** %9
store i32 0, i32* %10
%13 = load i8*, i8** %9
%14 = icmp ne i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %3
store i32 0, i32* %4
br label %45
16: ; preds = %3
%17 = load i8*, i8** %9
%18 = call i8* @strchr(i8* %17, i8 signext 58)
store i8* %18, i8** %8
%19 = load i8*, i8** %8
%20 = icmp ne i8* %19, null
br i1 %20, label %22, label %21
21: ; preds = %16
br label %41
22: ; preds = %16
%23 = load i8*, i8** %8
store i8 0, i8* %23
%24 = load i8*, i8** %8
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %8
%26 = load i8*, i8** %9
%27 = call i8* @strdup(i8* %26)
%28 = load i8**, i8*** %6
store i8* %27, i8** %28
%29 = load i8*, i8** %8
%30 = call i8* @strdup(i8* %29)
%31 = load i8**, i8*** %7
store i8* %30, i8** %31
%32 = load i8**, i8*** %6
%33 = load i8*, i8** %32
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %40
35: ; preds = %22
%36 = load i8**, i8*** %7
%37 = load i8*, i8** %36
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %40
39: ; preds = %35
store i32 1, i32* %10
br label %40
40: ; preds = %39, %35, %22
br label %41
41: ; preds = %40, %21
%42 = load i8*, i8** %9
%43 = call i32 @free(i8* %42)
%44 = load i32, i32* %10
store i32 %44, i32* %4
br label %45
45: ; preds = %41, %15
%46 = load i32, i32* %4
ret i32 %46
}

LLVM IR (-O2):
define i32 @split_user_passwd(i8* nocapture %0, i8** nocapture %1, i8** nocapture writeonly %2) {
%4 = tail call i8* @strdup(i8* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %21, label %6
6: ; preds = %3
%7 = tail call i8* @strchr(i8* %4, i8 signext 58)
%8 = icmp eq i8* %7, null
br i1 %8, label %18, label %9
9: ; preds = %6
store i8 0, i8* %7
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = tail call i8* @strdup(i8* %4)
store i8* %11, i8** %1
%12 = tail call i8* @strdup(i8* %10)
store i8* %12, i8** %2
%13 = load i8*, i8** %1
%14 = icmp ne i8* %13, null
%15 = icmp ne i8* %12, null
%16 = select i1 %14, i1 %15, i1 false
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %9, %6
%19 = phi i32 [ 0, %6 ], [ %17, %9 ]
%20 = tail call i32 @free(i8* %4)
br label %21
21: ; preds = %3, %18
%22 = phi i32 [ %19, %18 ], [ 0, %3 ]
ret i32 %22
}