#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 readCharFromStream(FILE *file) {
  int result = getc(file);
  if (result == EOF) {
    return result;
  }
  result &= 0xff;
  if ((result & 0xE0) == 0xC0) {
    result <<= 8;
    result |= (getc(file) & 0xff);
  } else if ((result & 0xF0) == 0xE0) {
    result <<= 8;
    result |= (getc(file) & 0xff);
    result <<= 8;
    result |= (getc(file) & 0xff);
  } else if ((result & 0xF8) == 0xF0) {
    result <<= 8;
    result |= (getc(file) & 0xff);
    result <<= 8;
    result |= (getc(file) & 0xff);
    result <<= 8;
    result |= (getc(file) & 0xff);
  }
  return result;
}


x86 assembly (clang, -O0):
<readCharFromStream>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2eb6(%rip),%rcx
cmp    (%rcx),%eax
jne    1145 <readCharFromStream+0x35>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1251 <readCharFromStream+0x141>
mov    -0x14(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    $0xe0,%eax
cmp    $0xc0,%eax
jne    1185 <readCharFromStream+0x75>
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
and    $0xff,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    124b <readCharFromStream+0x13b>
mov    -0x14(%rbp),%eax
and    $0xf0,%eax
cmp    $0xe0,%eax
jne    11d7 <readCharFromStream+0xc7>
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
and    $0xff,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
and    $0xff,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1246 <readCharFromStream+0x136>
mov    -0x14(%rbp),%eax
and    $0xf8,%eax
cmp    $0xf0,%eax
jne    1241 <readCharFromStream+0x131>
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
and    $0xff,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
and    $0xff,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
and    $0xff,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1246 <readCharFromStream+0x136>
jmp    124b <readCharFromStream+0x13b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readCharFromStream>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <getc@plt>
mov    0x2ec2(%rip),%rcx
cmp    (%rcx),%eax
je     11bd <readCharFromStream+0xad>
movzbl %al,%ebp
mov    %eax,%ecx
and    $0xe0,%ecx
cmp    $0xc0,%ecx
jne    1154 <readCharFromStream+0x44>
shl    $0x8,%ebp
mov    %rbx,%rdi
call   1030 <getc@plt>
movzbl %al,%r14d
mov    %ebp,%eax
jmp    11ba <readCharFromStream+0xaa>
mov    %eax,%ecx
and    $0xf0,%ecx
cmp    $0xe0,%ecx
jne    117b <readCharFromStream+0x6b>
mov    %rbx,%rdi
call   1030 <getc@plt>
shl    $0x10,%ebp
shl    $0x8,%eax
movzwl %ax,%r14d
or     %ebp,%r14d
jmp    11af <readCharFromStream+0x9f>
and    $0xf8,%eax
cmp    $0xf0,%eax
jne    11c8 <readCharFromStream+0xb8>
mov    %rbx,%rdi
call   1030 <getc@plt>
shl    $0x10,%ebp
shl    $0x8,%eax
movzwl %ax,%r15d
or     %ebp,%r15d
mov    %rbx,%rdi
call   1030 <getc@plt>
movzbl %al,%r14d
or     %r15d,%r14d
shl    $0x8,%r14d
mov    %rbx,%rdi
call   1030 <getc@plt>
movzbl %al,%eax
or     %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%eax
jmp    11bd <readCharFromStream+0xad>

LLVM IR (-O0):
@EOF = global i32 0
define i32 @readCharFromStream(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
%5 = load i32*, i32** %3
%6 = call i32 @getc(i32* %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load i32, i32* %4
store i32 %11, i32* %2
br label %75
12: ; preds = %1
%13 = load i32, i32* %4
%14 = and i32 %13, 255
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = and i32 %15, 224
%17 = icmp eq i32 %16, 192
br i1 %17, label %18, label %26
18: ; preds = %12
%19 = load i32, i32* %4
%20 = shl i32 %19, 8
store i32 %20, i32* %4
%21 = load i32*, i32** %3
%22 = call i32 @getc(i32* %21)
%23 = and i32 %22, 255
%24 = load i32, i32* %4
%25 = or i32 %24, %23
store i32 %25, i32* %4
br label %73
26: ; preds = %12
%27 = load i32, i32* %4
%28 = and i32 %27, 240
%29 = icmp eq i32 %28, 224
br i1 %29, label %30, label %45
30: ; preds = %26
%31 = load i32, i32* %4
%32 = shl i32 %31, 8
store i32 %32, i32* %4
%33 = load i32*, i32** %3
%34 = call i32 @getc(i32* %33)
%35 = and i32 %34, 255
%36 = load i32, i32* %4
%37 = or i32 %36, %35
store i32 %37, i32* %4
%38 = load i32, i32* %4
%39 = shl i32 %38, 8
store i32 %39, i32* %4
%40 = load i32*, i32** %3
%41 = call i32 @getc(i32* %40)
%42 = and i32 %41, 255
%43 = load i32, i32* %4
%44 = or i32 %43, %42
store i32 %44, i32* %4
br label %72
45: ; preds = %26
%46 = load i32, i32* %4
%47 = and i32 %46, 248
%48 = icmp eq i32 %47, 240
br i1 %48, label %49, label %71
49: ; preds = %45
%50 = load i32, i32* %4
%51 = shl i32 %50, 8
store i32 %51, i32* %4
%52 = load i32*, i32** %3
%53 = call i32 @getc(i32* %52)
%54 = and i32 %53, 255
%55 = load i32, i32* %4
%56 = or i32 %55, %54
store i32 %56, i32* %4
%57 = load i32, i32* %4
%58 = shl i32 %57, 8
store i32 %58, i32* %4
%59 = load i32*, i32** %3
%60 = call i32 @getc(i32* %59)
%61 = and i32 %60, 255
%62 = load i32, i32* %4
%63 = or i32 %62, %61
store i32 %63, i32* %4
%64 = load i32, i32* %4
%65 = shl i32 %64, 8
store i32 %65, i32* %4
%66 = load i32*, i32** %3
%67 = call i32 @getc(i32* %66)
%68 = and i32 %67, 255
%69 = load i32, i32* %4
%70 = or i32 %69, %68
store i32 %70, i32* %4
br label %71
71: ; preds = %49, %45
br label %72
72: ; preds = %71, %30
br label %73
73: ; preds = %72, %18
%74 = load i32, i32* %4
store i32 %74, i32* %2
br label %75
75: ; preds = %73, %10
%76 = load i32, i32* %2
ret i32 %76
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @readCharFromStream(i32* nocapture %0) {
%2 = tail call i32 @getc(i32* %0)
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %43, label %5
5: ; preds = %1
%6 = and i32 %2, 255
%7 = and i32 %2, 224
%8 = icmp eq i32 %7, 192
br i1 %8, label %9, label %13
9: ; preds = %5
%10 = shl nuw nsw i32 %6, 8
%11 = tail call i32 @getc(i32* %0)
%12 = and i32 %11, 255
br label %39
13: ; preds = %5
%14 = and i32 %2, 240
%15 = icmp eq i32 %14, 224
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = tail call i32 @getc(i32* %0)
%18 = shl nuw nsw i32 %6, 16
%19 = shl i32 %17, 8
%20 = and i32 %19, 65280
%21 = or i32 %20, %18
%22 = tail call i32 @getc(i32* %0)
%23 = and i32 %22, 255
br label %39
24: ; preds = %13
%25 = and i32 %2, 248
%26 = icmp eq i32 %25, 240
br i1 %26, label %27, label %43
27: ; preds = %24
%28 = tail call i32 @getc(i32* %0)
%29 = shl nuw nsw i32 %6, 16
%30 = shl i32 %28, 8
%31 = and i32 %30, 65280
%32 = or i32 %31, %29
%33 = tail call i32 @getc(i32* %0)
%34 = and i32 %33, 255
%35 = or i32 %32, %34
%36 = shl nuw i32 %35, 8
%37 = tail call i32 @getc(i32* %0)
%38 = and i32 %37, 255
br label %39
39: ; preds = %16, %27, %9
%40 = phi i32 [ %10, %9 ], [ %38, %27 ], [ %23, %16 ]
%41 = phi i32 [ %12, %9 ], [ %36, %27 ], [ %21, %16 ]
%42 = or i32 %41, %40
br label %43
43: ; preds = %39, %24, %1
%44 = phi i32 [ %2, %1 ], [ %6, %24 ], [ %42, %39 ]
ret i32 %44
}