#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(int /*<<< orphan*/);
int /*<<< orphan*/ generate_random_salt(char *, int);
int /*<<< orphan*/ printf(char *);
char *make_md5_salt(int length) {
  static char salt[21];
  if (length > 16) {
    printf("MD5 salt length too long\n");
    exit(0);
  }
  salt[0] = '$';
  salt[1] = '1';
  salt[2] = '$';
  generate_random_salt(&salt[3], length);
  salt[length + 3] = '$';
  salt[length + 4] = '\0';
  return salt;
}


x86 assembly (clang, -O0):
<make_md5_salt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jle    1158 <make_md5_salt+0x28>
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
movb   $0x24,0x2ef1(%rip)
movb   $0x31,0x2eeb(%rip)
movb   $0x24,0x2ee5(%rip)
mov    -0x4(%rbp),%esi
lea    0x2ed9(%rip),%rdi
add    $0x3,%rdi
call   1040 <generate_random_salt@plt>
mov    -0x4(%rbp),%eax
add    $0x3,%eax
movslq %eax,%rcx
lea    0x2ec0(%rip),%rax
movb   $0x24,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
add    $0x4,%eax
movslq %eax,%rcx
lea    0x2eac(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2ea1(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_md5_salt>:
push   %r14
push   %rbx
push   %rax
cmp    $0x11,%edi
jge    1176 <make_md5_salt+0x46>
mov    %edi,%ebx
movw   $0x3124,0x2f0c(%rip)
24 31
lea    0x2f05(%rip),%r14
movb   $0x24,0x2f00(%rip)
lea    0x2efa(%rip),%rdi
mov    %ebx,%esi
call   1040 <generate_random_salt@plt>
movslq %ebx,%rax
movw   $0x24,0x3(%rax,%r14,1)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@make_md5_salt.salt = internal global [21 x i8] zeroinitializer
@.str = [26 x i8] c"MD5 salt length too long\0A\00"
define i8* @make_md5_salt(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sgt i32 %3, 16
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @exit(i32 0)
unreachable
8: ; preds = %1
store i8 36, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @make_md5_salt.salt, i64 0, i64 0)
store i8 49, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @make_md5_salt.salt, i64 0, i64 1)
store i8 36, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @make_md5_salt.salt, i64 0, i64 2)
%9 = load i32, i32* %2
%10 = call i32 @generate_random_salt(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @make_md5_salt.salt, i64 0, i64 3), i32 %9)
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [21 x i8], [21 x i8]* @make_md5_salt.salt, i64 0, i64 %13
store i8 36, i8* %14
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [21 x i8], [21 x i8]* @make_md5_salt.salt, i64 0, i64 %17
store i8 0, i8* %18
ret i8* getelementptr inbounds ([21 x i8], [21 x i8]* @make_md5_salt.salt, i64 0, i64 0)
}

LLVM IR (-O2):
@make_md5_salt.salt = internal global [21 x i8] zeroinitializer
@str = [25 x i8] c"MD5 salt length too long\00"
define i8* @make_md5_salt(i32 %0) {
%2 = icmp sgt i32 %0, 16
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @exit(i32 0)
unreachable
6: ; preds = %1
store i8 36, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @make_md5_salt.salt, i64 0, i64 0)
store i8 49, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @make_md5_salt.salt, i64 0, i64 1)
store i8 36, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @make_md5_salt.salt, i64 0, i64 2)
%7 = tail call i32 @generate_random_salt(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @make_md5_salt.salt, i64 0, i64 3), i32 %0)
%8 = add nsw i32 %0, 3
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [21 x i8], [21 x i8]* @make_md5_salt.salt, i64 0, i64 %9
store i8 36, i8* %10
%11 = add nsw i32 %0, 4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [21 x i8], [21 x i8]* @make_md5_salt.salt, i64 0, i64 %12
store i8 0, i8* %13
ret i8* getelementptr inbounds ([21 x i8], [21 x i8]* @make_md5_salt.salt, i64 0, i64 0)
}