#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*/ HandleInput(char *);
scalar_t__ feof(int /*<<< orphan*/ *);
char *fgets(char *, int const, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
void inputLoop(FILE *stream) {
  const int MAX_CHAR = 255;
  char line[MAX_CHAR];
  char *return_val;
  while (1) {
    printf("Please enter appointment:\n");
    return_val = fgets(line, MAX_CHAR, stream);
    if (!return_val) {
      if (feof(stream)) {
        printf("Received EOF.\n");
        return;
      } else {
        fprintf(stderr, "IO error, existing program.\n");
        return;
      }
    }
    HandleInput(line);
  }
}


x86 assembly (clang, -O0):
<inputLoop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xff,-0xc(%rbp)
mov    %rsp,%rax
mov    %rax,-0x18(%rbp)
jmp    1172 <inputLoop+0x22>
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdx
lea    -0x130(%rbp),%rdi
mov    $0xff,%esi
call   1050 <fgets@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ee <inputLoop+0x9e>
mov    -0x8(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%rax
je     11cd <inputLoop+0x7d>
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x24(%rbp)
jmp    11ff <inputLoop+0xaf>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x24(%rbp)
jmp    11ff <inputLoop+0xaf>
lea    -0x130(%rbp),%rdi
call   1030 <HandleInput@plt>
jmp    116d <inputLoop+0x1d>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inputLoop>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%r14
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
mov    $0xff,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11b5 <inputLoop+0x65>
mov    %rsp,%rbx
lea    0xe93(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <HandleInput@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    1190 <inputLoop+0x40>
mov    %r14,%rdi
call   1070 <feof@plt>
test   %rax,%rax
je     11d0 <inputLoop+0x80>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
jmp    11e5 <inputLoop+0x95>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe20(%rip),%rsi
call   1060 <fprintf@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Please enter appointment:\0A\00"
@.str.1 = [15 x i8] c"Received EOF.\0A\00"
@stderr = global i32 0
@.str.2 = [29 x i8] c"IO error, existing program.\0A\00"
define void @inputLoop(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i32* %0, i32** %2
store i32 255, i32* %3
%7 = call i8* @llvm.stacksave()
store i8* %7, i8** %4
%8 = alloca i8, i64 255
br label %9
9: ; preds = %25, %1
br label %10
10: ; preds = %9
%11 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%12 = load i32*, i32** %2
%13 = call i8* @fgets(i8* %8, i32 255, i32* %12)
store i8* %13, i8** %5
%14 = load i8*, i8** %5
%15 = icmp ne i8* %14, null
br i1 %15, label %25, label %16
16: ; preds = %10
%17 = load i32*, i32** %2
%18 = call i64 @feof(i32* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %6
br label %27
22: ; preds = %16
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %6
br label %27
25: ; preds = %10
%26 = call i32 @HandleInput(i8* %8)
br label %9
27: ; preds = %22, %20
%28 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str.2 = [29 x i8] c"IO error, existing program.\0A\00"
@str = [26 x i8] c"Please enter appointment:\00"
@str.3 = [14 x i8] c"Received EOF.\00"
define void @inputLoop(i32* nocapture %0) {
%2 = alloca [255 x i8]
%3 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%5 = call i8* @fgets(i8* %3, i32 255, i32* %0)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %15
7: ; preds = %15, %1
%8 = call i64 @feof(i32* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.3, i64 0, i64 0))
br label %20
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %20
15: ; preds = %1, %15
%16 = call i32 @HandleInput(i8* %3)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%18 = call i8* @fgets(i8* %3, i32 255, i32* %0)
%19 = icmp eq i8* %18, null
br i1 %19, label %7, label %15
20: ; preds = %12, %10
ret void
}