#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 */

/* Variables and functions */
int /*<<< orphan*/ LOG_WARNING;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
scalar_t__ pw_auth(char const *, char const *, int, char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char const *);
void passwd_check(const char *user, const char *passwd, const char *progname) {
  if (pw_auth(passwd, user, 2, (char *)0) != 0) {
    syslog(LOG_WARNING, "incorrect password for `%s'", user);
    sleep(1);
    fprintf(stderr, "Incorrect password for %s.\n", user);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<passwd_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x2,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1060 <pw_auth@plt>
cmp    $0x0,%rax
je     11ca <passwd_check+0x7a>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe68(%rip),%rsi
call   1040 <syslog@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe61(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<passwd_check>:
push   %rbx
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
xor    %ecx,%ecx
call   1060 <pw_auth@plt>
test   %rax,%rax
jne    116d <passwd_check+0x1d>
pop    %rbx
ret
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
mov    %rbx,%rdx
call   1040 <syslog@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@LOG_WARNING = global i32 0
@.str = [28 x i8] c"incorrect password for `%s'\00"
@stderr = global i32 0
@.str.1 = [28 x i8] c"Incorrect password for %s.\0A\00"
define void @passwd_check(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %5
%8 = load i8*, i8** %4
%9 = call i64 @pw_auth(i8* %7, i8* %8, i32 2, i8* null)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %3
%12 = load i32, i32* @LOG_WARNING
%13 = load i8*, i8** %4
%14 = call i32 @syslog(i32 %12, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @sleep(i32 1)
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %4
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %3
ret void
}

LLVM IR (-O2):
@LOG_WARNING = global i32 0
@.str = [28 x i8] c"incorrect password for `%s'\00"
@stderr = global i32 0
@.str.1 = [28 x i8] c"Incorrect password for %s.\0A\00"
define void @passwd_check(i8* %0, i8* %1, i8* nocapture readnone %2) {
%4 = tail call i64 @pw_auth(i8* %1, i8* %0, i32 2, i8* null)
%5 = icmp eq i64 %4, 0
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = load i32, i32* @LOG_WARNING
%8 = tail call i32 @syslog(i32 %7, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = tail call i32 @sleep(i32 1)
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %3
ret void
}