#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*/ FatalErrnoError(int, int, char *);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
struct passwd *getpwnam(char const *);
int strlen(char const *);
int /*<<< orphan*/ write(int, char const *, int);
struct passwd const *Egetpwnam(char const *name) {
  struct passwd const *res;
  errno = 0;
  res = getpwnam(name);
  FatalErrnoError(res == 0 && errno != 0, 1, "getpwnam()");
  if (res == 0) {
    write(2, "getpwnam(\"", 10);
    write(2, name, strlen(name));
    write(2, "\"): no such user\n", 17);
    exit(1);
  }
  return res;
}


x86 assembly (clang, -O0):
<Egetpwnam>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e7d(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1050 <getpwnam@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x11(%rbp)
jne    1198 <Egetpwnam+0x48>
mov    0x2e52(%rip),%rax
cmpq   $0x0,(%rax)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x1,%esi
lea    0xe54(%rip),%rdx
call   1060 <FatalErrnoError@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1213 <Egetpwnam+0xc3>
mov    $0x2,%edi
lea    0xe43(%rip),%rsi
mov    $0xa,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
mov    $0x2,%edi
call   1030 <write@plt>
mov    $0x2,%edi
lea    0xe17(%rip),%rsi
mov    $0x11,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Egetpwnam>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    0x2e81(%rip),%r15
movq   $0x0,(%r15)
call   1050 <getpwnam@plt>
mov    %rax,%rbx
test   %rax,%rax
sete   %al
cmpq   $0x0,(%r15)
setne  %cl
and    %al,%cl
movzbl %cl,%edi
lea    0xe79(%rip),%rdx
mov    $0x1,%esi
call   1060 <FatalErrnoError@plt>
test   %rbx,%rbx
je     119f <Egetpwnam+0x4f>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe65(%rip),%rsi
mov    $0x2,%edi
mov    $0xa,%edx
call   1030 <write@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    $0x2,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xe43(%rip),%rsi
mov    $0x2,%edi
mov    $0x11,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.passwd = type { i32 }
@errno = global i64 0
@.str = [11 x i8] c"getpwnam()\00"
@.str.1 = [11 x i8] c"getpwnam(\22\00"
@.str.2 = [18 x i8] c"\22): no such user\0A\00"
define %struct.passwd* @Egetpwnam(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.passwd*
store i8* %0, i8** %2
store i64 0, i64* @errno
%4 = load i8*, i8** %2
%5 = call %struct.passwd* @getpwnam(i8* %4)
store %struct.passwd* %5, %struct.passwd** %3
%6 = load %struct.passwd*, %struct.passwd** %3
%7 = icmp eq %struct.passwd* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i64, i64* @errno
%10 = icmp ne i64 %9, 0
br label %11
11: ; preds = %8, %1
%12 = phi i1 [ false, %1 ], [ %10, %8 ]
%13 = zext i1 %12 to i32
%14 = call i32 @FatalErrnoError(i32 %13, i32 1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%15 = load %struct.passwd*, %struct.passwd** %3
%16 = icmp eq %struct.passwd* %15, null
br i1 %16, label %17, label %25
17: ; preds = %11
%18 = call i32 @write(i32 2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 10)
%19 = load i8*, i8** %2
%20 = load i8*, i8** %2
%21 = call i32 @strlen(i8* %20)
%22 = call i32 @write(i32 2, i8* %19, i32 %21)
%23 = call i32 @write(i32 2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 17)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %11
%26 = load %struct.passwd*, %struct.passwd** %3
ret %struct.passwd* %26
}

LLVM IR (-O2):
%struct.passwd = type { i32 }
@errno = global i64 0
@.str = [11 x i8] c"getpwnam()\00"
@.str.1 = [11 x i8] c"getpwnam(\22\00"
@.str.2 = [18 x i8] c"\22): no such user\0A\00"
define %struct.passwd* @Egetpwnam(i8* %0) {
store i64 0, i64* @errno
%2 = tail call %struct.passwd* @getpwnam(i8* %0)
%3 = icmp eq %struct.passwd* %2, null
%4 = load i64, i64* @errno
%5 = icmp ne i64 %4, 0
%6 = select i1 %3, i1 %5, i1 false
%7 = zext i1 %6 to i32
%8 = tail call i32 @FatalErrnoError(i32 %7, i32 1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br i1 %3, label %9, label %15
9: ; preds = %1
%10 = tail call i32 @write(i32 2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 10)
%11 = tail call i32 @strlen(i8* %0)
%12 = tail call i32 @write(i32 2, i8* %0, i32 %11)
%13 = tail call i32 @write(i32 2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 17)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %1
ret %struct.passwd* %2
}