#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*/ compact(char *, char *);
int /*<<< orphan*/ free(char *);
char *malloc(size_t);
int /*<<< orphan*/ parse(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
size_t strlen(char const *);
int tohtml(char *, char *, char *, size_t);
int sanitize(const char *restrict src, char *restrict dst, size_t dstsize) {
  size_t srclen = strlen(src);
  char *src2 = malloc(srclen + 1);
  char *attrs = malloc(srclen + 1);
  strcpy(src2, src);
  parse(src2, attrs);
  compact(src2, attrs);
  int ret = tohtml(src2, attrs, dst, dstsize);
  free(src2);
  free(attrs);
  return ret;
}


x86 assembly (clang, -O0):
<sanitize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1090 <parse@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1070 <compact@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1060 <tohtml@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sanitize>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
call   1050 <strlen@plt>
lea    0x1(%rax),%r13
mov    %r13,%rdi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1080 <malloc@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1090 <parse@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <compact@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1060 <tohtml@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @sanitize(i8* noalias %0, i8* noalias %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%11 = load i8*, i8** %4
%12 = call i64 @strlen(i8* %11)
store i64 %12, i64* %7
%13 = load i64, i64* %7
%14 = add i64 %13, 1
%15 = call i8* @malloc(i64 %14)
store i8* %15, i8** %8
%16 = load i64, i64* %7
%17 = add i64 %16, 1
%18 = call i8* @malloc(i64 %17)
store i8* %18, i8** %9
%19 = load i8*, i8** %8
%20 = load i8*, i8** %4
%21 = call i32 @strcpy(i8* %19, i8* %20)
%22 = load i8*, i8** %8
%23 = load i8*, i8** %9
%24 = call i32 @parse(i8* %22, i8* %23)
%25 = load i8*, i8** %8
%26 = load i8*, i8** %9
%27 = call i32 @compact(i8* %25, i8* %26)
%28 = load i8*, i8** %8
%29 = load i8*, i8** %9
%30 = load i8*, i8** %5
%31 = load i64, i64* %6
%32 = call i32 @tohtml(i8* %28, i8* %29, i8* %30, i64 %31)
store i32 %32, i32* %10
%33 = load i8*, i8** %8
%34 = call i32 @free(i8* %33)
%35 = load i8*, i8** %9
%36 = call i32 @free(i8* %35)
%37 = load i32, i32* %10
ret i32 %37
}

LLVM IR (-O2):
define i32 @sanitize(i8* noalias %0, i8* noalias %1, i64 %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = add i64 %4, 1
%6 = tail call i8* @malloc(i64 %5)
%7 = tail call i8* @malloc(i64 %5)
%8 = tail call i32 @strcpy(i8* %6, i8* %0)
%9 = tail call i32 @parse(i8* %6, i8* %7)
%10 = tail call i32 @compact(i8* %6, i8* %7)
%11 = tail call i32 @tohtml(i8* %6, i8* %7, i8* %1, i64 %2)
%12 = tail call i32 @free(i8* %6)
%13 = tail call i32 @free(i8* %7)
ret i32 %11
}