#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*/ SEEK_SET;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int getushort(int /*<<< orphan*/ *);
char *malloc(int);
char *ReadUnicode(FILE *ttf, long pos, int len) {
  char *str = malloc(len / 2 + 1), *pt = str;
  int ch;
  long here = ftell(ttf);
  fseek(ttf, pos, SEEK_SET);
  while (len > 0) {
    ch = getushort(ttf);
    if (ch >= ' ' && ch < 127)
      *pt++ = ch;
    len -= 2;
  }
  *pt = '\0';
  fseek(ttf, here, SEEK_SET);
  return (str);
}


x86 assembly (clang, -O0):
<ReadUnicode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
add    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <ftell@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e50(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
cmpl   $0x0,-0x14(%rbp)
jle    11e5 <ReadUnicode+0xa5>
mov    -0x8(%rbp),%rdi
call   1060 <getushort@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x20,-0x2c(%rbp)
jl     11d7 <ReadUnicode+0x97>
cmpl   $0x7f,-0x2c(%rbp)
jge    11d7 <ReadUnicode+0x97>
mov    -0x2c(%rbp),%eax
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1197 <ReadUnicode+0x57>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    0x2de5(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadUnicode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r12
mov    %rdi,%r13
mov    %edx,%edi
shr    $0x1f,%edi
add    %edx,%edi
sar    %edi
add    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %r13,%rdi
call   1030 <ftell@plt>
mov    %rax,%r15
mov    0x2e67(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %r12,%rsi
call   1050 <fseek@plt>
mov    %r14,%rbx
test   %ebp,%ebp
jle    11c0 <ReadUnicode+0x80>
add    $0x2,%ebp
mov    %r14,%rbx
jmp    11a8 <ReadUnicode+0x68>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xfffffffe,%ebp
cmp    $0x2,%ebp
jle    11c0 <ReadUnicode+0x80>
mov    %r13,%rdi
call   1060 <getushort@plt>
lea    -0x20(%rax),%ecx
cmp    $0x5e,%ecx
ja     11a0 <ReadUnicode+0x60>
mov    %al,(%rbx)
add    $0x1,%rbx
jmp    11a0 <ReadUnicode+0x60>
movb   $0x0,(%rbx)
mov    0x2e16(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %r15,%rsi
call   1050 <fseek@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i8* @ReadUnicode(i32* %0, i64 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i64
store i32* %0, i32** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
%11 = load i32, i32* %6
%12 = sdiv i32 %11, 2
%13 = add nsw i32 %12, 1
%14 = call i8* @malloc(i32 %13)
store i8* %14, i8** %7
%15 = load i8*, i8** %7
store i8* %15, i8** %8
%16 = load i32*, i32** %4
%17 = call i64 @ftell(i32* %16)
store i64 %17, i64* %10
%18 = load i32*, i32** %4
%19 = load i64, i64* %5
%20 = load i32, i32* @SEEK_SET
%21 = call i32 @fseek(i32* %18, i64 %19, i32 %20)
br label %22
22: ; preds = %38, %3
%23 = load i32, i32* %6
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %41
25: ; preds = %22
%26 = load i32*, i32** %4
%27 = call i32 @getushort(i32* %26)
store i32 %27, i32* %9
%28 = load i32, i32* %9
%29 = icmp sge i32 %28, 32
br i1 %29, label %30, label %38
30: ; preds = %25
%31 = load i32, i32* %9
%32 = icmp slt i32 %31, 127
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load i32, i32* %9
%35 = trunc i32 %34 to i8
%36 = load i8*, i8** %8
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %8
store i8 %35, i8* %36
br label %38
38: ; preds = %33, %30, %25
%39 = load i32, i32* %6
%40 = sub nsw i32 %39, 2
store i32 %40, i32* %6
br label %22
41: ; preds = %22
%42 = load i8*, i8** %8
store i8 0, i8* %42
%43 = load i32*, i32** %4
%44 = load i64, i64* %10
%45 = load i32, i32* @SEEK_SET
%46 = call i32 @fseek(i32* %43, i64 %44, i32 %45)
%47 = load i8*, i8** %7
ret i8* %47
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define noalias i8* @ReadUnicode(i32* %0, i64 %1, i32 %2) {
%4 = sdiv i32 %2, 2
%5 = add nsw i32 %4, 1
%6 = tail call i8* @malloc(i32 %5)
%7 = tail call i64 @ftell(i32* %0)
%8 = load i32, i32* @SEEK_SET
%9 = tail call i32 @fseek(i32* %0, i64 %1, i32 %8)
%10 = icmp sgt i32 %2, 0
br i1 %10, label %11, label %24
11: ; preds = %3, %20
%12 = phi i32 [ %22, %20 ], [ %2, %3 ]
%13 = phi i8* [ %21, %20 ], [ %6, %3 ]
%14 = tail call i32 @getushort(i32* %0)
%15 = add i32 %14, -32
%16 = icmp ult i32 %15, 95
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = trunc i32 %14 to i8
%19 = getelementptr inbounds i8, i8* %13, i64 1
store i8 %18, i8* %13
br label %20
20: ; preds = %17, %11
%21 = phi i8* [ %19, %17 ], [ %13, %11 ]
%22 = add nsw i32 %12, -2
%23 = icmp sgt i32 %12, 2
br i1 %23, label %11, label %24
24: ; preds = %20, %3
%25 = phi i8* [ %6, %3 ], [ %21, %20 ]
store i8 0, i8* %25
%26 = load i32, i32* @SEEK_SET
%27 = tail call i32 @fseek(i32* %0, i64 %7, i32 %26)
ret i8* %6
}