#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;
struct passwd {
  int /*<<< orphan*/ pw_uid;
};

/* Variables and functions */
int /*<<< orphan*/ errx(int, char *);
struct passwd *getpwnam(char const *);
int /*<<< orphan*/ id(char const *, char *);
uid_t a_uid(const char *s) {
  struct passwd *pw;
  if (*s == '\0')
    errx(1, "owner must be specified when the group is");
  return ((pw = getpwnam(s)) == NULL) ? id(s, "user") : pw->pw_uid;
}


x86 assembly (clang, -O0):
<a_uid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    115d <a_uid+0x2d>
mov    $0x1,%edi
lea    0xea8(%rip),%rsi
call   1030 <errx@plt>
mov    -0x8(%rbp),%rdi
call   1040 <getpwnam@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    118c <a_uid+0x5c>
mov    -0x8(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1050 <id@plt>
mov    %eax,-0x14(%rbp)
jmp    1195 <a_uid+0x65>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<a_uid>:
push   %rbx
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
jne    114a <a_uid+0x1a>
lea    0xec0(%rip),%rsi
mov    $0x1,%edi
call   1030 <errx@plt>
mov    %rbx,%rdi
call   1040 <getpwnam@plt>
test   %rax,%rax
je     115b <a_uid+0x2b>
mov    (%rax),%eax
pop    %rbx
ret
lea    0xec8(%rip),%rsi
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <id@plt>

LLVM IR (-O0):
%struct.passwd = type { i32 }
@.str = [42 x i8] c"owner must be specified when the group is\00"
@.str.1 = [5 x i8] c"user\00"
define i32 @a_uid(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.passwd*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @errx(i32 1, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = load i8*, i8** %2
%12 = call %struct.passwd* @getpwnam(i8* %11)
store %struct.passwd* %12, %struct.passwd** %3
%13 = icmp eq %struct.passwd* %12, null
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i8*, i8** %2
%16 = call i32 @id(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %21
17: ; preds = %10
%18 = load %struct.passwd*, %struct.passwd** %3
%19 = getelementptr inbounds %struct.passwd, %struct.passwd* %18, i32 0, i32 0
%20 = load i32, i32* %19
br label %21
21: ; preds = %17, %14
%22 = phi i32 [ %16, %14 ], [ %20, %17 ]
ret i32 %22
}

LLVM IR (-O2):
%struct.passwd = type { i32 }
@.str = [42 x i8] c"owner must be specified when the group is\00"
@.str.1 = [5 x i8] c"user\00"
define i32 @a_uid(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = tail call %struct.passwd* @getpwnam(i8* %0)
%8 = icmp eq %struct.passwd* %7, null
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @id(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %14
11: ; preds = %6
%12 = getelementptr inbounds %struct.passwd, %struct.passwd* %7, i64 0, i32 0
%13 = load i32, i32* %12
br label %14
14: ; preds = %11, %9
%15 = phi i32 [ %10, %9 ], [ %13, %11 ]
ret i32 %15
}