#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*/ SHA_CTX;

/* Variables and functions */
int SHA1_Final(unsigned char *, int /*<<< orphan*/ *);
int SHA1_Init(int /*<<< orphan*/ *);
int SHA1_Update(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/);
int SHA_DIGEST_LENGTH;
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int snprintf(char *, int, char *, unsigned char);
char *strcat(char *, char *);
int /*<<< orphan*/ strlen(char const *);
void hash_with_salt(const char *text, const char *salt, char *store) {
  SHA_CTX ctx;
  unsigned char digest[SHA_DIGEST_LENGTH];
  int i;
  char *c;
  memset(digest, 0, SHA_DIGEST_LENGTH);
  if (1 == SHA1_Init(&ctx) && 1 == SHA1_Update(&ctx, text, strlen(text)) &&
      1 == SHA1_Update(&ctx, salt, strlen(salt)) &&
      1 == SHA1_Final(digest, &ctx)) {
    c = malloc(sizeof(char) * 3);
    for (i = 0; i < SHA_DIGEST_LENGTH; i++) {
      if (3 != snprintf(c, 3, "%02x", digest[i])) {
      }
      store = strcat(store, c);
    }
    free(c);
  } else {
  }
}


x86 assembly (clang, -O0):
<hash_with_salt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x30(%rbp)
mov    0x2e11(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    -0x1c(%rbp),%rdi
call   1090 <SHA1_Init@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    12fb <hash_with_salt+0x16b>
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
lea    -0x1c(%rbp),%rdi
call   1080 <SHA1_Update@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    12fb <hash_with_salt+0x16b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x58(%rbp),%rsi
mov    %eax,%edx
lea    -0x1c(%rbp),%rdi
call   1080 <SHA1_Update@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    12fb <hash_with_salt+0x16b>
mov    -0x48(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   10b0 <SHA1_Final@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jne    12fb <hash_with_salt+0x16b>
mov    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x2d57(%rip),%rcx
cmp    (%rcx),%eax
jge    12ed <hash_with_salt+0x15d>
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp),%rdi
movslq -0x34(%rbp),%rcx
mov    $0x3,%esi
lea    0xd4f(%rip),%rdx
movzbl (%rax,%rcx,1),%ecx
call   1050 <snprintf@plt>
mov    %eax,%ecx
mov    $0x3,%eax
cmp    %ecx,%eax
je     12ce <hash_with_salt+0x13e>
jmp    12ce <hash_with_salt+0x13e>
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   10a0 <strcat@plt>
mov    %rax,-0x18(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1287 <hash_with_salt+0xf7>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
jmp    1300 <hash_with_salt+0x170>
jmp    1300 <hash_with_salt+0x170>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_with_salt>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %rsp,-0x38(%rbp)
mov    0x2e33(%rip),%r13
mov    0x0(%r13),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x0(%r13),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
lea    -0x2c(%rbp),%rdi
call   1090 <SHA1_Init@plt>
cmp    $0x1,%eax
jne    1289 <hash_with_salt+0xf9>
mov    %r12,%rdi
call   1040 <strlen@plt>
lea    -0x2c(%rbp),%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1080 <SHA1_Update@plt>
cmp    $0x1,%eax
jne    1289 <hash_with_salt+0xf9>
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    -0x2c(%rbp),%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1080 <SHA1_Update@plt>
cmp    $0x1,%eax
jne    1289 <hash_with_salt+0xf9>
lea    -0x2c(%rbp),%rsi
mov    %rbx,%rdi
call   10b0 <SHA1_Final@plt>
cmp    $0x1,%eax
jne    1289 <hash_with_salt+0xf9>
mov    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
cmpl   $0x0,0x0(%r13)
jle    1281 <hash_with_salt+0xf1>
xor    %r12d,%r12d
nopl   0x0(%rax)
movzbl (%rbx,%r12,1),%ecx
mov    %r15,%rdi
mov    $0x3,%esi
lea    0xd9c(%rip),%rdx
call   1050 <snprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <strcat@plt>
add    $0x1,%r12
movslq 0x0(%r13),%rax
cmp    %rax,%r12
jl     1250 <hash_with_salt+0xc0>
mov    %r15,%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SHA_DIGEST_LENGTH = global i32 0
@.str = [5 x i8] c"%02x\00"
define void @hash_with_salt(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%12 = load i32, i32* @SHA_DIGEST_LENGTH
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %8
%15 = alloca i8, i64 %13
store i64 %13, i64* %9
%16 = load i32, i32* @SHA_DIGEST_LENGTH
%17 = call i32 @memset(i8* %15, i32 0, i32 %16)
%18 = call i32 @SHA1_Init(i32* %7)
%19 = icmp eq i32 1, %18
br i1 %19, label %20, label %60
20: ; preds = %3
%21 = load i8*, i8** %4
%22 = load i8*, i8** %4
%23 = call i32 @strlen(i8* %22)
%24 = call i32 @SHA1_Update(i32* %7, i8* %21, i32 %23)
%25 = icmp eq i32 1, %24
br i1 %25, label %26, label %60
26: ; preds = %20
%27 = load i8*, i8** %5
%28 = load i8*, i8** %5
%29 = call i32 @strlen(i8* %28)
%30 = call i32 @SHA1_Update(i32* %7, i8* %27, i32 %29)
%31 = icmp eq i32 1, %30
br i1 %31, label %32, label %60
32: ; preds = %26
%33 = call i32 @SHA1_Final(i8* %15, i32* %7)
%34 = icmp eq i32 1, %33
br i1 %34, label %35, label %60
35: ; preds = %32
%36 = call i8* @malloc(i32 3)
store i8* %36, i8** %11
store i32 0, i32* %10
br label %37
37: ; preds = %54, %35
%38 = load i32, i32* %10
%39 = load i32, i32* @SHA_DIGEST_LENGTH
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %57
41: ; preds = %37
%42 = load i8*, i8** %11
%43 = load i32, i32* %10
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %15, i64 %44
%46 = load i8, i8* %45
%47 = call i32 @snprintf(i8* %42, i32 3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %46)
%48 = icmp ne i32 3, %47
br i1 %48, label %49, label %50
49: ; preds = %41
br label %50
50: ; preds = %49, %41
%51 = load i8*, i8** %6
%52 = load i8*, i8** %11
%53 = call i8* @strcat(i8* %51, i8* %52)
store i8* %53, i8** %6
br label %54
54: ; preds = %50
%55 = load i32, i32* %10
%56 = add nsw i32 %55, 1
store i32 %56, i32* %10
br label %37
57: ; preds = %37
%58 = load i8*, i8** %11
%59 = call i32 @free(i8* %58)
br label %61
60: ; preds = %32, %26, %20, %3
br label %61
61: ; preds = %60, %57
%62 = load i8*, i8** %8
ret void
}

LLVM IR (-O2):
@SHA_DIGEST_LENGTH = global i32 0
@.str = [5 x i8] c"%02x\00"
define void @hash_with_salt(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = load i32, i32* @SHA_DIGEST_LENGTH
%7 = zext i32 %6 to i64
%8 = tail call i8* @llvm.stacksave()
%9 = alloca i8, i64 %7
%10 = load i32, i32* @SHA_DIGEST_LENGTH
%11 = call i32 @memset(i8* %9, i32 0, i32 %10)
%12 = call i32 @SHA1_Init(i32* %4)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %41
14: ; preds = %3
%15 = call i32 @strlen(i8* %0)
%16 = call i32 @SHA1_Update(i32* %4, i8* %0, i32 %15)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %41
18: ; preds = %14
%19 = call i32 @strlen(i8* %1)
%20 = call i32 @SHA1_Update(i32* %4, i8* %1, i32 %19)
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %41
22: ; preds = %18
%23 = call i32 @SHA1_Final(i8* %9, i32* %4)
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %41
25: ; preds = %22
%26 = call dereferenceable_or_null(3) i8* @malloc(i32 3)
%27 = load i32, i32* @SHA_DIGEST_LENGTH
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %39
29: ; preds = %25, %29
%30 = phi i64 [ %35, %29 ], [ 0, %25 ]
%31 = getelementptr inbounds i8, i8* %9, i64 %30
%32 = load i8, i8* %31
%33 = call i32 @snprintf(i8* %26, i32 3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %32)
%34 = call i8* @strcat(i8* dereferenceable(1) %2, i8* dereferenceable(1) %26)
%35 = add nuw nsw i64 %30, 1
%36 = load i32, i32* @SHA_DIGEST_LENGTH
%37 = sext i32 %36 to i64
%38 = icmp slt i64 %35, %37
br i1 %38, label %29, label %39
39: ; preds = %29, %25
%40 = call i32 @free(i8* %26)
br label %41
41: ; preds = %3, %14, %18, %22, %39
ret void
}