#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*/ __u16;

/* Variables and functions */
int /*<<< orphan*/ __le16_to_cpus(int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int fromhex(unsigned char);
int /*<<< orphan*/ identify(unsigned short *, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int read(int /*<<< orphan*/, unsigned char *, int);
int /*<<< orphan*/ stderr;
int identify_from_stdin(void) {
  unsigned short sbuf[800];
  unsigned char buf[1600], *b = (unsigned char *)buf;
  int i, count;
  while (1 == read(0, buf, 1) && (*buf < '0' || *buf > '9') &&
         (*buf < 'a' || *buf > 'f'))
    while (1 == read(0, buf, 1) && *buf != '\n')
      ;
  count = read(0, buf + 1, 1279);
  if (count != 1279) {
    fprintf(stderr, "read(1279 bytes) failed (rc=%d)", count);
    perror("");
    exit(errno);
  }
  for (i = 0; count >= 4; ++i) {
    sbuf[i] = (fromhex(b[0]) << 12) | (fromhex(b[1]) << 8) |
              (fromhex(b[2]) << 4) | fromhex(b[3]);
    __le16_to_cpus((__u16 *)(&sbuf[i]));
    b += 5;
    count -= 5;
  }
  identify(sbuf, NULL);
  return 0;
}


x86 assembly (clang, -O0):
<identify_from_stdin>:
push   %rbp
mov    %rsp,%rbp
sub    $0xca0,%rsp
lea    -0xc80(%rbp),%rax
mov    %rax,-0xc88(%rbp)
lea    -0xc80(%rbp),%rsi
xor    %edi,%edi
mov    $0x1,%edx
call   1040 <read@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %edx,%ecx
mov    %al,-0xc91(%rbp)
jne    1212 <identify_from_stdin+0xa2>
movzbl -0xc80(%rbp),%eax
cmp    $0x30,%eax
jl     11db <identify_from_stdin+0x6b>
movzbl -0xc80(%rbp),%ecx
xor    %eax,%eax
cmp    $0x39,%ecx
mov    %al,-0xc91(%rbp)
jle    1212 <identify_from_stdin+0xa2>
movzbl -0xc80(%rbp),%ecx
mov    $0x1,%al
cmp    $0x61,%ecx
mov    %al,-0xc92(%rbp)
jl     1206 <identify_from_stdin+0x96>
movzbl -0xc80(%rbp),%eax
cmp    $0x66,%eax
setg   %al
mov    %al,-0xc92(%rbp)
mov    -0xc92(%rbp),%al
mov    %al,-0xc91(%rbp)
mov    -0xc91(%rbp),%al
test   $0x1,%al
jne    1225 <identify_from_stdin+0xb5>
jmp    1284 <identify_from_stdin+0x114>
jmp    122a <identify_from_stdin+0xba>
lea    -0xc80(%rbp),%rsi
xor    %edi,%edi
mov    $0x1,%edx
call   1040 <read@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %edx,%ecx
mov    %al,-0xc93(%rbp)
jne    1267 <identify_from_stdin+0xf7>
movzbl -0xc80(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0xc93(%rbp)
mov    -0xc93(%rbp),%al
test   $0x1,%al
jne    127a <identify_from_stdin+0x10a>
jmp    127f <identify_from_stdin+0x10f>
jmp    122a <identify_from_stdin+0xba>
jmp    1189 <identify_from_stdin+0x19>
lea    -0xc80(%rbp),%rsi
add    $0x1,%rsi
xor    %edi,%edi
mov    $0x4ff,%edx
call   1040 <read@plt>
mov    %eax,-0xc90(%rbp)
cmpl   $0x4ff,-0xc90(%rbp)
je     12e6 <identify_from_stdin+0x176>
mov    0x2d28(%rip),%rax
mov    (%rax),%edi
mov    -0xc90(%rbp),%edx
lea    0xd39(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xd4c(%rip),%rdi
call   1080 <perror@plt>
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
movl   $0x0,-0xc8c(%rbp)
cmpl   $0x4,-0xc90(%rbp)
jl     13d6 <identify_from_stdin+0x266>
mov    -0xc88(%rbp),%rax
movzbl (%rax),%edi
call   1030 <fromhex@plt>
shl    $0xc,%eax
mov    %eax,-0xca0(%rbp)
mov    -0xc88(%rbp),%rax
movzbl 0x1(%rax),%edi
call   1030 <fromhex@plt>
mov    %eax,%ecx
mov    -0xca0(%rbp),%eax
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0xc9c(%rbp)
mov    -0xc88(%rbp),%rax
movzbl 0x2(%rax),%edi
call   1030 <fromhex@plt>
mov    %eax,%ecx
mov    -0xc9c(%rbp),%eax
shl    $0x4,%ecx
or     %ecx,%eax
mov    %eax,-0xc98(%rbp)
mov    -0xc88(%rbp),%rax
movzbl 0x3(%rax),%edi
call   1030 <fromhex@plt>
mov    %eax,%ecx
mov    -0xc98(%rbp),%eax
or     %ecx,%eax
mov    %ax,%cx
movslq -0xc8c(%rbp),%rax
mov    %cx,-0x640(%rbp,%rax,2)
ff
movslq -0xc8c(%rbp),%rax
lea    -0x640(%rbp),%rdi
shl    $0x1,%rax
add    %rax,%rdi
call   1070 <__le16_to_cpus@plt>
mov    -0xc88(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0xc88(%rbp)
mov    -0xc90(%rbp),%eax
sub    $0x5,%eax
mov    %eax,-0xc90(%rbp)
mov    -0xc8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc8c(%rbp)
jmp    12f0 <identify_from_stdin+0x180>
lea    -0x640(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <identify@plt>
xor    %eax,%eax
add    $0xca0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<identify_from_stdin>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xc88,%rsp
mov    %rsp,%rsi
xor    %edi,%edi
mov    $0x1,%edx
call   1040 <read@plt>
cmp    $0x1,%eax
jne    11ec <identify_from_stdin+0x7c>
mov    %rsp,%rbx
jmp    11b4 <identify_from_stdin+0x44>
cs nopw 0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <read@plt>
cmp    $0x1,%eax
jne    11ec <identify_from_stdin+0x7c>
mov    (%rsp),%al
lea    -0x3a(%rax),%ecx
cmp    $0xf5,%cl
ja     11ec <identify_from_stdin+0x7c>
add    $0x99,%al
cmp    $0xf9,%al
ja     11ec <identify_from_stdin+0x7c>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <read@plt>
cmp    $0x1,%eax
jne    11a0 <identify_from_stdin+0x30>
cmpb   $0xa,(%rsp)
jne    11d0 <identify_from_stdin+0x60>
jmp    11a0 <identify_from_stdin+0x30>
lea    0x1(%rsp),%rsi
xor    %edi,%edi
mov    $0x4ff,%edx
call   1040 <read@plt>
cmp    $0x4ff,%eax
jne    129e <identify_from_stdin+0x12e>
lea    0x640(%rsp),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rsp,%rbp,1),%edi
call   1030 <fromhex@plt>
mov    %eax,%r15d
shl    $0xc,%r15d
movzbl 0x1(%rsp,%rbp,1),%edi
call   1030 <fromhex@plt>
mov    %eax,%ebx
shl    $0x8,%ebx
or     %r15d,%ebx
movzbl 0x2(%rsp,%rbp,1),%edi
call   1030 <fromhex@plt>
mov    %eax,%r15d
shl    $0x4,%r15d
movzbl 0x3(%rsp,%rbp,1),%edi
call   1030 <fromhex@plt>
or     %r15d,%eax
or     %ebx,%eax
mov    %ax,(%r14)
mov    %r14,%rdi
call   1070 <__le16_to_cpus@plt>
add    $0x2,%r14
add    $0x5,%rbp
cmp    $0x500,%rbp
jne    1220 <identify_from_stdin+0xb0>
lea    0x640(%rsp),%rdi
xor    %esi,%esi
call   1060 <identify@plt>
xor    %eax,%eax
add    $0xc88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d3b(%rip),%rcx
mov    (%rcx),%edi
lea    0xd52(%rip),%rsi
mov    %eax,%edx
call   1050 <fprintf@plt>
lea    0xd63(%rip),%rdi
call   1080 <perror@plt>
mov    0x2d10(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"read(1279 bytes) failed (rc=%d)\00"
@.str.1 = [1 x i8] zeroinitializer
@errno = global i32 0
define i32 @identify_from_stdin() {
%1 = alloca [800 x i16]
%2 = alloca [1600 x i8]
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [1600 x i8], [1600 x i8]* %2, i64 0, i64 0
store i8* %6, i8** %3
br label %7
7: ; preds = %48, %0
%8 = getelementptr inbounds [1600 x i8], [1600 x i8]* %2, i64 0, i64 0
%9 = call i32 @read(i32 0, i8* %8, i32 1)
%10 = icmp eq i32 1, %9
br i1 %10, label %11, label %33
11: ; preds = %7
%12 = getelementptr inbounds [1600 x i8], [1600 x i8]* %2, i64 0, i64 0
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = icmp slt i32 %14, 48
br i1 %15, label %21, label %16
16: ; preds = %11
%17 = getelementptr inbounds [1600 x i8], [1600 x i8]* %2, i64 0, i64 0
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = icmp sgt i32 %19, 57
br i1 %20, label %21, label %33
21: ; preds = %16, %11
%22 = getelementptr inbounds [1600 x i8], [1600 x i8]* %2, i64 0, i64 0
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = icmp slt i32 %24, 97
br i1 %25, label %31, label %26
26: ; preds = %21
%27 = getelementptr inbounds [1600 x i8], [1600 x i8]* %2, i64 0, i64 0
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = icmp sgt i32 %29, 102
br label %31
31: ; preds = %26, %21
%32 = phi i1 [ true, %21 ], [ %30, %26 ]
br label %33
33: ; preds = %31, %16, %7
%34 = phi i1 [ false, %16 ], [ false, %7 ], [ %32, %31 ]
br i1 %34, label %35, label %49
35: ; preds = %33
br label %36
36: ; preds = %47, %35
%37 = getelementptr inbounds [1600 x i8], [1600 x i8]* %2, i64 0, i64 0
%38 = call i32 @read(i32 0, i8* %37, i32 1)
%39 = icmp eq i32 1, %38
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = getelementptr inbounds [1600 x i8], [1600 x i8]* %2, i64 0, i64 0
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = icmp ne i32 %43, 10
br label %45
45: ; preds = %40, %36
%46 = phi i1 [ false, %36 ], [ %44, %40 ]
br i1 %46, label %47, label %48
47: ; preds = %45
br label %36
48: ; preds = %45
br label %7
49: ; preds = %33
%50 = getelementptr inbounds [1600 x i8], [1600 x i8]* %2, i64 0, i64 0
%51 = getelementptr inbounds i8, i8* %50, i64 1
%52 = call i32 @read(i32 0, i8* %51, i32 1279)
store i32 %52, i32* %5
%53 = load i32, i32* %5
%54 = icmp ne i32 %53, 1279
br i1 %54, label %55, label %62
55: ; preds = %49
%56 = load i32, i32* @stderr
%57 = load i32, i32* %5
%58 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %57)
%59 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%60 = load i32, i32* @errno
%61 = call i32 @exit(i32 %60)
unreachable
62: ; preds = %49
store i32 0, i32* %4
br label %63
63: ; preds = %102, %62
%64 = load i32, i32* %5
%65 = icmp sge i32 %64, 4
br i1 %65, label %66, label %105
66: ; preds = %63
%67 = load i8*, i8** %3
%68 = getelementptr inbounds i8, i8* %67, i64 0
%69 = load i8, i8* %68
%70 = call i32 @fromhex(i8 zeroext %69)
%71 = shl i32 %70, 12
%72 = load i8*, i8** %3
%73 = getelementptr inbounds i8, i8* %72, i64 1
%74 = load i8, i8* %73
%75 = call i32 @fromhex(i8 zeroext %74)
%76 = shl i32 %75, 8
%77 = or i32 %71, %76
%78 = load i8*, i8** %3
%79 = getelementptr inbounds i8, i8* %78, i64 2
%80 = load i8, i8* %79
%81 = call i32 @fromhex(i8 zeroext %80)
%82 = shl i32 %81, 4
%83 = or i32 %77, %82
%84 = load i8*, i8** %3
%85 = getelementptr inbounds i8, i8* %84, i64 3
%86 = load i8, i8* %85
%87 = call i32 @fromhex(i8 zeroext %86)
%88 = or i32 %83, %87
%89 = trunc i32 %88 to i16
%90 = load i32, i32* %4
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [800 x i16], [800 x i16]* %1, i64 0, i64 %91
store i16 %89, i16* %92
%93 = load i32, i32* %4
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [800 x i16], [800 x i16]* %1, i64 0, i64 %94
%96 = bitcast i16* %95 to i32*
%97 = call i32 @__le16_to_cpus(i32* %96)
%98 = load i8*, i8** %3
%99 = getelementptr inbounds i8, i8* %98, i64 5
store i8* %99, i8** %3
%100 = load i32, i32* %5
%101 = sub nsw i32 %100, 5
store i32 %101, i32* %5
br label %102
102: ; preds = %66
%103 = load i32, i32* %4
%104 = add nsw i32 %103, 1
store i32 %104, i32* %4
br label %63
105: ; preds = %63
%106 = getelementptr inbounds [800 x i16], [800 x i16]* %1, i64 0, i64 0
%107 = call i32 @identify(i16* %106, i32* null)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"read(1279 bytes) failed (rc=%d)\00"
@.str.1 = [1 x i8] zeroinitializer
@errno = global i32 0
define i32 @identify_from_stdin() {
%1 = alloca [800 x i16]
%2 = alloca [1600 x i8]
%3 = bitcast [800 x i16]* %1 to i8*
%4 = getelementptr inbounds [1600 x i8], [1600 x i8]* %2, i64 0, i64 0
%5 = call i32 @read(i32 0, i8* %4, i32 1)
%6 = icmp eq i32 %5, 1
br i1 %6, label %10, label %23
7: ; preds = %17
%8 = call i32 @read(i32 0, i8* %4, i32 1)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %23
10: ; preds = %0, %7
%11 = load i8, i8* %4
%12 = add i8 %11, -58
%13 = icmp ult i8 %12, -10
%14 = add i8 %11, -103
%15 = icmp ult i8 %14, -6
%16 = and i1 %13, %15
br i1 %16, label %17, label %23
17: ; preds = %10, %17
%18 = call i32 @read(i32 0, i8* %4, i32 1)
%19 = icmp eq i32 %18, 1
%20 = load i8, i8* %4
%21 = icmp ne i8 %20, 10
%22 = select i1 %19, i1 %21, i1 false
br i1 %22, label %17, label %7
23: ; preds = %7, %10, %0
%24 = getelementptr inbounds [1600 x i8], [1600 x i8]* %2, i64 0, i64 1
%25 = call i32 @read(i32 0, i8* %24, i32 1279)
%26 = icmp eq i32 %25, 1279
br i1 %26, label %33, label %27
27: ; preds = %23
%28 = load i32, i32* @stderr
%29 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %25)
%30 = tail call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32, i32* @errno
%32 = tail call i32 @exit(i32 %31)
unreachable
33: ; preds = %23, %33
%34 = phi i64 [ %58, %33 ], [ 0, %23 ]
%35 = phi i8* [ %57, %33 ], [ %4, %23 ]
%36 = load i8, i8* %35
%37 = call i32 @fromhex(i8 zeroext %36)
%38 = shl i32 %37, 12
%39 = getelementptr inbounds i8, i8* %35, i64 1
%40 = load i8, i8* %39
%41 = call i32 @fromhex(i8 zeroext %40)
%42 = shl i32 %41, 8
%43 = or i32 %42, %38
%44 = getelementptr inbounds i8, i8* %35, i64 2
%45 = load i8, i8* %44
%46 = call i32 @fromhex(i8 zeroext %45)
%47 = shl i32 %46, 4
%48 = or i32 %43, %47
%49 = getelementptr inbounds i8, i8* %35, i64 3
%50 = load i8, i8* %49
%51 = call i32 @fromhex(i8 zeroext %50)
%52 = or i32 %48, %51
%53 = trunc i32 %52 to i16
%54 = getelementptr inbounds [800 x i16], [800 x i16]* %1, i64 0, i64 %34
store i16 %53, i16* %54
%55 = bitcast i16* %54 to i32*
%56 = call i32 @__le16_to_cpus(i32* %55)
%57 = getelementptr inbounds i8, i8* %35, i64 5
%58 = add nuw nsw i64 %34, 1
%59 = icmp eq i64 %58, 256
br i1 %59, label %60, label %33
60: ; preds = %33
%61 = getelementptr inbounds [800 x i16], [800 x i16]* %1, i64 0, i64 0
%62 = call i32 @identify(i16* %61, i32* null)
ret i32 0
}