#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*/ adj_order(unsigned char *);
int /*<<< orphan*/ box_num_gene(int *, unsigned char *, int);
int /*<<< orphan*/ free(unsigned char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(unsigned char *, char, int);
int /*<<< orphan*/ pword_gene(unsigned char *, unsigned char *, int *, int);
int /*<<< orphan*/ random_num_gene(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ seed_gene(unsigned char *, unsigned char *, unsigned char *);
int strlen(unsigned char *);
int pwd_gene(unsigned char *app, unsigned char *username,
             unsigned char *password, int pwd_len) {
  do {
  } while (0);
  int box_num[3];
  unsigned char *seed = (unsigned char *)malloc(
      (strlen(app) + strlen(username) + 1) * sizeof(unsigned char));
  memset(seed, '\0', strlen(app) + strlen(username) + 1);
  unsigned char *random_num =
      (unsigned char *)malloc(3 * sizeof(unsigned char));
  seed_gene(app, username, seed);
  random_num_gene(seed, random_num, 3);
  box_num_gene(box_num, random_num, pwd_len);
  pword_gene(seed, password, box_num, pwd_len);
  adj_order(password);
  free(seed);
  free(random_num);
  return 0;
}


x86 assembly (clang, -O0):
<pwd_gene>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
jmp    11ac <pwd_gene+0x1c>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x44(%rbp),%edx
mov    -0x40(%rbp),%rdi
add    %eax,%edx
add    $0x1,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    $0x3,%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   10b0 <seed_gene@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    $0x3,%edx
call   1080 <random_num_gene@plt>
lea    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   10a0 <box_num_gene@plt>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1060 <pword_gene@plt>
mov    -0x18(%rbp),%rdi
call   1030 <adj_order@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pwd_gene>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r13
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1050 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x1,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1050 <strlen@plt>
lea    (%rax,%rbp,1),%edx
add    $0x1,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <memset@plt>
mov    $0x3,%edi
call   1090 <malloc@plt>
mov    %rax,%rbp
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   10b0 <seed_gene@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x3,%edx
call   1080 <random_num_gene@plt>
lea    0xc(%rsp),%r12
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
call   10a0 <box_num_gene@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
mov    %r15d,%ecx
call   1060 <pword_gene@plt>
mov    %r14,%rdi
call   1030 <adj_order@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @pwd_gene(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca [3 x i32]
%6 = bitcast [3 x i32]* %5 to i8*
%7 = tail call i32 @strlen(i8* %0)
%8 = tail call i32 @strlen(i8* %1)
%9 = add i32 %7, 1
%10 = add i32 %9, %8
%11 = tail call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i8*
%13 = tail call i32 @strlen(i8* %0)
%14 = tail call i32 @strlen(i8* %1)
%15 = add i32 %13, 1
%16 = add i32 %15, %14
%17 = tail call i32 @memset(i8* %12, i8 signext 0, i32 %16)
%18 = tail call i64 @malloc(i32 3)
%19 = inttoptr i64 %18 to i8*
%20 = tail call i32 @seed_gene(i8* %0, i8* %1, i8* %12)
%21 = tail call i32 @random_num_gene(i8* %12, i8* %19, i32 3)
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%23 = call i32 @box_num_gene(i32* %22, i8* %19, i32 %3)
%24 = call i32 @pword_gene(i8* %12, i8* %2, i32* %22, i32 %3)
%25 = call i32 @adj_order(i8* %2)
%26 = call i32 @free(i8* %12)
%27 = call i32 @free(i8* %19)
ret i32 0
}