#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 */
char *crypt(char *, char *);
char *getpass(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("usage: %s hash [pass]\n", argv[0]);
    return (1);
  }
  char *result;
  int ok;
  if (argc < 3)
    result = crypt(getpass("Password:"), argv[1]);
  else
    result = crypt(argv[2], argv[1]);
  ok = strcmp(result, argv[1]) == 0;
  puts(ok ? "Access granted." : "Access denied.");
  return ok ? 0 : 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    118f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe82(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1227 <main+0xd7>
cmpl   $0x3,-0x8(%rbp)
jge    11be <main+0x6e>
lea    0xe77(%rip),%rdi
call   1070 <getpass@plt>
mov    %rax,%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <crypt@plt>
mov    %rax,-0x18(%rbp)
jmp    11d7 <main+0x87>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <crypt@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
lea    0xe30(%rip),%rdi
lea    0xe19(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <puts@plt>
mov    -0x1c(%rbp),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     116f <main+0x1f>
mov    (%rbx),%rsi
lea    0xe9d(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%ebx
jmp    11bd <main+0x6d>
cmp    $0x2,%edi
jne    1185 <main+0x35>
lea    0xe9c(%rip),%rdi
call   1070 <getpass@plt>
mov    %rax,%rdi
jmp    1189 <main+0x39>
mov    0x10(%rbx),%rdi
mov    0x8(%rbx),%rsi
call   1040 <crypt@plt>
mov    0x8(%rbx),%rsi
mov    %rax,%rdi
call   1060 <strcmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
lea    0xe74(%rip),%rax
lea    0xe7d(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"usage: %s hash [pass]\0A\00"
@.str.1 = [10 x i8] c"Password:\00"
@.str.2 = [16 x i8] c"Access granted.\00"
@.str.3 = [15 x i8] c"Access denied.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 1, i32* %3
br label %49
15: ; preds = %2
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = call i8* @getpass(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i8* @crypt(i8* %19, i8* %22)
store i8* %23, i8** %6
br label %32
24: ; preds = %15
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i8* @crypt(i8* %27, i8* %30)
store i8* %31, i8** %6
br label %32
32: ; preds = %24, %18
%33 = load i8*, i8** %6
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i64 @strcmp(i8* %33, i8* %36)
%38 = icmp eq i64 %37, 0
%39 = zext i1 %38 to i32
store i32 %39, i32* %7
%40 = load i32, i32* %7
%41 = icmp ne i32 %40, 0
%42 = zext i1 %41 to i64
%43 = select i1 %41, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0)
%44 = call i32 @puts(i8* %43)
%45 = load i32, i32* %7
%46 = icmp ne i32 %45, 0
%47 = zext i1 %46 to i64
%48 = select i1 %46, i32 0, i32 1
store i32 %48, i32* %3
br label %49
49: ; preds = %32, %10
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@.str = [23 x i8] c"usage: %s hash [pass]\0A\00"
@.str.1 = [10 x i8] c"Password:\00"
@.str.2 = [16 x i8] c"Access granted.\00"
@.str.3 = [15 x i8] c"Access denied.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %27
7: ; preds = %2
%8 = icmp eq i32 %0, 2
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i8* @getpass(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %14
11: ; preds = %7
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
br label %14
14: ; preds = %11, %9
%15 = phi i8* [ %13, %11 ], [ %10, %9 ]
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i8* @crypt(i8* %15, i8* %17)
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = tail call i64 @strcmp(i8* %18, i8* %20)
%22 = icmp eq i64 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0)
%24 = tail call i32 @puts(i8* dereferenceable(1) %23)
%25 = xor i1 %22, true
%26 = zext i1 %25 to i32
br label %27
27: ; preds = %14, %4
%28 = phi i32 [ 1, %4 ], [ %26, %14 ]
ret i32 %28
}