#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;
char *crypt(char *, char const *const);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *getpass(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strlen(char *);
void encode(char *encrypt_str) {
  char *p, *p2;
  const char *const salt = "FMSIOPQWE/MNCBCKLASJZIOQWIEASD";
  if ((p = getpass("Enter Password:")) != NULL) {
    if ((p2 = crypt(p, salt)) == NULL) {
      fprintf(stderr, "Encrypt password was failed.\n");
      exit(EXIT_FAILURE);
    }
    memset(p, 0, strlen(p));
    strcat(encrypt_str, ":");
    strcat(encrypt_str, p2);
    strcat(encrypt_str, "\n");
  } else {
    fprintf(stderr, "Get password was failed.\n");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe7d(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe91(%rip),%rdi
call   1070 <getpass@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1232 <encode+0xc2>
mov    -0x10(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1030 <crypt@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11e2 <encode+0x72>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1080 <strcat@plt>
jmp    1255 <encode+0xe5>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
lea    0xe0b(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xea0(%rip),%rdi
call   1070 <getpass@plt>
test   %rax,%rax
je     11e5 <encode+0x75>
mov    %rax,%rbx
lea    0xe6d(%rip),%rsi
mov    %rax,%rdi
call   1030 <crypt@plt>
test   %rax,%rax
je     11f7 <encode+0x87>
mov    %rax,%r15
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1050 <memset@plt>
lea    0xe6f(%rip),%rsi
mov    %r14,%rdi
call   1080 <strcat@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1080 <strcat@plt>
lea    0xe8d(%rip),%rsi
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1080 <strcat@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
jmp    1207 <encode+0x97>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
lea    0xe28(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"FMSIOPQWE/MNCBCKLASJZIOQWIEASD\00"
@.str.1 = [16 x i8] c"Enter Password:\00"
@stderr = global i32 0
@.str.2 = [30 x i8] c"Encrypt password was failed.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [2 x i8] c":\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [26 x i8] c"Get password was failed.\0A\00"
define void @encode(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
store i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8** %5
%6 = call i8* @getpass(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i8* %6, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %29
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i8* @crypt(i8* %9, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i32 0, i32 0))
store i8* %10, i8** %4
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %8
%18 = load i8*, i8** %3
%19 = load i8*, i8** %3
%20 = call i32 @strlen(i8* %19)
%21 = call i32 @memset(i8* %18, i32 0, i32 %20)
%22 = load i8*, i8** %2
%23 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = load i8*, i8** %2
%25 = load i8*, i8** %4
%26 = call i32 @strcat(i8* %24, i8* %25)
%27 = load i8*, i8** %2
%28 = call i32 @strcat(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %34
29: ; preds = %1
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %17
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"FMSIOPQWE/MNCBCKLASJZIOQWIEASD\00"
@.str.1 = [16 x i8] c"Enter Password:\00"
@stderr = global i32 0
@.str.2 = [30 x i8] c"Encrypt password was failed.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [2 x i8] c":\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [26 x i8] c"Get password was failed.\0A\00"
define void @encode(i8* %0) {
%2 = tail call i8* @getpass(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %18, label %4
4: ; preds = %1
%5 = tail call i8* @crypt(i8* %2, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %12
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %4
%13 = tail call i32 @strlen(i8* %2)
%14 = tail call i32 @memset(i8* %2, i32 0, i32 %13)
%15 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%16 = tail call i32 @strcat(i8* %0, i8* %5)
%17 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
18: ; preds = %1
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
}