#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*/ assert(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
unsigned long long word_hash(char *, int);
unsigned long long make_tag(char *tag_name, int tag_name_len,
                            unsigned int value) {
  assert(tag_name_len <= 16);
  char s[32];
  int i = 1;
  s[0] = 0x1f;
  memcpy(s + 1, tag_name, tag_name_len);
  i += tag_name_len;
  while (value >= 0x40) {
    s[i++] = (unsigned char)((value & 0x7f) + 0x80);
    value >>= 7;
  }
  s[i++] = (unsigned char)((value & 0x3f) + 0x40);
  return word_hash(s, i);
}


x86 assembly (clang, -O0):
<make_tag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x10,-0xc(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x1,-0x34(%rbp)
movb   $0x1f,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
add    $0x1,%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0xc(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x40,-0x10(%rbp)
jb     11b1 <make_tag+0x81>
mov    -0x10(%rbp),%eax
and    $0x7f,%eax
add    $0x80,%eax
mov    %al,%cl
mov    -0x34(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x34(%rbp)
cltq
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
shr    $0x7,%eax
mov    %eax,-0x10(%rbp)
jmp    117b <make_tag+0x4b>
mov    -0x10(%rbp),%eax
and    $0x3f,%eax
add    $0x40,%eax
mov    %al,%cl
mov    -0x34(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x34(%rbp)
cltq
mov    %cl,-0x30(%rbp,%rax,1)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1030 <word_hash@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_tag>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edx,%ebp
mov    %esi,%ebx
mov    %rdi,%r14
xor    %edi,%edi
cmp    $0x11,%esi
setl   %dil
call   1040 <assert@plt>
movb   $0x1f,(%rsp)
lea    0x1(%rsp),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1050 <memcpy@plt>
lea    0x1(%rbx),%eax
cmp    $0x40,%ebp
jb     118e <make_tag+0x5e>
cltq
add    %rsp,%rax
nopl   (%rax)
mov    %ebp,%ecx
mov    %ecx,%edx
or     $0x80,%dl
mov    %dl,(%rax)
shr    $0x7,%ebp
add    $0x1,%ebx
add    $0x1,%rax
cmp    $0x1fff,%ecx
ja     1170 <make_tag+0x40>
lea    0x1(%rbx),%eax
or     $0x40,%bpl
add    $0x2,%ebx
cltq
mov    %bpl,(%rsp,%rax,1)
mov    %rsp,%rdi
mov    %ebx,%esi
call   1030 <word_hash@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i64 @make_tag(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [32 x i8]
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %5
%10 = icmp sle i32 %9, 16
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
store i32 1, i32* %8
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
store i8 31, i8* %13
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8*, i8** %4
%17 = load i32, i32* %5
%18 = call i32 @memcpy(i8* %15, i8* %16, i32 %17)
%19 = load i32, i32* %5
%20 = load i32, i32* %8
%21 = add nsw i32 %20, %19
store i32 %21, i32* %8
br label %22
22: ; preds = %25, %3
%23 = load i32, i32* %6
%24 = icmp uge i32 %23, 64
br i1 %24, label %25, label %36
25: ; preds = %22
%26 = load i32, i32* %6
%27 = and i32 %26, 127
%28 = add i32 %27, 128
%29 = trunc i32 %28 to i8
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 %32
store i8 %29, i8* %33
%34 = load i32, i32* %6
%35 = lshr i32 %34, 7
store i32 %35, i32* %6
br label %22
36: ; preds = %22
%37 = load i32, i32* %6
%38 = and i32 %37, 63
%39 = add i32 %38, 64
%40 = trunc i32 %39 to i8
%41 = load i32, i32* %8
%42 = add nsw i32 %41, 1
store i32 %42, i32* %8
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 %43
store i8 %40, i8* %44
%45 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%46 = load i32, i32* %8
%47 = call i64 @word_hash(i8* %45, i32 %46)
ret i64 %47
}

LLVM IR (-O2):
define i64 @make_tag(i8* %0, i32 %1, i32 %2) {
%4 = alloca [32 x i8]
%5 = icmp slt i32 %1, 17
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
store i8 31, i8* %8
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 1
%10 = call i32 @memcpy(i8* %9, i8* %0, i32 %1)
%11 = add i32 %1, 1
%12 = icmp ugt i32 %2, 63
br i1 %12, label %13, label %27
13: ; preds = %3
%14 = sext i32 %11 to i64
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ %14, %13 ], [ %22, %15 ]
%17 = phi i32 [ %2, %13 ], [ %21, %15 ]
%18 = trunc i32 %17 to i8
%19 = or i8 %18, -128
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 %16
store i8 %19, i8* %20
%21 = lshr i32 %17, 7
%22 = add nsw i64 %16, 1
%23 = icmp ugt i32 %17, 8191
br i1 %23, label %15, label %24
24: ; preds = %15
%25 = trunc i64 %16 to i32
%26 = trunc i64 %22 to i32
br label %27
27: ; preds = %24, %3
%28 = phi i32 [ %2, %3 ], [ %21, %24 ]
%29 = phi i32 [ %1, %3 ], [ %25, %24 ]
%30 = phi i32 [ %11, %3 ], [ %26, %24 ]
%31 = trunc i32 %28 to i8
%32 = or i8 %31, 64
%33 = add nsw i32 %29, 2
%34 = sext i32 %30 to i64
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 %34
store i8 %32, i8* %35
%36 = call i64 @word_hash(i8* %8, i32 %33)
ret i64 %36
}