#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
char *crypt(char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char password[256];
  char salt[12];
  char *pass;
  printf("salt: ");
  scanf("%12s", salt);
  printf("password: ");
  scanf("%256s", password);
  if ((pass = crypt(password, salt)) == NULL) {
    fprintf(stderr, "Err. when (en)crypt password\n");
    exit(EXIT_FAILURE);
  } else
    printf("Encrypt '%s'(%s)\n", password, pass);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x11c(%rbp),%rsi
lea    0xe82(%rip),%rdi
call   1060 <scanf@plt>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x110(%rbp),%rdi
lea    -0x11c(%rbp),%rsi
call   1030 <crypt@plt>
mov    %rax,-0x128(%rbp)
cmp    $0x0,%rax
jne    11f2 <main+0xa2>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    -0x110(%rbp),%rsi
mov    -0x128(%rbp),%rdx
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dbb(%rip),%rax
mov    (%rax),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x118,%rsp
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe98(%rip),%rdi
lea    0x4(%rsp),%r14
mov    %r14,%rsi
call   1060 <scanf@plt>
lea    0xe89(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe86(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <crypt@plt>
test   %rax,%rax
je     11d8 <main+0x88>
lea    0xe86(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%eax
add    $0x118,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe35(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"salt: \00"
@.str.1 = [5 x i8] c"%12s\00"
@.str.2 = [11 x i8] c"password: \00"
@.str.3 = [6 x i8] c"%256s\00"
@stderr = global i32 0
@.str.4 = [30 x i8] c"Err. when (en)crypt password\0A\00"
@EXIT_FAILURE = global i32 0
@.str.5 = [18 x i8] c"Encrypt '%s'(%s)\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca [12 x i8]
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%14 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%16 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%17 = call i8* @crypt(i8* %15, i8* %16)
store i8* %17, i8** %8
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %24
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %2
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%26 = load i8*, i8** %8
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %25, i8* %26)
br label %28
28: ; preds = %24
%29 = load i32, i32* @EXIT_SUCCESS
ret i32 %29
}

LLVM IR (-O2):
@.str = [7 x i8] c"salt: \00"
@.str.1 = [5 x i8] c"%12s\00"
@.str.2 = [11 x i8] c"password: \00"
@.str.3 = [6 x i8] c"%256s\00"
@stderr = global i32 0
@.str.4 = [30 x i8] c"Err. when (en)crypt password\0A\00"
@EXIT_FAILURE = global i32 0
@.str.5 = [18 x i8] c"Encrypt '%s'(%s)\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8]
%4 = alloca [12 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%11 = call i8* @crypt(i8* %5, i8* %6)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %5, i8* %11)
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
}