#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*/ BUFSIZ;
int /*<<< orphan*/ _IONBF;
int /*<<< orphan*/ fileno(int /*<<< orphan*/);
int /*<<< orphan*/ isatty(int /*<<< orphan*/);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
void gdb_unbuffer_output(void) {
  if (!isatty(fileno(stdin))) {
    setvbuf(stdout, NULL, _IONBF, BUFSIZ);
    setvbuf(stderr, NULL, _IONBF, BUFSIZ);
  }
}


x86 assembly (clang, -O0):
<gdb_unbuffer_output>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ead(%rip),%rax
mov    (%rax),%edi
call   1040 <fileno@plt>
mov    %eax,%edi
call   1030 <isatty@plt>
cmp    $0x0,%eax
jne    119a <gdb_unbuffer_output+0x6a>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
mov    0x2e7e(%rip),%rax
mov    (%rax),%edx
mov    0x2e5d(%rip),%rax
mov    (%rax),%ecx
xor    %eax,%eax
mov    %eax,%esi
call   1050 <setvbuf@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
mov    0x2e5a(%rip),%rax
mov    (%rax),%edx
mov    0x2e39(%rip),%rax
mov    (%rax),%ecx
xor    %eax,%eax
mov    %eax,%esi
call   1050 <setvbuf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<gdb_unbuffer_output>:
push   %r14
push   %rbx
push   %rax
mov    0x2ead(%rip),%rax
mov    (%rax),%edi
call   1040 <fileno@plt>
mov    %eax,%edi
call   1030 <isatty@plt>
test   %eax,%eax
je     1155 <gdb_unbuffer_output+0x25>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
mov    0x2e7b(%rip),%r14
mov    (%r14),%edx
mov    0x2e59(%rip),%rbx
mov    (%rbx),%ecx
xor    %esi,%esi
call   1050 <setvbuf@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%edx
mov    (%rbx),%ecx
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <setvbuf@plt>

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
@_IONBF = global i32 0
@BUFSIZ = global i32 0
@stderr = global i32 0
define void @gdb_unbuffer_output() {
%1 = load i32, i32* @stdin
%2 = call i32 @fileno(i32 %1)
%3 = call i32 @isatty(i32 %2)
%4 = icmp ne i32 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %0
%6 = load i32, i32* @stdout
%7 = load i32, i32* @_IONBF
%8 = load i32, i32* @BUFSIZ
%9 = call i32 @setvbuf(i32 %6, i32* null, i32 %7, i32 %8)
%10 = load i32, i32* @stderr
%11 = load i32, i32* @_IONBF
%12 = load i32, i32* @BUFSIZ
%13 = call i32 @setvbuf(i32 %10, i32* null, i32 %11, i32 %12)
br label %14
14: ; preds = %5, %0
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
@_IONBF = global i32 0
@BUFSIZ = global i32 0
@stderr = global i32 0
define void @gdb_unbuffer_output() {
%1 = load i32, i32* @stdin
%2 = tail call i32 @fileno(i32 %1)
%3 = tail call i32 @isatty(i32 %2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %14
5: ; preds = %0
%6 = load i32, i32* @stdout
%7 = load i32, i32* @_IONBF
%8 = load i32, i32* @BUFSIZ
%9 = tail call i32 @setvbuf(i32 %6, i32* null, i32 %7, i32 %8)
%10 = load i32, i32* @stderr
%11 = load i32, i32* @_IONBF
%12 = load i32, i32* @BUFSIZ
%13 = tail call i32 @setvbuf(i32 %10, i32* null, i32 %11, i32 %12)
br label %14
14: ; preds = %5, %0
ret void
}