#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*/ Base64Encode(unsigned char *, unsigned char **);
int /*<<< orphan*/ encrypt(unsigned char *, unsigned char *, unsigned char *);
int /*<<< orphan*/ free(unsigned char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(unsigned char *, char, int);
int /*<<< orphan*/ pwd_gene(unsigned char *, unsigned char *, unsigned char *,
                            int);
int strlen(unsigned char *);
int generate(unsigned char *app, unsigned char *username,
             unsigned char *b64_pwd, int pwd_len) {
  unsigned char *password =
      (unsigned char *)malloc((pwd_len + 1) * sizeof(unsigned char));
  memset(password, '\0', pwd_len + 1);
  pwd_gene(app, username, password, pwd_len);
  int len_cip = (strlen(password) / (128 / 8) + 1) * (128 / 8);
  unsigned char *ciphertext =
      (unsigned char *)malloc((len_cip + 1) * sizeof(unsigned char));
  memset(ciphertext, '\0', len_cip + 1);
  unsigned char *key = "0123456789ABCDEF";
  encrypt(password, ciphertext, key);
  do {
  } while (0);
  Base64Encode(ciphertext, &b64_pwd);
  do {
  } while (0);
  free(password);
  free(ciphertext);
}


x86 assembly (clang, -O0):
<generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%edx
add    $0x1,%edx
xor    %esi,%esi
call   1080 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1050 <pwd_gene@plt>
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    $0x10,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
shl    $0x4,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x34(%rbp),%edx
add    $0x1,%edx
xor    %esi,%esi
call   1080 <memset@plt>
lea    0xdf4(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rdx
call   1070 <encrypt@plt>
jmp    1226 <generate+0xb6>
mov    -0x40(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <Base64Encode@plt>
jmp    1238 <generate+0xc8>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rsi,%r15
mov    %rdi,%r12
mov    %rdx,(%rsp)
lea    0x1(%r14),%ebp
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1080 <memset@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
mov    %r14d,%ecx
call   1050 <pwd_gene@plt>
mov    %r13,%rdi
call   1060 <strlen@plt>
lea    0xf(%rax),%ebp
test   %eax,%eax
cmovns %eax,%ebp
and    $0xfffffff0,%ebp
add    $0x11,%ebp
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1080 <memset@plt>
lea    0xe1a(%rip),%rdx
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <encrypt@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <Base64Encode@plt>
mov    %r13,%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"0123456789ABCDEF\00"
define i32 @generate(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%14 = load i32, i32* %9
%15 = add nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 1
%18 = trunc i64 %17 to i32
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %10
%21 = load i8*, i8** %10
%22 = load i32, i32* %9
%23 = add nsw i32 %22, 1
%24 = call i32 @memset(i8* %21, i8 signext 0, i32 %23)
%25 = load i8*, i8** %6
%26 = load i8*, i8** %7
%27 = load i8*, i8** %10
%28 = load i32, i32* %9
%29 = call i32 @pwd_gene(i8* %25, i8* %26, i8* %27, i32 %28)
%30 = load i8*, i8** %10
%31 = call i32 @strlen(i8* %30)
%32 = sdiv i32 %31, 16
%33 = add nsw i32 %32, 1
%34 = mul nsw i32 %33, 16
store i32 %34, i32* %11
%35 = load i32, i32* %11
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = mul i64 %37, 1
%39 = trunc i64 %38 to i32
%40 = call i64 @malloc(i32 %39)
%41 = inttoptr i64 %40 to i8*
store i8* %41, i8** %12
%42 = load i8*, i8** %12
%43 = load i32, i32* %11
%44 = add nsw i32 %43, 1
%45 = call i32 @memset(i8* %42, i8 signext 0, i32 %44)
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %13
%46 = load i8*, i8** %10
%47 = load i8*, i8** %12
%48 = load i8*, i8** %13
%49 = call i32 @encrypt(i8* %46, i8* %47, i8* %48)
br label %50
50: ; preds = %4
br label %51
51: ; preds = %50
%52 = load i8*, i8** %12
%53 = call i32 @Base64Encode(i8* %52, i8** %8)
br label %54
54: ; preds = %51
br label %55
55: ; preds = %54
%56 = load i8*, i8** %10
%57 = call i32 @free(i8* %56)
%58 = load i8*, i8** %12
%59 = call i32 @free(i8* %58)
%60 = load i32, i32* %5
ret i32 %60
}

LLVM IR (-O2):
@.str = [17 x i8] c"0123456789ABCDEF\00"
define i32 @generate(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
store i8* %2, i8** %5
%6 = add nsw i32 %3, 1
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @memset(i8* %8, i8 signext 0, i32 %6)
%10 = tail call i32 @pwd_gene(i8* %0, i8* %1, i8* %8, i32 %3)
%11 = tail call i32 @strlen(i8* %8)
%12 = sdiv i32 %11, 16
%13 = shl nsw i32 %12, 4
%14 = add i32 %13, 17
%15 = tail call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i8*
%17 = tail call i32 @memset(i8* %16, i8 signext 0, i32 %14)
%18 = tail call i32 @encrypt(i8* %8, i8* %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @Base64Encode(i8* %16, i8** %5)
%20 = call i32 @free(i8* %8)
%21 = call i32 @free(i8* %16)
ret i32 undef
}