#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;
scalar_t__ feof(int /*<<< orphan*/ *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int sscanf(char *, char *, int *);
int E_ReadDataType(FILE *input) {
  int type, items;
  long pos;
  char type_str[256] = "";
  int p = 0;
  if (feof(input))
    return -1;
  pos = ftell(input);
  while (!feof(input) && fread(&type_str[p], 1, 1, input) == 1 &&
         type_str[p] >= '0' && type_str[p] <= '9') {
    p += 1;
  }
  if (p == 0) {
    fseek(input, pos, SEEK_SET);
    return -1;
  }
  type_str[p + 1] = '\n';
  items = sscanf(type_str, "%i", &type);
  if (items != 1) {
    fseek(input, pos, SEEK_SET);
    return -1;
  }
  fseek(input, pos, SEEK_SET);
  return type;
}


x86 assembly (clang, -O0):
<E_ReadDataType>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
movl   $0x0,-0x124(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     11ab <E_ReadDataType+0x4b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1310 <E_ReadDataType+0x1b0>
mov    -0x10(%rbp),%rdi
call   1050 <ftell@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x125(%rbp)
jne    1245 <E_ReadDataType+0xe5>
movslq -0x124(%rbp),%rax
lea    -0x120(%rbp),%rdi
add    %rax,%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
mov    %al,-0x125(%rbp)
jne    1245 <E_ReadDataType+0xe5>
movslq -0x124(%rbp),%rax
movsbl -0x120(%rbp,%rax,1),%ecx
ff
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x125(%rbp)
jl     1245 <E_ReadDataType+0xe5>
movslq -0x124(%rbp),%rax
movsbl -0x120(%rbp,%rax,1),%eax
ff
cmp    $0x39,%eax
setle  %al
mov    %al,-0x125(%rbp)
mov    -0x125(%rbp),%al
test   $0x1,%al
jne    1258 <E_ReadDataType+0xf8>
jmp    126c <E_ReadDataType+0x10c>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    11b8 <E_ReadDataType+0x58>
cmpl   $0x0,-0x124(%rbp)
jne    129b <E_ReadDataType+0x13b>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2d58(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1310 <E_ReadDataType+0x1b0>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0xa,-0x120(%rbp,%rax,1)
0a
lea    -0x120(%rbp),%rdi
lea    0xd44(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1070 <sscanf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
je     12f4 <E_ReadDataType+0x194>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2cff(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1310 <E_ReadDataType+0x1b0>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2cdd(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<E_ReadDataType>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x110,%rsp
mov    %rdi,%r12
xorps  %xmm0,%xmm0
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
call   1050 <feof@plt>
mov    $0xffffffff,%r15d
test   %rax,%rax
jne    120c <E_ReadDataType+0xbc>
mov    %r12,%rdi
call   1040 <ftell@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1050 <feof@plt>
test   %rax,%rax
je     121f <E_ReadDataType+0xcf>
mov    0x2de1(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <fseek@plt>
mov    %r15d,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%rsp,%rbx,1),%rbp
add    $0x10,%rbp
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    126d <E_ReadDataType+0x11d>
movzbl 0x0(%rbp),%eax
add    $0xd0,%al
cmp    $0x9,%al
ja     126d <E_ReadDataType+0x11d>
add    $0x1,%rbx
mov    %r12,%rdi
call   1050 <feof@plt>
test   %rax,%rax
je     1230 <E_ReadDataType+0xe0>
test   %ebx,%ebx
je     11f8 <E_ReadDataType+0xa8>
add    $0x1,%ebx
movb   $0xa,0x10(%rsp,%rbx,1)
lea    0xd80(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
call   1060 <sscanf@plt>
mov    %eax,%ebp
mov    0x2d48(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <fseek@plt>
mov    $0xffffffff,%r15d
cmp    $0x1,%ebp
jne    120c <E_ReadDataType+0xbc>
mov    0xc(%rsp),%r15d
jmp    120c <E_ReadDataType+0xbc>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [3 x i8] c"%i\00"
define i32 @E_ReadDataType(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca [256 x i8]
%8 = alloca i32
store i32* %0, i32** %3
%9 = bitcast [256 x i8]* %7 to i8*
store i32 0, i32* %8
%10 = load i32*, i32** %3
%11 = call i64 @feof(i32* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %1
store i32 -1, i32* %2
br label %75
14: ; preds = %1
%15 = load i32*, i32** %3
%16 = call i64 @ftell(i32* %15)
store i64 %16, i64* %6
br label %17
17: ; preds = %44, %14
%18 = load i32*, i32** %3
%19 = call i64 @feof(i32* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %42, label %21
21: ; preds = %17
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %23
%25 = load i32*, i32** %3
%26 = call i32 @fread(i8* %24, i32 1, i32 1, i32* %25)
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %42
28: ; preds = %21
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp sge i32 %33, 48
br i1 %34, label %35, label %42
35: ; preds = %28
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp sle i32 %40, 57
br label %42
42: ; preds = %35, %28, %21, %17
%43 = phi i1 [ false, %28 ], [ false, %21 ], [ false, %17 ], [ %41, %35 ]
br i1 %43, label %44, label %47
44: ; preds = %42
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %17
47: ; preds = %42
%48 = load i32, i32* %8
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %47
%51 = load i32*, i32** %3
%52 = load i64, i64* %6
%53 = load i32, i32* @SEEK_SET
%54 = call i32 @fseek(i32* %51, i64 %52, i32 %53)
store i32 -1, i32* %2
br label %75
55: ; preds = %47
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %58
store i8 10, i8* %59
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%61 = call i32 @sscanf(i8* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
store i32 %61, i32* %5
%62 = load i32, i32* %5
%63 = icmp ne i32 %62, 1
br i1 %63, label %64, label %69
64: ; preds = %55
%65 = load i32*, i32** %3
%66 = load i64, i64* %6
%67 = load i32, i32* @SEEK_SET
%68 = call i32 @fseek(i32* %65, i64 %66, i32 %67)
store i32 -1, i32* %2
br label %75
69: ; preds = %55
%70 = load i32*, i32** %3
%71 = load i64, i64* %6
%72 = load i32, i32* @SEEK_SET
%73 = call i32 @fseek(i32* %70, i64 %71, i32 %72)
%74 = load i32, i32* %4
store i32 %74, i32* %2
br label %75
75: ; preds = %69, %64, %50, %13
%76 = load i32, i32* %2
ret i32 %76
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [3 x i8] c"%i\00"
define i32 @E_ReadDataType(i32* nocapture %0) {
%2 = alloca i32
%3 = alloca [256 x i8]
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = tail call i64 @feof(i32* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %42
8: ; preds = %1
%9 = tail call i64 @ftell(i32* %0)
%10 = tail call i64 @feof(i32* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %29
12: ; preds = %8, %21
%13 = phi i64 [ %22, %21 ], [ 0, %8 ]
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %13
%15 = call i32 @fread(i8* %14, i32 1, i32 1, i32* %0)
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %25
17: ; preds = %12
%18 = load i8, i8* %14
%19 = add i8 %18, -48
%20 = icmp ult i8 %19, 10
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = add nuw i64 %13, 1
%23 = tail call i64 @feof(i32* %0)
%24 = icmp eq i64 %23, 0
br i1 %24, label %12, label %25
25: ; preds = %17, %12, %21
%26 = phi i64 [ %13, %17 ], [ %13, %12 ], [ %22, %21 ]
%27 = trunc i64 %26 to i32
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %8, %25
%30 = load i32, i32* @SEEK_SET
%31 = tail call i32 @fseek(i32* %0, i64 %9, i32 %30)
br label %42
32: ; preds = %25
%33 = add i64 %26, 1
%34 = and i64 %33, 4294967295
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %34
store i8 10, i8* %35
%36 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%37 = icmp eq i32 %36, 1
%38 = load i32, i32* @SEEK_SET
%39 = call i32 @fseek(i32* %0, i64 %9, i32 %38)
%40 = load i32, i32* %2
%41 = select i1 %37, i32 %40, i32 -1
br label %42
42: ; preds = %32, %1, %29
%43 = phi i32 [ -1, %29 ], [ -1, %1 ], [ %41, %32 ]
ret i32 %43
}