#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 getc(int /*<<< orphan*/ *);
int egetc(FILE *istream) {
  static int spleft = 0;
  static int linepos = 0;
  int c;
  if (spleft > 0) {
    spleft--;
    linepos++;
    return ' ';
  }
  c = getc(istream);
  if (c == EOF)
    return c;
  else if (c == '\n' || c == '\f') {
    linepos = 0;
    return c;
  } else if (c == '\t') {
    spleft = 8 - linepos % 8;
    spleft--;
    linepos++;
    return ' ';
  } else {
    linepos++;
    return c;
  }
}


x86 assembly (clang, -O0):
<egetc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpl   $0x0,0x2f09(%rip)
jle    1153 <egetc+0x43>
mov    0x2efd(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2ef4(%rip)
mov    0x2ef2(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ee9(%rip)
movl   $0x20,-0x4(%rbp)
jmp    1209 <egetc+0xf9>
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e7f(%rip),%rcx
cmp    (%rcx),%eax
jne    117c <egetc+0x6c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1209 <egetc+0xf9>
cmpl   $0xa,-0x14(%rbp)
je     1190 <egetc+0x80>
cmpl   $0xc,-0x14(%rbp)
jne    11a5 <egetc+0x95>
movl   $0x0,0x2e96(%rip)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1209 <egetc+0xf9>
cmpl   $0x9,-0x14(%rbp)
jne    11f4 <egetc+0xe4>
mov    0x2e7b(%rip),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    $0x8,%eax
sub    %edx,%eax
mov    %eax,0x2e62(%rip)
mov    0x2e5c(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2e53(%rip)
mov    0x2e51(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e48(%rip)
movl   $0x20,-0x4(%rbp)
jmp    1209 <egetc+0xf9>
mov    0x2e36(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e2d(%rip)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<egetc>:
push   %rax
mov    0x2f15(%rip),%eax
test   %eax,%eax
jle    113a <egetc+0x2a>
add    $0xffffffff,%eax
mov    %eax,0x2f08(%rip)
mov    0x2f06(%rip),%ecx
add    $0x1,%ecx
mov    $0x20,%eax
mov    %ecx,0x2ef8(%rip)
pop    %rcx
ret
call   1030 <getc@plt>
mov    0x2ea2(%rip),%rcx
cmp    (%rcx),%eax
je     1138 <egetc+0x28>
xor    %ecx,%ecx
cmp    $0xc,%eax
je     1132 <egetc+0x22>
cmp    $0xa,%eax
je     1132 <egetc+0x22>
cmp    $0x9,%eax
jne    1179 <egetc+0x69>
mov    0x2ecf(%rip),%ecx
lea    0x7(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
and    $0xfffffff8,%eax
sub    %ecx,%eax
add    $0x7,%eax
mov    %eax,0x2eb5(%rip)
jmp    112a <egetc+0x1a>
mov    0x2eb1(%rip),%ecx
add    $0x1,%ecx
jmp    1132 <egetc+0x22>

LLVM IR (-O0):
@egetc.spleft = internal global i32 0
@egetc.linepos = internal global i32 0
@EOF = global i32 0
define i32 @egetc(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
%5 = load i32, i32* @egetc.spleft
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i32, i32* @egetc.spleft
%9 = add nsw i32 %8, -1
store i32 %9, i32* @egetc.spleft
%10 = load i32, i32* @egetc.linepos
%11 = add nsw i32 %10, 1
store i32 %11, i32* @egetc.linepos
store i32 32, i32* %2
br label %43
12: ; preds = %1
%13 = load i32*, i32** %3
%14 = call i32 @getc(i32* %13)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = load i32, i32* %4
store i32 %19, i32* %2
br label %43
20: ; preds = %12
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 10
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 12
br i1 %25, label %26, label %28
26: ; preds = %23, %20
store i32 0, i32* @egetc.linepos
%27 = load i32, i32* %4
store i32 %27, i32* %2
br label %43
28: ; preds = %23
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 9
br i1 %30, label %31, label %39
31: ; preds = %28
%32 = load i32, i32* @egetc.linepos
%33 = srem i32 %32, 8
%34 = sub nsw i32 8, %33
store i32 %34, i32* @egetc.spleft
%35 = load i32, i32* @egetc.spleft
%36 = add nsw i32 %35, -1
store i32 %36, i32* @egetc.spleft
%37 = load i32, i32* @egetc.linepos
%38 = add nsw i32 %37, 1
store i32 %38, i32* @egetc.linepos
store i32 32, i32* %2
br label %43
39: ; preds = %28
%40 = load i32, i32* @egetc.linepos
%41 = add nsw i32 %40, 1
store i32 %41, i32* @egetc.linepos
%42 = load i32, i32* %4
store i32 %42, i32* %2
br label %43
43: ; preds = %39, %31, %26, %18, %7
%44 = load i32, i32* %2
ret i32 %44
}

LLVM IR (-O2):
@egetc.spleft = internal unnamed_addr global i32 0
@egetc.linepos = internal unnamed_addr global i32 0
@EOF = global i32 0
define i32 @egetc(i32* nocapture %0) {
%2 = load i32, i32* @egetc.spleft
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = add nsw i32 %2, -1
store i32 %5, i32* @egetc.spleft
%6 = load i32, i32* @egetc.linepos
%7 = add nsw i32 %6, 1
br label %21
8: ; preds = %1
%9 = tail call i32 @getc(i32* %0)
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %24, label %12
12: ; preds = %8
switch i32 %9, label %18 [
i32 12, label %21
i32 10, label %21
i32 9, label %13
]
13: ; preds = %12
%14 = load i32, i32* @egetc.linepos
%15 = srem i32 %14, 8
%16 = sub nsw i32 7, %15
store i32 %16, i32* @egetc.spleft
%17 = add nsw i32 %14, 1
br label %21
18: ; preds = %12
%19 = load i32, i32* @egetc.linepos
%20 = add nsw i32 %19, 1
br label %21
21: ; preds = %12, %12, %4, %13, %18
%22 = phi i32 [ %20, %18 ], [ %17, %13 ], [ %7, %4 ], [ 0, %12 ], [ 0, %12 ]
%23 = phi i32 [ %9, %18 ], [ 32, %13 ], [ 32, %4 ], [ %9, %12 ], [ %9, %12 ]
store i32 %22, i32* @egetc.linepos
br label %24
24: ; preds = %21, %8
%25 = phi i32 [ %9, %8 ], [ %23, %21 ]
ret i32 %25
}