#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 *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ gensalt(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc < 2) {
    fprintf(stderr, "Usage: %s <password>\n", argv[0]);
    return 1;
  }
  char salt[3 + 16 + 1] = "$5$";
  gensalt(salt + 3);
  salt[3 + 16] = '\0';
  char *pwd = crypt(argv[1], salt);
  puts(pwd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1188 <main+0x48>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe89(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d6 <main+0x96>
mov    0xe91(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe8e(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe8c(%rip),%eax
mov    %eax,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
add    $0x3,%rdi
call   1060 <gensalt@plt>
movb   $0x0,-0x1d(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <crypt@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     116c <main+0x2c>
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xea0(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    11a4 <main+0x64>
movaps 0xead(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
lea    0x3(%rsp),%rdi
call   1060 <gensalt@plt>
movb   $0x0,0x13(%rsp)
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
call   1040 <crypt@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <password>\0A\00"
@__const.main.salt = [20 x i8] c"$5$\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [20 x i8]
%7 = alloca i8*
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 %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %29
16: ; preds = %2
%17 = bitcast [20 x i8]* %6 to i8*
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%19 = getelementptr inbounds i8, i8* %18, i64 3
%20 = call i32 @gensalt(i8* %19)
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 19
store i8 0, i8* %21
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%26 = call i8* @crypt(i8* %24, i8* %25)
store i8* %26, i8** %7
%27 = load i8*, i8** %7
%28 = call i32 @puts(i8* %27)
br label %29
29: ; preds = %16, %10
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <password>\0A\00"
@__const.main.salt = [20 x i8] c"$5$\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %18
9: ; preds = %2
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 3
%12 = call i32 @gensalt(i8* %11)
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 19
store i8 0, i8* %13
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = call i8* @crypt(i8* %15, i8* %10)
%17 = call i32 @puts(i8* dereferenceable(1) %16)
br label %18
18: ; preds = %9, %5
%19 = phi i32 [ 1, %5 ], [ 0, %9 ]
ret i32 %19
}