#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 u_int8_t;
typedef int /*<<< orphan*/ u_int16_t;

/* Variables and functions */
int /*<<< orphan*/ encode_base64(int *, int *, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
void encode_salt(char *salt, u_int8_t *csalt, u_int16_t clen, u_int8_t logr) {
  salt[0] = '$';
  salt[1] = '2';
  salt[2] = 'a';
  salt[3] = '$';
  snprintf(salt + 4, 4, "%2.2u$", logr);
  encode_base64((u_int8_t *)salt + 7, csalt, clen);
}


x86 assembly (clang, -O0):
<encode_salt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x24,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x32,0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x61,0x2(%rax)
mov    -0x8(%rbp),%rax
movb   $0x24,0x3(%rax)
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
mov    -0x18(%rbp),%ecx
mov    $0x4,%esi
lea    0xe94(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x8(%rbp),%rdi
add    $0x1c,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <encode_base64@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode_salt>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
movl   $0x24613224,(%rdi)
add    $0x4,%rdi
lea    0xec2(%rip),%rdx
mov    $0x4,%esi
call   1030 <snprintf@plt>
add    $0x1c,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <encode_base64@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%2.2u$\00"
define void @encode_salt(i8* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i8*, i8** %5
%10 = getelementptr inbounds i8, i8* %9, i64 0
store i8 36, i8* %10
%11 = load i8*, i8** %5
%12 = getelementptr inbounds i8, i8* %11, i64 1
store i8 50, i8* %12
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i64 2
store i8 97, i8* %14
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 3
store i8 36, i8* %16
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i64 4
%19 = load i32, i32* %8
%20 = call i32 @snprintf(i8* %18, i32 4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i8*, i8** %5
%22 = bitcast i8* %21 to i32*
%23 = getelementptr inbounds i32, i32* %22, i64 7
%24 = load i32*, i32** %6
%25 = load i32, i32* %7
%26 = call i32 @encode_base64(i32* %23, i32* %24, i32 %25)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%2.2u$\00"
define void @encode_salt(i8* %0, i32* %1, i32 %2, i32 %3) {
store i8 36, i8* %0
%5 = getelementptr inbounds i8, i8* %0, i64 1
store i8 50, i8* %5
%6 = getelementptr inbounds i8, i8* %0, i64 2
store i8 97, i8* %6
%7 = getelementptr inbounds i8, i8* %0, i64 3
store i8 36, i8* %7
%8 = getelementptr inbounds i8, i8* %0, i64 4
%9 = tail call i32 @snprintf(i8* %8, i32 4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %3)
%10 = getelementptr inbounds i8, i8* %0, i64 28
%11 = bitcast i8* %10 to i32*
%12 = tail call i32 @encode_base64(i32* %11, i32* %1, i32 %2)
ret void
}