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

/* Variables and functions */
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ errno;
char *tripcode_crypt(char *, size_t, char *);
size_t tripcode_html(char *, char *);
size_t tripcode_sjis(int /*<<< orphan*/, char *, size_t, char *, int);
char *tripcode(iconv_t cd, char *input, size_t len, char *output) {
  char html[32] = {0};
  char sjis[32] = {0};
  len = tripcode_sjis(cd, input, len, sjis, 32);
  if (len == (size_t)-1)
    return NULL;
  len = tripcode_html(sjis, html);
  if (len == 0) {
    errno = EINVAL;
    return NULL;
  }
  return tripcode_crypt(html, len, output);
}


x86 assembly (clang, -O0):
<tripcode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    -0x70(%rbp),%rcx
mov    $0x20,%r8d
call   1030 <tripcode_sjis@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0xffffffffffffffff,-0x20(%rbp)
jne    11ad <tripcode+0x6d>
movq   $0x0,-0x8(%rbp)
jmp    11fd <tripcode+0xbd>
lea    -0x70(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <tripcode_html@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e8 <tripcode+0xa8>
mov    0x2e08(%rip),%rax
mov    (%rax),%ecx
mov    0x2e07(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    11fd <tripcode+0xbd>
lea    -0x50(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1060 <tripcode_crypt@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tripcode>:
push   %rbx
sub    $0x40,%rsp
mov    %rcx,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rcx
mov    $0x20,%r8d
call   1030 <tripcode_sjis@plt>
cmp    $0xffffffffffffffff,%rax
je     1198 <tripcode+0x68>
mov    %rsp,%rdi
lea    0x20(%rsp),%rsi
call   1040 <tripcode_html@plt>
test   %rax,%rax
je     1186 <tripcode+0x56>
lea    0x20(%rsp),%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
call   1050 <tripcode_crypt@plt>
jmp    119a <tripcode+0x6a>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    0x2e4a(%rip),%rcx
mov    %eax,(%rcx)
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@EINVAL = global i32 0
@errno = global i32 0
define i8* @tripcode(i32 %0, i8* %1, i64 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca [32 x i8]
%11 = alloca [32 x i8]
store i32 %0, i32* %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
%12 = bitcast [32 x i8]* %10 to i8*
%13 = bitcast [32 x i8]* %11 to i8*
%14 = load i32, i32* %6
%15 = load i8*, i8** %7
%16 = load i64, i64* %8
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%18 = call i64 @tripcode_sjis(i32 %14, i8* %15, i64 %16, i8* %17, i32 32)
store i64 %18, i64* %8
%19 = load i64, i64* %8
%20 = icmp eq i64 %19, -1
br i1 %20, label %21, label %22
21: ; preds = %4
store i8* null, i8** %5
br label %35
22: ; preds = %4
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%25 = call i64 @tripcode_html(i8* %23, i8* %24)
store i64 %25, i64* %8
%26 = load i64, i64* %8
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = load i32, i32* @EINVAL
store i32 %29, i32* @errno
store i8* null, i8** %5
br label %35
30: ; preds = %22
%31 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%32 = load i64, i64* %8
%33 = load i8*, i8** %9
%34 = call i8* @tripcode_crypt(i8* %31, i64 %32, i8* %33)
store i8* %34, i8** %5
br label %35
35: ; preds = %30, %28, %21
%36 = load i8*, i8** %5
ret i8* %36
}

LLVM IR (-O2):
@EINVAL = global i32 0
@errno = global i32 0
define i8* @tripcode(i32 %0, i8* %1, i64 %2, i8* %3) {
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%9 = call i64 @tripcode_sjis(i32 %0, i8* %1, i64 %2, i8* %8, i32 32)
%10 = icmp eq i64 %9, -1
br i1 %10, label %18, label %11
11: ; preds = %4
%12 = call i64 @tripcode_html(i8* %8, i8* %7)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = load i32, i32* @EINVAL
store i32 %15, i32* @errno
br label %18
16: ; preds = %11
%17 = call i8* @tripcode_crypt(i8* %7, i64 %12, i8* %3)
br label %18
18: ; preds = %4, %16, %14
%19 = phi i8* [ null, %14 ], [ %17, %16 ], [ null, %4 ]
ret i8* %19
}