#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;
int 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
sub    $0x10,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
call   1040 <fileno@plt>
mov    %eax,%edi
call   1030 <isatty@plt>
cmp    $0x0,%eax
jne    119e <gdb_unbuffer_output+0x6e>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
mov    0x2e7a(%rip),%rax
mov    (%rax),%edx
mov    0x2e59(%rip),%rax
mov    (%rax),%ecx
xor    %eax,%eax
mov    %eax,%esi
call   1050 <setvbuf@plt>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
mov    0x2e56(%rip),%rax
mov    (%rax),%edx
mov    0x2e35(%rip),%rax
mov    (%rax),%ecx
xor    %eax,%eax
mov    %eax,%esi
call   1050 <setvbuf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
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
jne    1185 <gdb_unbuffer_output+0x55>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    0x2e83(%rip),%r14
mov    (%r14),%edx
mov    0x2e61(%rip),%rbx
mov    (%rbx),%ecx
xor    %esi,%esi
call   1050 <setvbuf@plt>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%edx
mov    (%rbx),%ecx
xor    %esi,%esi
call   1050 <setvbuf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
@_IONBF = global i32 0
@BUFSIZ = global i32 0
@stderr = global i32 0
define i32 @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 i32 undef
}