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

/* Variables and functions */
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite_base32hex(char *, int, int /*<<< orphan*/ *);
int hash_val(void *ctx, char *hkey, int hkeylen, char *hval, int hvallen) {
  FILE *fp = ctx;
  fputs("{\"hkey\":", fp);
  fwrite_base32hex(hkey, hkeylen, fp);
  fputs(",\"hval\":", fp);
  fwrite_base32hex(hval, hvallen, fp);
  fputs("},", fp);
  return 0;
}


x86 assembly (clang, -O0):
<hash_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xeb2(%rip),%rdi
call   1030 <fputs@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1040 <fwrite_base32hex@plt>
mov    -0x30(%rbp),%rsi
lea    0xe9b(%rip),%rdi
call   1030 <fputs@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1040 <fwrite_base32hex@plt>
mov    -0x30(%rbp),%rsi
lea    0xe84(%rip),%rdi
call   1030 <fputs@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_val>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %edx,%r12d
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0xec2(%rip),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %rbx,%rdx
call   1030 <fwrite_base32hex@plt>
lea    0xea4(%rip),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    %r15,%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1030 <fwrite_base32hex@plt>
lea    0xe86(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"{\22hkey\22:\00"
@.str.1 = [9 x i8] c",\22hval\22:\00"
@.str.2 = [3 x i8] c"},\00"
define i32 @hash_val(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%12 = load i8*, i8** %6
%13 = bitcast i8* %12 to i32*
store i32* %13, i32** %11
%14 = load i32*, i32** %11
%15 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %14)
%16 = load i8*, i8** %7
%17 = load i32, i32* %8
%18 = load i32*, i32** %11
%19 = call i32 @fwrite_base32hex(i8* %16, i32 %17, i32* %18)
%20 = load i32*, i32** %11
%21 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %20)
%22 = load i8*, i8** %9
%23 = load i32, i32* %10
%24 = load i32*, i32** %11
%25 = call i32 @fwrite_base32hex(i8* %22, i32 %23, i32* %24)
%26 = load i32*, i32** %11
%27 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"{\22hkey\22:\00"
@.str.1 = [9 x i8] c",\22hval\22:\00"
@.str.2 = [3 x i8] c"},\00"
define i32 @hash_val(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = bitcast i8* %0 to i32*
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64 8, i64 1, i32* %6)
%8 = tail call i32 @fwrite_base32hex(i8* %1, i32 %2, i32* %6)
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64 8, i64 1, i32* %6)
%10 = tail call i32 @fwrite_base32hex(i8* %3, i32 %4, i32* %6)
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 2, i64 1, i32* %6)
ret i32 0
}