#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 spwd {
  int /*<<< orphan*/ sp_pwdp;
};

/* Variables and functions */
char *crypt(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *getpass(char *);
struct spwd *getspnam(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int main(int argc, char **argv) {
  char *input_pass, *cryptedpass;
  struct spwd *shadowline;
  if (argc < 2) {
    fprintf(stderr, "Usage...\n");
    exit(1);
  }
  input_pass = getpass("Password:");
  shadowline = getspnam(argv[1]);
  cryptedpass = crypt(input_pass, shadowline->sp_pwdp);
  if (strcmp(shadowline->sp_pwdp, cryptedpass) == 0)
    puts("ok!");
  else
    puts("Failed!");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11af <main+0x3f>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xe54(%rip),%rdi
call   1070 <getpass@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <getspnam@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
call   1040 <crypt@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    120d <main+0x9d>
lea    0xe11(%rip),%rdi
call   1030 <puts@plt>
jmp    1219 <main+0xa9>
lea    0xe04(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     1198 <main+0x28>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    %rsi,%rbx
lea    0xe68(%rip),%rdi
call   1070 <getpass@plt>
mov    %rax,%r14
mov    0x8(%rbx),%rdi
call   1080 <getspnam@plt>
mov    %rax,%rbx
mov    (%rax),%esi
mov    %r14,%rdi
call   1040 <crypt@plt>
mov    (%rbx),%edi
mov    %rax,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
lea    0xe40(%rip),%rax
lea    0xe3d(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.spwd = type { i32 }
@stderr = global i32 0
@.str = [10 x i8] c"Usage...\0A\00"
@.str.1 = [10 x i8] c"Password:\00"
@.str.2 = [4 x i8] c"ok!\00"
@.str.3 = [8 x i8] c"Failed!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.spwd*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = call i8* @getpass(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i8* %16, i8** %6
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call %struct.spwd* @getspnam(i8* %19)
store %struct.spwd* %20, %struct.spwd** %8
%21 = load i8*, i8** %6
%22 = load %struct.spwd*, %struct.spwd** %8
%23 = getelementptr inbounds %struct.spwd, %struct.spwd* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = call i8* @crypt(i8* %21, i32 %24)
store i8* %25, i8** %7
%26 = load %struct.spwd*, %struct.spwd** %8
%27 = getelementptr inbounds %struct.spwd, %struct.spwd* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = load i8*, i8** %7
%30 = call i64 @strcmp(i32 %28, i8* %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %15
%33 = call i32 @puts(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %36
34: ; preds = %15
%35 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %34, %32
%37 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.spwd = type { i32 }
@stderr = global i32 0
@.str = [10 x i8] c"Usage...\0A\00"
@.str.1 = [10 x i8] c"Password:\00"
@.str.2 = [4 x i8] c"ok!\00"
@.str.3 = [8 x i8] c"Failed!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = tail call i8* @getpass(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call %struct.spwd* @getspnam(i8* %11)
%13 = getelementptr inbounds %struct.spwd, %struct.spwd* %12, i64 0, i32 0
%14 = load i32, i32* %13
%15 = tail call i8* @crypt(i8* %9, i32 %14)
%16 = load i32, i32* %13
%17 = tail call i64 @strcmp(i32 %16, i8* %15)
%18 = icmp eq i64 %17, 0
%19 = select i1 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
%20 = tail call i32 @puts(i8* dereferenceable(1) %19)
%21 = tail call i32 @exit(i32 0)
unreachable
}