#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 EOF;
int fgetc(int /*<<< orphan*/ *);
long ftell(int /*<<< orphan*/ *);
long find_first_non_us_ascii(FILE *fp) {
  int byte;
  while (1) {
    byte = fgetc(fp);
    if (byte == EOF)
      return -1;
    if (byte >= 0x7F || ((byte) <= 0x08 || ((byte) >= 0x0E && (byte) <= 0x1F)))
      return ftell(fp) - 1;
  }
}


x86 assembly (clang, -O0):
<find_first_non_us_ascii>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2ea6(%rip),%rcx
cmp    (%rcx),%eax
jne    1157 <find_first_non_us_ascii+0x37>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    119a <find_first_non_us_ascii+0x7a>
cmpl   $0x7f,-0x14(%rbp)
jge    117f <find_first_non_us_ascii+0x5f>
cmpl   $0x8,-0x14(%rbp)
jle    117f <find_first_non_us_ascii+0x5f>
cmpl   $0xe,-0x14(%rbp)
jl     1195 <find_first_non_us_ascii+0x75>
cmpl   $0x1f,-0x14(%rbp)
jg     1195 <find_first_non_us_ascii+0x75>
mov    -0x10(%rbp),%rdi
call   1040 <ftell@plt>
sub    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    119a <find_first_non_us_ascii+0x7a>
jmp    112c <find_first_non_us_ascii+0xc>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_first_non_us_ascii>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2eba(%rip),%r14
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    (%r14),%eax
je     115b <find_first_non_us_ascii+0x3b>
lea    -0x7f(%rax),%ecx
cmp    $0xffffff8a,%ecx
jb     114d <find_first_non_us_ascii+0x2d>
add    $0xfffffff2,%eax
cmp    $0x11,%eax
ja     1130 <find_first_non_us_ascii+0x10>
mov    %rbx,%rdi
call   1040 <ftell@plt>
add    $0xffffffffffffffff,%rax
jmp    1162 <find_first_non_us_ascii+0x42>
mov    $0xffffffffffffffff,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i32 0
define i64 @find_first_non_us_ascii(i32* %0) {
%2 = alloca i64
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
br label %5
5: ; preds = %1, %28
%6 = load i32*, i32** %3
%7 = call i32 @fgetc(i32* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %12
11: ; preds = %5
store i64 -1, i64* %2
br label %29
12: ; preds = %5
%13 = load i32, i32* %4
%14 = icmp sge i32 %13, 127
br i1 %14, label %24, label %15
15: ; preds = %12
%16 = load i32, i32* %4
%17 = icmp sle i32 %16, 8
br i1 %17, label %24, label %18
18: ; preds = %15
%19 = load i32, i32* %4
%20 = icmp sge i32 %19, 14
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i32, i32* %4
%23 = icmp sle i32 %22, 31
br i1 %23, label %24, label %28
24: ; preds = %21, %15, %12
%25 = load i32*, i32** %3
%26 = call i64 @ftell(i32* %25)
%27 = sub nsw i64 %26, 1
store i64 %27, i64* %2
br label %29
28: ; preds = %21, %18
br label %5
29: ; preds = %24, %11
%30 = load i64, i64* %2
ret i64 %30
}

LLVM IR (-O2):
@EOF = global i32 0
define i64 @find_first_non_us_ascii(i32* nocapture %0) {
br label %2
2: ; preds = %6, %1
%3 = tail call i32 @fgetc(i32* %0)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %15, label %6
6: ; preds = %2
%7 = add i32 %3, -127
%8 = icmp ult i32 %7, -118
%9 = add i32 %3, -14
%10 = icmp ult i32 %9, 18
%11 = or i1 %8, %10
br i1 %11, label %12, label %2
12: ; preds = %6
%13 = tail call i64 @ftell(i32* %0)
%14 = add nsw i64 %13, -1
br label %15
15: ; preds = %2, %12
%16 = phi i64 [ %14, %12 ], [ -1, %2 ]
ret i64 %16
}