#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 {
  scalar_t__ pw_passwd;
};

/* Variables and functions */
int /*<<< orphan*/ crypt(char const *, scalar_t__);
struct passwd *getpwnam(char const *);
int /*<<< orphan*/ strcmp(int /*<<< orphan*/, scalar_t__);
char const *_auth_attempt_login(char const *username, char const *password) {
  struct passwd *pwitem;
  pwitem = getpwnam(username);
  if (!pwitem)
    return NULL;
  if (password && pwitem->pw_passwd &&
      !strcmp(crypt(password, pwitem->pw_passwd), pwitem->pw_passwd))
    return username;
  return NULL;
}


x86 assembly (clang, -O0):
<_auth_attempt_login>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <getpwnam@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1165 <_auth_attempt_login+0x35>
movq   $0x0,-0x8(%rbp)
jmp    11ba <_auth_attempt_login+0x8a>
cmpq   $0x0,-0x18(%rbp)
je     11b2 <_auth_attempt_login+0x82>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11b2 <_auth_attempt_login+0x82>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
call   1030 <crypt@plt>
mov    %eax,%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11b2 <_auth_attempt_login+0x82>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ba <_auth_attempt_login+0x8a>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_auth_attempt_login>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <getpwnam@plt>
test   %rax,%rax
je     116b <_auth_attempt_login+0x3b>
test   %r14,%r14
je     116b <_auth_attempt_login+0x3b>
mov    %rax,%rbx
mov    (%rax),%rsi
test   %rsi,%rsi
je     116b <_auth_attempt_login+0x3b>
mov    %r14,%rdi
call   1030 <crypt@plt>
mov    (%rbx),%rsi
mov    %eax,%edi
call   1040 <strcmp@plt>
test   %eax,%eax
je     116e <_auth_attempt_login+0x3e>
xor    %r15d,%r15d
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.passwd = type { i64 }
define i8* @_auth_attempt_login(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.passwd*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call %struct.passwd* @getpwnam(i8* %7)
store %struct.passwd* %8, %struct.passwd** %6
%9 = load %struct.passwd*, %struct.passwd** %6
%10 = icmp ne %struct.passwd* %9, null
br i1 %10, label %12, label %11
11: ; preds = %2
store i8* null, i8** %3
br label %34
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %33
15: ; preds = %12
%16 = load %struct.passwd*, %struct.passwd** %6
%17 = getelementptr inbounds %struct.passwd, %struct.passwd* %16, i32 0, i32 0
%18 = load i64, i64* %17
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %33
20: ; preds = %15
%21 = load i8*, i8** %5
%22 = load %struct.passwd*, %struct.passwd** %6
%23 = getelementptr inbounds %struct.passwd, %struct.passwd* %22, i32 0, i32 0
%24 = load i64, i64* %23
%25 = call i32 @crypt(i8* %21, i64 %24)
%26 = load %struct.passwd*, %struct.passwd** %6
%27 = getelementptr inbounds %struct.passwd, %struct.passwd* %26, i32 0, i32 0
%28 = load i64, i64* %27
%29 = call i32 @strcmp(i32 %25, i64 %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %20
%32 = load i8*, i8** %4
store i8* %32, i8** %3
br label %34
33: ; preds = %20, %15, %12
store i8* null, i8** %3
br label %34
34: ; preds = %33, %31, %11
%35 = load i8*, i8** %3
ret i8* %35
}

LLVM IR (-O2):
%struct.passwd = type { i64 }
define i8* @_auth_attempt_login(i8* %0, i8* %1) {
%3 = tail call %struct.passwd* @getpwnam(i8* %0)
%4 = icmp eq %struct.passwd* %3, null
br i1 %4, label %17, label %5
5: ; preds = %2
%6 = icmp eq i8* %1, null
br i1 %6, label %16, label %7
7: ; preds = %5
%8 = getelementptr inbounds %struct.passwd, %struct.passwd* %3, i64 0, i32 0
%9 = load i64, i64* %8
%10 = icmp eq i64 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %7
%12 = tail call i32 @crypt(i8* %1, i64 %9)
%13 = load i64, i64* %8
%14 = tail call i32 @strcmp(i32 %12, i64 %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %11, %7, %5
br label %17
17: ; preds = %11, %2, %16
%18 = phi i8* [ null, %16 ], [ null, %2 ], [ %0, %11 ]
ret i8* %18
}