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

/* Variables and functions */
int /*<<< orphan*/ errx(int, char *, char *);
struct passwd *getpwnam(char *);
struct passwd *getpwuid(long);
long strtol(char *, char **, int);
struct passwd *who(char *u) {
  struct passwd *pw;
  long id;
  char *ep;
  if ((pw = getpwnam(u)) != NULL)
    return pw;
  id = strtol(u, &ep, 10);
  if (*u && !*ep && (pw = getpwuid(id)))
    return pw;
  errx(1, "%s: No such user", u);
  return NULL;
}


x86 assembly (clang, -O0):
<who>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1170 <who+0x30>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11e4 <who+0xa4>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c7 <who+0x87>
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11c7 <who+0x87>
mov    -0x20(%rbp),%rdi
call   1030 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11c7 <who+0x87>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11e4 <who+0xa4>
mov    -0x10(%rbp),%rdx
mov    $0x1,%edi
lea    0xe29(%rip),%rsi
call   1040 <errx@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<who>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1050 <getpwnam@plt>
test   %rax,%rax
jne    1189 <who+0x49>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1060 <strtol@plt>
cmpb   $0x0,(%rbx)
je     1173 <who+0x33>
mov    0x8(%rsp),%rcx
cmpb   $0x0,(%rcx)
je     118f <who+0x4f>
lea    0xe86(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
call   1040 <errx@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    %rax,%rdi
call   1030 <getpwuid@plt>
test   %rax,%rax
jne    1189 <who+0x49>
jmp    1173 <who+0x33>

LLVM IR (-O0):
%struct.passwd = type { i32 }
@.str = [17 x i8] c"%s: No such user\00"
define %struct.passwd* @who(i8* %0) {
%2 = alloca %struct.passwd*
%3 = alloca i8*
%4 = alloca %struct.passwd*
%5 = alloca i64
%6 = alloca i8*
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call %struct.passwd* @getpwnam(i8* %7)
store %struct.passwd* %8, %struct.passwd** %4
%9 = icmp ne %struct.passwd* %8, null
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load %struct.passwd*, %struct.passwd** %4
store %struct.passwd* %11, %struct.passwd** %2
br label %32
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i64 @strtol(i8* %13, i8** %6, i32 10)
store i64 %14, i64* %5
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %12
%20 = load i8*, i8** %6
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %19
%24 = load i64, i64* %5
%25 = call %struct.passwd* @getpwuid(i64 %24)
store %struct.passwd* %25, %struct.passwd** %4
%26 = icmp ne %struct.passwd* %25, null
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = load %struct.passwd*, %struct.passwd** %4
store %struct.passwd* %28, %struct.passwd** %2
br label %32
29: ; preds = %23, %19, %12
%30 = load i8*, i8** %3
%31 = call i32 @errx(i32 1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %30)
store %struct.passwd* null, %struct.passwd** %2
br label %32
32: ; preds = %29, %27, %10
%33 = load %struct.passwd*, %struct.passwd** %2
ret %struct.passwd* %33
}

LLVM IR (-O2):
%struct.passwd = type { i32 }
@.str = [17 x i8] c"%s: No such user\00"
define %struct.passwd* @who(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = tail call %struct.passwd* @getpwnam(i8* %0)
%5 = icmp eq %struct.passwd* %4, null
br i1 %5, label %6, label %19
6: ; preds = %1
%7 = call i64 @strtol(i8* %0, i8** %2, i32 10)
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %6
%11 = load i8*, i8** %2
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = tail call %struct.passwd* @getpwuid(i64 %7)
%16 = icmp eq %struct.passwd* %15, null
br i1 %16, label %17, label %19
17: ; preds = %14, %10, %6
%18 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %19
19: ; preds = %14, %1, %17
%20 = phi %struct.passwd* [ null, %17 ], [ %4, %1 ], [ %15, %14 ]
ret %struct.passwd* %20
}