#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 /*<<< orphan*/ *FindFptr(void *, char const *);
int /*<<< orphan*/ clearerr(int /*<<< orphan*/ *);
int gengetchar(void *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdin;
int GetcFile(void *theEnv, const char *logicalName) {
  FILE *fptr;
  int theChar;
  fptr = FindFptr(theEnv, logicalName);
  if (fptr == stdin) {
    theChar = gengetchar(theEnv);
  } else {
    theChar = getc(fptr);
  }
  if ((fptr == stdin) && (theChar == EOF))
    clearerr(stdin);
  return (theChar);
}


x86 assembly (clang, -O0):
<GetcFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <FindFptr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2e7c(%rip),%rcx
cmp    (%rcx),%rax
jne    1186 <GetcFile+0x46>
mov    -0x8(%rbp),%rdi
call   1040 <gengetchar@plt>
mov    %eax,-0x1c(%rbp)
jmp    1192 <GetcFile+0x52>
mov    -0x18(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2e4b(%rip),%rcx
cmp    (%rcx),%rax
jne    11c7 <GetcFile+0x87>
mov    -0x1c(%rbp),%eax
mov    0x2e30(%rip),%rcx
cmp    (%rcx),%eax
jne    11c7 <GetcFile+0x87>
mov    0x2e29(%rip),%rax
mov    (%rax),%rdi
call   1050 <clearerr@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetcFile>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbp
call   1030 <FindFptr@plt>
mov    %rax,%rbx
mov    0x2e92(%rip),%r14
cmp    (%r14),%rax
je     1165 <GetcFile+0x25>
mov    %rbx,%rdi
call   1060 <getc@plt>
jmp    116d <GetcFile+0x2d>
mov    %rbp,%rdi
call   1040 <gengetchar@plt>
mov    %eax,%ebp
cmp    (%r14),%rbx
jne    1187 <GetcFile+0x47>
mov    0x2e65(%rip),%rax
cmp    (%rax),%ebp
jne    1187 <GetcFile+0x47>
mov    %rbx,%rdi
call   1050 <clearerr@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32* null
@EOF = global i32 0
define i32 @GetcFile(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = load i8*, i8** %4
%9 = call i32* @FindFptr(i8* %7, i8* %8)
store i32* %9, i32** %5
%10 = load i32*, i32** %5
%11 = load i32*, i32** @stdin
%12 = icmp eq i32* %10, %11
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = call i32 @gengetchar(i8* %14)
store i32 %15, i32* %6
br label %19
16: ; preds = %2
%17 = load i32*, i32** %5
%18 = call i32 @getc(i32* %17)
store i32 %18, i32* %6
br label %19
19: ; preds = %16, %13
%20 = load i32*, i32** %5
%21 = load i32*, i32** @stdin
%22 = icmp eq i32* %20, %21
br i1 %22, label %23, label %30
23: ; preds = %19
%24 = load i32, i32* %6
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32*, i32** @stdin
%29 = call i32 @clearerr(i32* %28)
br label %30
30: ; preds = %27, %23, %19
%31 = load i32, i32* %6
ret i32 %31
}

LLVM IR (-O2):
@stdin = global i32* null
@EOF = global i32 0
define i32 @GetcFile(i8* %0, i8* %1) {
%3 = tail call i32* @FindFptr(i8* %0, i8* %1)
%4 = load i32*, i32** @stdin
%5 = icmp eq i32* %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @gengetchar(i8* %0)
br label %10
8: ; preds = %2
%9 = tail call i32 @getc(i32* %3)
br label %10
10: ; preds = %8, %6
%11 = phi i32 [ %7, %6 ], [ %9, %8 ]
%12 = load i32*, i32** @stdin
%13 = icmp eq i32* %3, %12
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %11, %14
%16 = select i1 %13, i1 %15, i1 false
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = tail call i32 @clearerr(i32* %3)
br label %19
19: ; preds = %17, %10
ret i32 %11
}