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


x86 assembly (clang, -O0):
<Read1Byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%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    0x2e5a(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
cmpl   $0x0,-0x14(%rbp)
jle    11db <Read1Byte+0x9b>
mov    -0x8(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x20,-0x2c(%rbp)
jl     11cd <Read1Byte+0x8d>
cmpl   $0x7f,-0x2c(%rbp)
jge    11cd <Read1Byte+0x8d>
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
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    118d <Read1Byte+0x4d>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    0x2def(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Read1Byte>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %rsi,%r13
mov    %rdi,%r15
lea    0x1(%r12),%ebp
mov    %ebp,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1030 <ftell@plt>
mov    %rax,(%rsp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    %r13,%rsi
call   1050 <fseek@plt>
mov    %r14,%rbx
test   %r12d,%r12d
jle    11b0 <Read1Byte+0x70>
mov    %r14,%rbx
jmp    1198 <Read1Byte+0x58>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
jle    11b0 <Read1Byte+0x70>
mov    %r15,%rdi
call   1060 <getc@plt>
lea    -0x20(%rax),%ecx
cmp    $0x5e,%ecx
ja     1190 <Read1Byte+0x50>
mov    %al,(%rbx)
add    $0x1,%rbx
jmp    1190 <Read1Byte+0x50>
movb   $0x0,(%rbx)
mov    0x2e26(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    (%rsp),%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* @Read1Byte(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 = add nsw i32 %11, 1
%13 = call i8* @malloc(i32 %12)
store i8* %13, i8** %7
%14 = load i8*, i8** %7
store i8* %14, i8** %8
%15 = load i32*, i32** %4
%16 = call i64 @ftell(i32* %15)
store i64 %16, i64* %10
%17 = load i32*, i32** %4
%18 = load i64, i64* %5
%19 = load i32, i32* @SEEK_SET
%20 = call i32 @fseek(i32* %17, i64 %18, i32 %19)
br label %21
21: ; preds = %37, %3
%22 = load i32, i32* %6
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %40
24: ; preds = %21
%25 = load i32*, i32** %4
%26 = call i32 @getc(i32* %25)
store i32 %26, i32* %9
%27 = load i32, i32* %9
%28 = icmp sge i32 %27, 32
br i1 %28, label %29, label %37
29: ; preds = %24
%30 = load i32, i32* %9
%31 = icmp slt i32 %30, 127
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = load i32, i32* %9
%34 = trunc i32 %33 to i8
%35 = load i8*, i8** %8
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %8
store i8 %34, i8* %35
br label %37
37: ; preds = %32, %29, %24
%38 = load i32, i32* %6
%39 = add nsw i32 %38, -1
store i32 %39, i32* %6
br label %21
40: ; preds = %21
%41 = load i8*, i8** %8
store i8 0, i8* %41
%42 = load i32*, i32** %4
%43 = load i64, i64* %10
%44 = load i32, i32* @SEEK_SET
%45 = call i32 @fseek(i32* %42, i64 %43, i32 %44)
%46 = load i8*, i8** %7
ret i8* %46
}

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