#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*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ isalnum(char);
char *readitem(FILE *file, char *buffer) {
  char *aux;
  int k;
  k = 0;
  aux = buffer;
  while (!feof(file)) {
    *aux = fgetc(file);
    switch (k) {
    case 0:
      if (*aux == '#')
        k = 1;
      if (isalnum(*aux))
        k = 2, aux++;
      break;
    case 1:
      if (*aux == 0xA)
        k = 0;
      break;
    case 2:
      if (!isalnum(*aux)) {
        *aux = 0;
        return buffer;
      }
      aux++;
      break;
    }
  }
  *aux = 0;
  return buffer;
}


x86 assembly (clang, -O0):
<readitem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    116d <readitem+0x3d>
jmp    124d <readitem+0x11d>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
test   %eax,%eax
je     11b3 <readitem+0x83>
jmp    1191 <readitem+0x61>
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
je     11f7 <readitem+0xc7>
jmp    11a2 <readitem+0x72>
mov    -0x28(%rbp),%eax
sub    $0x2,%eax
je     1213 <readitem+0xe3>
jmp    1248 <readitem+0x118>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    11ca <readitem+0x9a>
movl   $0x1,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
je     11f2 <readitem+0xc2>
movl   $0x2,-0x24(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1248 <readitem+0x118>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    120e <readitem+0xde>
movl   $0x0,-0x24(%rbp)
jmp    1248 <readitem+0x118>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    123c <readitem+0x10c>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <readitem+0x12c>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    114f <readitem+0x1f>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readitem>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <feof@plt>
mov    %r14,%rbx
test   %eax,%eax
je     1159 <readitem+0x29>
movb   $0x0,(%rbx)
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
mov    $0x2,%r12d
mov    %r14,%rbx
jmp    1184 <readitem+0x54>
cs nopw 0x0(%rax,%rax,1)
xor    %ebp,%ebp
cmp    $0xa,%al
setne  %bpl
mov    %r15,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    114a <readitem+0x1a>
mov    %r15,%rdi
call   1040 <fgetc@plt>
mov    %al,(%rbx)
cmp    $0x2,%ebp
je     11c0 <readitem+0x90>
cmp    $0x1,%ebp
je     1170 <readitem+0x40>
test   %ebp,%ebp
jne    1178 <readitem+0x48>
xor    %ebp,%ebp
cmp    $0x23,%al
sete   %bpl
movsbl %al,%edi
call   1030 <isalnum@plt>
xor    %ecx,%ecx
test   %eax,%eax
setne  %cl
cmovne %r12d,%ebp
add    %rcx,%rbx
jmp    1178 <readitem+0x48>
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %eax,%eax
je     114a <readitem+0x1a>
add    $0x1,%rbx
mov    $0x2,%ebp
jmp    1178 <readitem+0x48>

LLVM IR (-O0):
define i8* @readitem(i32* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 0, i32* %7
%8 = load i8*, i8** %5
store i8* %8, i8** %6
br label %9
9: ; preds = %52, %2
%10 = load i32*, i32** %4
%11 = call i32 @feof(i32* %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %53
14: ; preds = %9
%15 = load i32*, i32** %4
%16 = call signext i8 @fgetc(i32* %15)
%17 = load i8*, i8** %6
store i8 %16, i8* %17
%18 = load i32, i32* %7
switch i32 %18, label %52 [
i32 0, label %19
i32 1, label %34
i32 2, label %41
]
19: ; preds = %14
%20 = load i8*, i8** %6
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 35
br i1 %23, label %24, label %25
24: ; preds = %19
store i32 1, i32* %7
br label %25
25: ; preds = %24, %19
%26 = load i8*, i8** %6
%27 = load i8, i8* %26
%28 = call i32 @isalnum(i8 signext %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %25
store i32 2, i32* %7
%31 = load i8*, i8** %6
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %6
br label %33
33: ; preds = %30, %25
br label %52
34: ; preds = %14
%35 = load i8*, i8** %6
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 10
br i1 %38, label %39, label %40
39: ; preds = %34
store i32 0, i32* %7
br label %40
40: ; preds = %39, %34
br label %52
41: ; preds = %14
%42 = load i8*, i8** %6
%43 = load i8, i8* %42
%44 = call i32 @isalnum(i8 signext %43)
%45 = icmp ne i32 %44, 0
br i1 %45, label %49, label %46
46: ; preds = %41
%47 = load i8*, i8** %6
store i8 0, i8* %47
%48 = load i8*, i8** %5
store i8* %48, i8** %3
br label %56
49: ; preds = %41
%50 = load i8*, i8** %6
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %6
br label %52
52: ; preds = %14, %49, %40, %33
br label %9
53: ; preds = %9
%54 = load i8*, i8** %6
store i8 0, i8* %54
%55 = load i8*, i8** %5
store i8* %55, i8** %3
br label %56
56: ; preds = %53, %46
%57 = load i8*, i8** %3
ret i8* %57
}

LLVM IR (-O2):
define i8* @readitem(i32* nocapture %0, i8* returned %1) {
%3 = tail call i32 @feof(i32* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %31
5: ; preds = %2, %26
%6 = phi i32 [ %28, %26 ], [ 0, %2 ]
%7 = phi i8* [ %27, %26 ], [ %1, %2 ]
%8 = tail call signext i8 @fgetc(i32* %0)
store i8 %8, i8* %7
switch i32 %6, label %26 [
i32 0, label %9
i32 1, label %18
i32 2, label %21
]
9: ; preds = %5
%10 = icmp eq i8 %8, 35
%11 = zext i1 %10 to i32
%12 = tail call i32 @isalnum(i8 signext %8)
%13 = icmp eq i32 %12, 0
%14 = xor i1 %13, true
%15 = zext i1 %14 to i64
%16 = getelementptr i8, i8* %7, i64 %15
%17 = select i1 %13, i32 %11, i32 2
br label %26
18: ; preds = %5
%19 = icmp ne i8 %8, 10
%20 = zext i1 %19 to i32
br label %26
21: ; preds = %5
%22 = tail call i32 @isalnum(i8 signext %8)
%23 = icmp eq i32 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %21
%25 = getelementptr inbounds i8, i8* %7, i64 1
br label %26
26: ; preds = %9, %18, %5, %24
%27 = phi i8* [ %7, %5 ], [ %25, %24 ], [ %7, %18 ], [ %16, %9 ]
%28 = phi i32 [ %6, %5 ], [ 2, %24 ], [ %20, %18 ], [ %17, %9 ]
%29 = tail call i32 @feof(i32* %0)
%30 = icmp eq i32 %29, 0
br i1 %30, label %5, label %31
31: ; preds = %21, %26, %2
%32 = phi i8* [ %1, %2 ], [ %27, %26 ], [ %7, %21 ]
store i8 0, i8* %32
ret i8* %1
}