#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 */

/* Variables and functions */
int /*<<< orphan*/ clearerr(int /*<<< orphan*/);
scalar_t__ feof(int /*<<< orphan*/);
scalar_t__ ferror(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
int test_stdin(char *fullCommand) {
  if (feof(stdin)) {
    strcpy(fullCommand, "exit");
  } else if (ferror(stdin)) {
    clearerr(stdin);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<test_stdin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
call   1050 <feof@plt>
cmp    $0x0,%rax
je     1179 <test_stdin+0x39>
mov    -0x10(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11b0 <test_stdin+0x70>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     11ab <test_stdin+0x6b>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
call   1060 <clearerr@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <test_stdin+0x77>
jmp    11b0 <test_stdin+0x70>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_stdin>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e9a(%rip),%r14
mov    (%r14),%edi
call   1050 <feof@plt>
test   %rax,%rax
je     1171 <test_stdin+0x31>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    $0x1,%eax
jmp    1188 <test_stdin+0x48>
mov    (%r14),%edi
call   1040 <ferror@plt>
test   %rax,%rax
je     116a <test_stdin+0x2a>
mov    (%r14),%edi
call   1060 <clearerr@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [5 x i8] c"exit\00"
define i32 @test_stdin(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i32, i32* @stdin
%5 = call i64 @feof(i32 %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %18
10: ; preds = %1
%11 = load i32, i32* @stdin
%12 = call i64 @ferror(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* @stdin
%16 = call i32 @clearerr(i32 %15)
store i32 0, i32* %2
br label %19
17: ; preds = %10
br label %18
18: ; preds = %17, %7
store i32 1, i32* %2
br label %19
19: ; preds = %18, %14
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [5 x i8] c"exit\00"
define i32 @test_stdin(i8* %0) {
%2 = load i32, i32* @stdin
%3 = tail call i64 @feof(i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %14
7: ; preds = %1
%8 = load i32, i32* @stdin
%9 = tail call i64 @ferror(i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = load i32, i32* @stdin
%13 = tail call i32 @clearerr(i32 %12)
br label %14
14: ; preds = %5, %7, %11
%15 = phi i32 [ 0, %11 ], [ 1, %7 ], [ 1, %5 ]
ret i32 %15
}