#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*/ tbuf;
typedef int /*<<< orphan*/ salt;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int strlen(char const *);
char *make_bf_salt_para(int rounds, const char *saltpara) {
  static char salt[31];
  char tbuf[3];
  if (saltpara && (strlen(saltpara) <= 22)) {
    snprintf(tbuf, sizeof(tbuf), "%02d", rounds);
    snprintf(salt, sizeof(salt), "$2a$%s$%s$", tbuf, saltpara);
    return salt;
  }
  printf("Invalid Salt, please use up to 22 random alphanumeric characters\n");
  exit(1);
  return NULL;
}


x86 assembly (clang, -O0):
<make_bf_salt_para>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b5 <make_bf_salt_para+0x75>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x16,%eax
jg     11b5 <make_bf_salt_para+0x75>
lea    -0x13(%rbp),%rdi
mov    -0x4(%rbp),%ecx
mov    $0x3,%esi
lea    0xe81(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
lea    -0x13(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0x2ebb(%rip),%rdi
mov    $0x1f,%esi
lea    0xe64(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
lea    0x2ea1(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret
lea    0xe54(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<make_bf_salt_para>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %rsi,%rsi
je     11ab <make_bf_salt_para+0x6b>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1040 <strlen@plt>
cmp    $0x16,%eax
jg     11ab <make_bf_salt_para+0x6b>
lea    0xe9a(%rip),%rdx
lea    0xd(%rsp),%r14
mov    %r14,%rdi
mov    $0x3,%esi
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <snprintf@plt>
lea    0x2ecd(%rip),%rbp
lea    0xe7b(%rip),%rdx
mov    %rbp,%rdi
mov    $0x1f,%esi
mov    %r14,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %rbp,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@make_bf_salt_para.salt = internal global [31 x i8] zeroinitializer
@.str = [5 x i8] c"%02d\00"
@.str.1 = [11 x i8] c"$2a$%s$%s$\00"
@.str.2 = [66 x i8] c"Invalid Salt, please use up to 22 random alphanumeric characters\0A\00"
define i8* @make_bf_salt_para(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [3 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %19
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = icmp sle i32 %10, 22
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%14 = load i32, i32* %3
%15 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %13, i32 3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%17 = load i8*, i8** %4
%18 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @make_bf_salt_para.salt, i64 0, i64 0), i32 31, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %16, i8* %17)
ret i8* getelementptr inbounds ([31 x i8], [31 x i8]* @make_bf_salt_para.salt, i64 0, i64 0)
19: ; preds = %8, %2
%20 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@make_bf_salt_para.salt = internal global [31 x i8] zeroinitializer
@.str = [5 x i8] c"%02d\00"
@.str.1 = [11 x i8] c"$2a$%s$%s$\00"
@str = [65 x i8] c"Invalid Salt, please use up to 22 random alphanumeric characters\00"
define i8* @make_bf_salt_para(i32 %0, i8* %1) {
%3 = alloca [3 x i8]
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%5 = icmp eq i8* %1, null
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = tail call i32 @strlen(i8* %1)
%8 = icmp slt i32 %7, 23
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %4, i32 3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %0)
%11 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @make_bf_salt_para.salt, i64 0, i64 0), i32 31, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* %1)
ret i8* getelementptr inbounds ([31 x i8], [31 x i8]* @make_bf_salt_para.salt, i64 0, i64 0)
12: ; preds = %6, %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
}