#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 /*<<< orphan*/ pw_name;
};

/* Variables and functions */
int /*<<< orphan*/ endpwent();
int ext_run(int /*<<< orphan*/, char const *, int);
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ getuid();
int ext_passwd_valid_p(const char *typed_passwd, int verbose_p) {
  struct passwd *pw;
  int res = 0;
  if ((pw = getpwuid(getuid())) != NULL)
    res = ext_run(pw->pw_name, typed_passwd, verbose_p);
  endpwent();
  return res;
}


x86 assembly (clang, -O0):
<ext_passwd_valid_p>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <getuid@plt>
mov    %eax,%edi
call   1040 <getpwuid@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1187 <ext_passwd_valid_p+0x47>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <ext_run@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1060 <endpwent@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ext_passwd_valid_p>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbp
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <getuid@plt>
mov    %eax,%edi
call   1040 <getpwuid@plt>
test   %rax,%rax
je     116e <ext_passwd_valid_p+0x2e>
mov    (%rax),%edi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1030 <ext_run@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <endpwent@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.passwd = type { i32 }
define i32 @ext_passwd_valid_p(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.passwd*
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %6
%7 = call i32 (...) @getuid()
%8 = call %struct.passwd* @getpwuid(i32 %7)
store %struct.passwd* %8, %struct.passwd** %5
%9 = icmp ne %struct.passwd* %8, null
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load %struct.passwd*, %struct.passwd** %5
%12 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = call i32 @ext_run(i32 %13, i8* %14, i32 %15)
store i32 %16, i32* %6
br label %17
17: ; preds = %10, %2
%18 = call i32 (...) @endpwent()
%19 = load i32, i32* %6
ret i32 %19
}

LLVM IR (-O2):
%struct.passwd = type { i32 }
define i32 @ext_passwd_valid_p(i8* %0, i32 %1) {
%3 = tail call i32 (...) @getuid()
%4 = tail call %struct.passwd* @getpwuid(i32 %3)
%5 = icmp eq %struct.passwd* %4, null
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = getelementptr inbounds %struct.passwd, %struct.passwd* %4, i64 0, i32 0
%8 = load i32, i32* %7
%9 = tail call i32 @ext_run(i32 %8, i8* %0, i32 %1)
br label %10
10: ; preds = %6, %2
%11 = phi i32 [ %9, %6 ], [ 0, %2 ]
%12 = tail call i32 (...) @endpwent()
ret i32 %11
}