#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*/ free(unsigned char *);
scalar_t__ malloc(int);
int txt2html(unsigned char *, int, unsigned char *, int);
int txt2html_nofont(unsigned char *str, int len, unsigned char **pnewstr,
                    int *plen) {
  int txtlen;
  int htmllen;
  unsigned char *newstr;
  txtlen = len * 7;
  newstr = (unsigned char *)malloc(txtlen + 1);
  htmllen = txt2html(str, len, newstr, txtlen);
  if (htmllen >= 0) {
    newstr[htmllen] = '\0';
    *pnewstr = newstr;
    *plen = htmllen;
  } else {
    free(newstr);
    *pnewstr = NULL;
    *plen = 0;
  }
  return htmllen;
}


x86 assembly (clang, -O0):
<txt2html_nofont>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
imul   $0x7,-0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
add    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1050 <txt2html@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     11a2 <txt2html_nofont+0x72>
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    11c0 <txt2html_nofont+0x90>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<txt2html_nofont>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebp
mov    %rdi,%r12
lea    0x0(,%rbp,8),%ebx
sub    %esi,%ebx
lea    0x1(%rbx),%edi
call   1040 <malloc@plt>
mov    %rax,%r13
mov    %r12,%rdi
mov    %ebp,%esi
mov    %rax,%rdx
mov    %ebx,%ecx
call   1050 <txt2html@plt>
mov    %eax,%ebp
test   %eax,%eax
js     117b <txt2html_nofont+0x4b>
mov    %ebp,%eax
movb   $0x0,0x0(%r13,%rax,1)
mov    %ebp,%eax
jmp    1188 <txt2html_nofont+0x58>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %r13d,%r13d
xor    %eax,%eax
mov    %r13,(%r15)
mov    %eax,(%r14)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @txt2html_nofont(i8* %0, i32 %1, i8** %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i32* %3, i32** %8
%12 = load i32, i32* %6
%13 = mul nsw i32 %12, 7
store i32 %13, i32* %9
%14 = load i32, i32* %9
%15 = add nsw i32 %14, 1
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %11
%18 = load i8*, i8** %5
%19 = load i32, i32* %6
%20 = load i8*, i8** %11
%21 = load i32, i32* %9
%22 = call i32 @txt2html(i8* %18, i32 %19, i8* %20, i32 %21)
store i32 %22, i32* %10
%23 = load i32, i32* %10
%24 = icmp sge i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %4
%26 = load i8*, i8** %11
%27 = load i32, i32* %10
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 0, i8* %29
%30 = load i8*, i8** %11
%31 = load i8**, i8*** %7
store i8* %30, i8** %31
%32 = load i32, i32* %10
%33 = load i32*, i32** %8
store i32 %32, i32* %33
br label %39
34: ; preds = %4
%35 = load i8*, i8** %11
%36 = call i32 @free(i8* %35)
%37 = load i8**, i8*** %7
store i8* null, i8** %37
%38 = load i32*, i32** %8
store i32 0, i32* %38
br label %39
39: ; preds = %34, %25
%40 = load i32, i32* %10
ret i32 %40
}

LLVM IR (-O2):
define i32 @txt2html_nofont(i8* %0, i32 %1, i8** nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = mul nsw i32 %1, 7
%6 = add nsw i32 %5, 1
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @txt2html(i8* %0, i32 %1, i8* %8, i32 %5)
%10 = icmp sgt i32 %9, -1
br i1 %10, label %11, label %14
11: ; preds = %4
%12 = zext i32 %9 to i64
%13 = getelementptr inbounds i8, i8* %8, i64 %12
store i8 0, i8* %13
br label %16
14: ; preds = %4
%15 = tail call i32 @free(i8* %8)
br label %16
16: ; preds = %14, %11
%17 = phi i8* [ null, %14 ], [ %8, %11 ]
%18 = phi i32 [ 0, %14 ], [ %9, %11 ]
store i8* %17, i8** %2
store i32 %18, i32* %3
ret i32 %9
}