#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 */
typedef int /*<<< orphan*/ uid_t;
typedef int /*<<< orphan*/ gid_t;

/* Variables and functions */
int parse_gid(char *, int /*<<< orphan*/ *);
int parse_uid(char *, int /*<<< orphan*/ *);
char *strchr(char *, char);
int parse_owner(char *str, uid_t *uid, gid_t *gid) {
  int r = 0;
  char *group;
  if (!uid)
    return parse_gid(str, gid);
  if (!gid)
    return parse_uid(str, uid);
  group = strchr(str, ':');
  *group++ = 0;
  r = parse_gid(group, gid);
  if (r)
    return r;
  return parse_uid(str, uid);
}


x86 assembly (clang, -O0):
<parse_owner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116b <parse_owner+0x3b>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <parse_gid@plt>
mov    %eax,-0x4(%rbp)
jmp    11e4 <parse_owner+0xb4>
cmpq   $0x0,-0x20(%rbp)
jne    118b <parse_owner+0x5b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <parse_uid@plt>
mov    %eax,-0x4(%rbp)
jmp    11e4 <parse_owner+0xb4>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <parse_gid@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11d4 <parse_owner+0xa4>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11e4 <parse_owner+0xb4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <parse_uid@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_owner>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rdi,%r14
test   %rsi,%rsi
je     116e <parse_owner+0x3e>
mov    %rsi,%r15
test   %rbx,%rbx
je     117e <parse_owner+0x4e>
mov    %r14,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
movb   $0x0,(%rax)
lea    0x1(%rax),%rdi
mov    %rbx,%rsi
call   1030 <parse_gid@plt>
test   %eax,%eax
je     117e <parse_owner+0x4e>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r14,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <parse_gid@plt>
mov    %r14,%rdi
mov    %r15,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <parse_uid@plt>

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

LLVM IR (-O2):
define i32 @parse_owner(i8* %0, i32* %1, i32* %2) {
%4 = icmp eq i32* %1, null
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @parse_gid(i8* %0, i32* %2)
br label %18
7: ; preds = %3
%8 = icmp eq i32* %2, null
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 @parse_uid(i8* %0, i32* %1)
br label %18
11: ; preds = %7
%12 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
%13 = getelementptr inbounds i8, i8* %12, i64 1
store i8 0, i8* %12
%14 = tail call i32 @parse_gid(i8* %13, i32* %2)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = tail call i32 @parse_uid(i8* %0, i32* %1)
br label %18
18: ; preds = %11, %16, %9, %5
%19 = phi i32 [ %17, %16 ], [ %10, %9 ], [ %6, %5 ], [ %14, %11 ]
ret i32 %19
}