#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*/ STDIN_FILENO;
int /*<<< orphan*/ error_log(char *);
int input_get(unsigned char **, int /*<<< orphan*/ *);
scalar_t__ isatty(int /*<<< orphan*/);
int input_get_from_pipe(unsigned char **dest) {
  int r;
  if (isatty(STDIN_FILENO)) {
    error_log("Input data from a piped or redirected source is required.");
    return -1;
  }
  r = input_get(dest, NULL);
  if (r < 0) {
    error_log("Could not get input.");
    return -1;
  }
  if (r == 0) {
    error_log("No input provided.");
    return -1;
  }
  return r;
}


x86 assembly (clang, -O0):
<input_get_from_pipe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
call   1030 <isatty@plt>
cmp    $0x0,%rax
je     116c <input_get_from_pipe+0x3c>
lea    0xea5(%rip),%rdi
call   1050 <error_log@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <input_get_from_pipe+0x96>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <input_get@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    119e <input_get_from_pipe+0x6e>
lea    0xead(%rip),%rdi
call   1050 <error_log@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <input_get_from_pipe+0x96>
cmpl   $0x0,-0x14(%rbp)
jne    11c0 <input_get_from_pipe+0x90>
lea    0xea0(%rip),%rdi
call   1050 <error_log@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <input_get_from_pipe+0x96>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input_get_from_pipe>:
push   %rbx
mov    %rdi,%rbx
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
call   1030 <isatty@plt>
test   %rax,%rax
je     115a <input_get_from_pipe+0x2a>
lea    0xeb2(%rip),%rdi
call   1050 <error_log@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <input_get@plt>
test   %eax,%eax
js     1173 <input_get_from_pipe+0x43>
jne    1158 <input_get_from_pipe+0x28>
lea    0xede(%rip),%rdi
jmp    114e <input_get_from_pipe+0x1e>
lea    0xec0(%rip),%rdi
jmp    114e <input_get_from_pipe+0x1e>

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@.str = [58 x i8] c"Input data from a piped or redirected source is required.\00"
@.str.1 = [21 x i8] c"Could not get input.\00"
@.str.2 = [19 x i8] c"No input provided.\00"
define i32 @input_get_from_pipe(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32
store i8** %0, i8*** %3
%5 = load i32, i32* @STDIN_FILENO
%6 = call i64 @isatty(i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @error_log(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %24
10: ; preds = %1
%11 = load i8**, i8*** %3
%12 = call i32 @input_get(i8** %11, i32* null)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 @error_log(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %24
17: ; preds = %10
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @error_log(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %2
br label %24
22: ; preds = %17
%23 = load i32, i32* %4
store i32 %23, i32* %2
br label %24
24: ; preds = %22, %20, %15, %8
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@.str = [58 x i8] c"Input data from a piped or redirected source is required.\00"
@.str.1 = [21 x i8] c"Could not get input.\00"
@.str.2 = [19 x i8] c"No input provided.\00"
define i32 @input_get_from_pipe(i8** %0) {
%2 = load i32, i32* @STDIN_FILENO
%3 = tail call i64 @isatty(i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = tail call i32 @input_get(i8** %0, i32* null)
%7 = icmp slt i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = icmp eq i32 %6, 0
br i1 %9, label %10, label %13
10: ; preds = %8, %5, %1
%11 = phi i8* [ getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), %8 ]
%12 = tail call i32 @error_log(i8* %11)
br label %13
13: ; preds = %10, %8
%14 = phi i32 [ %6, %8 ], [ -1, %10 ]
ret i32 %14
}