#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 */
typedef int /*<<< orphan*/ de_content;
typedef int /*<<< orphan*/ content_de;
typedef int /*<<< orphan*/ DES_key_schedule;
typedef int /*<<< orphan*/ DES_cblock;

/* Variables and functions */
int /*<<< orphan*/ Base64Encode(char *, int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ DES_DECRYPT;
int /*<<< orphan*/ DES_ENCRYPT;
int /*<<< orphan*/ DES_ncbc_encrypt(char const *, char *, int /*<<< orphan*/,
                                    int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                    int /*<<< orphan*/);
int /*<<< orphan*/ DES_set_key_checked(int /*<<< orphan*/ *,
                                       int /*<<< orphan*/ *);
int /*<<< orphan*/ DES_string_to_key(char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ test_base64();
int main(void) {
  int i = 0;
  char de_content[1024] = {0};
  char content_de[1024] = {0};
  char content_in[1024] = {0};
  char content_out[1024] = {0};
  const char *key = "abc45678";
  const char *content = "helightxu@gmail.com";
  DES_cblock key_cblock;
  DES_key_schedule schedule;
  DES_string_to_key(key, &key_cblock);
  DES_set_key_checked(&key_cblock, &schedule);
  DES_ncbc_encrypt(content, content_in, strlen(content), &schedule, &key_cblock,
                   DES_ENCRYPT);
  Base64Encode(content_in, strlen(content_in), de_content, sizeof(de_content));
  printf("content= %s\n", content);
  printf("content_in= %s\n", content_in);
  printf("content_out= %s\n", de_content);
  DES_string_to_key(key, &key_cblock);
  DES_set_key_checked(&key_cblock, &schedule);
  Base64Encode(de_content, strlen(de_content), content_de, sizeof(content_de));
  DES_ncbc_encrypt(content_de, content_out, strlen(content_de), &schedule,
                   &key_cblock, DES_DECRYPT);
  printf("content_out= %s\n", content_out);
  test_base64();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1060,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0xc10(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0x1010(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    0xe14(%rip),%rax
mov    %rax,-0x1018(%rbp)
lea    0xe0f(%rip),%rax
mov    %rax,-0x1020(%rbp)
mov    -0x1018(%rbp),%rdi
lea    -0x1024(%rbp),%rsi
call   1090 <DES_string_to_key@plt>
lea    -0x1024(%rbp),%rdi
lea    -0x1028(%rbp),%rsi
call   10a0 <DES_set_key_checked@plt>
mov    -0x1020(%rbp),%rax
mov    %rax,-0x1058(%rbp)
lea    -0xc10(%rbp),%rax
mov    %rax,-0x1050(%rbp)
mov    -0x1020(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1058(%rbp),%rdi
mov    -0x1050(%rbp),%rsi
mov    %eax,%edx
mov    0x2d7a(%rip),%rax
mov    (%rax),%r9d
lea    -0x1028(%rbp),%rcx
lea    -0x1024(%rbp),%r8
call   1070 <DES_ncbc_encrypt@plt>
lea    -0xc10(%rbp),%rax
mov    %rax,-0x1048(%rbp)
lea    -0xc10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1048(%rbp),%rdi
mov    %eax,%esi
lea    -0x410(%rbp),%rdx
mov    $0x400,%ecx
call   1030 <Base64Encode@plt>
mov    -0x1020(%rbp),%rsi
lea    0xd5f(%rip),%rdi
call   1050 <printf@plt>
lea    -0xc10(%rbp),%rsi
lea    0xd59(%rip),%rdi
call   1050 <printf@plt>
lea    -0x410(%rbp),%rsi
lea    0xd56(%rip),%rdi
call   1050 <printf@plt>
mov    -0x1018(%rbp),%rdi
lea    -0x1024(%rbp),%rsi
call   1090 <DES_string_to_key@plt>
lea    -0x1024(%rbp),%rdi
lea    -0x1028(%rbp),%rsi
call   10a0 <DES_set_key_checked@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x1040(%rbp)
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1040(%rbp),%rdi
mov    %eax,%esi
lea    -0x810(%rbp),%rdx
mov    $0x400,%ecx
call   1030 <Base64Encode@plt>
lea    -0x810(%rbp),%rax
mov    %rax,-0x1038(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1030(%rbp)
lea    -0x810(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1038(%rbp),%rdi
mov    -0x1030(%rbp),%rsi
mov    %eax,%edx
mov    0x2c56(%rip),%rax
mov    (%rax),%r9d
lea    -0x1028(%rbp),%rcx
lea    -0x1024(%rbp),%r8
call   1070 <DES_ncbc_encrypt@plt>
lea    -0x1010(%rbp),%rsi
lea    0xc94(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <test_base64@plt>
xor    %eax,%eax
add    $0x1060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
lea    0xc10(%rsp),%r12
mov    $0x400,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
lea    0x810(%rsp),%r15
mov    $0x400,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
lea    0x410(%rsp),%rbp
mov    $0x400,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
lea    0x10(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xe12(%rip),%rdi
lea    0xc(%rsp),%rbx
mov    %rbx,%rsi
call   1090 <DES_string_to_key@plt>
lea    0x8(%rsp),%r13
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <DES_set_key_checked@plt>
lea    0xdf7(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    0x2dbf(%rip),%rcx
mov    (%rcx),%r9d
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
mov    %r13,%rcx
mov    %rbx,%r8
call   1070 <DES_ncbc_encrypt@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbp,%rdi
mov    %eax,%esi
mov    %r12,%rdx
mov    $0x400,%ecx
call   1030 <Base64Encode@plt>
lea    0xdc5(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
lea    0xdc3(%rip),%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
lea    0xdc4(%rip),%r14
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <printf@plt>
lea    0xd78(%rip),%rdi
mov    %rbx,%rsi
call   1090 <DES_string_to_key@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <DES_set_key_checked@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
mov    %eax,%esi
mov    %r15,%rdx
mov    $0x400,%ecx
call   1030 <Base64Encode@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    0x2d14(%rip),%rcx
mov    (%rcx),%r9d
mov    %r15,%rdi
lea    0x10(%rsp),%rbp
mov    %rbp,%rsi
mov    %eax,%edx
mov    %r13,%rcx
mov    %rbx,%r8
call   1070 <DES_ncbc_encrypt@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
call   1080 <test_base64@plt>
xor    %eax,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"abc45678\00"
@.str.1 = [20 x i8] c"helightxu@gmail.com\00"
@DES_ENCRYPT = global i32 0
@.str.2 = [13 x i8] c"content= %s\0A\00"
@.str.3 = [16 x i8] c"content_in= %s\0A\00"
@.str.4 = [17 x i8] c"content_out= %s\0A\00"
@DES_DECRYPT = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%11 = bitcast [1024 x i8]* %3 to i8*
%12 = bitcast [1024 x i8]* %4 to i8*
%13 = bitcast [1024 x i8]* %5 to i8*
%14 = bitcast [1024 x i8]* %6 to i8*
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8** %8
%15 = load i8*, i8** %7
%16 = call i32 @DES_string_to_key(i8* %15, i32* %9)
%17 = call i32 @DES_set_key_checked(i32* %9, i32* %10)
%18 = load i8*, i8** %8
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%20 = load i8*, i8** %8
%21 = call i32 @strlen(i8* %20)
%22 = load i32, i32* @DES_ENCRYPT
%23 = call i32 @DES_ncbc_encrypt(i8* %18, i8* %19, i32 %21, i32* %10, i32* %9, i32 %22)
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%28 = call i32 @Base64Encode(i8* %24, i32 %26, i8* %27, i32 1024)
%29 = load i8*, i8** %8
%30 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%32 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%34 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %33)
%35 = load i8*, i8** %7
%36 = call i32 @DES_string_to_key(i8* %35, i32* %9)
%37 = call i32 @DES_set_key_checked(i32* %9, i32* %10)
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%40 = call i32 @strlen(i8* %39)
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%42 = call i32 @Base64Encode(i8* %38, i32 %40, i8* %41, i32 1024)
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%46 = call i32 @strlen(i8* %45)
%47 = load i32, i32* @DES_DECRYPT
%48 = call i32 @DES_ncbc_encrypt(i8* %43, i8* %44, i32 %46, i32* %10, i32* %9, i32 %47)
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%50 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %49)
%51 = call i32 (...) @test_base64()
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"abc45678\00"
@.str.1 = [20 x i8] c"helightxu@gmail.com\00"
@DES_ENCRYPT = global i32 0
@.str.2 = [13 x i8] c"content= %s\0A\00"
@.str.3 = [16 x i8] c"content_in= %s\0A\00"
@.str.4 = [17 x i8] c"content_out= %s\0A\00"
@DES_DECRYPT = global i32 0
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = call i32 @DES_string_to_key(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %5)
%14 = call i32 @DES_set_key_checked(i32* %5, i32* %6)
%15 = call i32 @strlen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @DES_ENCRYPT
%17 = call i32 @DES_ncbc_encrypt(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %9, i32 %15, i32* %6, i32* %5, i32 %16)
%18 = call i32 @strlen(i8* %9)
%19 = call i32 @Base64Encode(i8* %9, i32 %18, i8* %7, i32 1024)
%20 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%22 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%23 = call i32 @DES_string_to_key(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %5)
%24 = call i32 @DES_set_key_checked(i32* %5, i32* %6)
%25 = call i32 @strlen(i8* %7)
%26 = call i32 @Base64Encode(i8* %7, i32 %25, i8* %8, i32 1024)
%27 = call i32 @strlen(i8* %8)
%28 = load i32, i32* @DES_DECRYPT
%29 = call i32 @DES_ncbc_encrypt(i8* %8, i8* %10, i32 %27, i32* %6, i32* %5, i32 %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%31 = call i32 (...) @test_base64()
ret i32 0
}