#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int /*<<< orphan*/ _flags;
};
struct TYPE_3__ {
  int /*<<< orphan*/ _flags;
};

/* Variables and functions */
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ _IOFBF;
int /*<<< orphan*/ _IOLBF;
scalar_t__ isatty(int /*<<< orphan*/);
TYPE_2__ *stdin;
TYPE_1__ *stdout;
void __set_std_buffering(void) {
  stdin->_flags |= (isatty(STDIN_FILENO)) ? _IOLBF : _IOFBF;
  stdout->_flags |= (isatty(STDOUT_FILENO)) ? _IOLBF : _IOFBF;
}


x86 assembly (clang, -O0):
<__set_std_buffering>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
call   1030 <isatty@plt>
cmp    $0x0,%rax
je     1141 <__set_std_buffering+0x31>
mov    0x2e99(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    114d <__set_std_buffering+0x3d>
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
mov    0x2e89(%rip),%rax
mov    (%rax),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
call   1030 <isatty@plt>
cmp    $0x0,%rax
je     1187 <__set_std_buffering+0x77>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
jmp    1193 <__set_std_buffering+0x83>
mov    0x2e2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
mov    0x2e2b(%rip),%rax
mov    (%rax),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__set_std_buffering>:
push   %r14
push   %rbx
push   %rax
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
call   1030 <isatty@plt>
test   %rax,%rax
mov    0x2ea4(%rip),%rbx
mov    0x2e85(%rip),%r14
mov    %rbx,%rax
cmove  %r14,%rax
mov    (%rax),%eax
mov    0x2e9d(%rip),%rcx
mov    (%rcx),%rcx
or     %eax,(%rcx)
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
call   1030 <isatty@plt>
test   %rax,%rax
cmove  %r14,%rbx
mov    (%rbx),%eax
mov    0x2e62(%rip),%rcx
mov    (%rcx),%rcx
or     %eax,(%rcx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32 }
%struct.TYPE_3__ = type { i32 }
@STDIN_FILENO = global i32 0
@_IOLBF = global i32 0
@_IOFBF = global i32 0
@stdin = global %struct.TYPE_4__* null
@STDOUT_FILENO = global i32 0
@stdout = global %struct.TYPE_3__* null
define void @__set_std_buffering() {
%1 = load i32, i32* @STDIN_FILENO
%2 = call i64 @isatty(i32 %1)
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = load i32, i32* @_IOLBF
br label %8
6: ; preds = %0
%7 = load i32, i32* @_IOFBF
br label %8
8: ; preds = %6, %4
%9 = phi i32 [ %5, %4 ], [ %7, %6 ]
%10 = load %struct.TYPE_4__*, %struct.TYPE_4__** @stdin
%11 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = or i32 %12, %9
store i32 %13, i32* %11
%14 = load i32, i32* @STDOUT_FILENO
%15 = call i64 @isatty(i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %8
%18 = load i32, i32* @_IOLBF
br label %21
19: ; preds = %8
%20 = load i32, i32* @_IOFBF
br label %21
21: ; preds = %19, %17
%22 = phi i32 [ %18, %17 ], [ %20, %19 ]
%23 = load %struct.TYPE_3__*, %struct.TYPE_3__** @stdout
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i32 0, i32 0
%25 = load i32, i32* %24
%26 = or i32 %25, %22
store i32 %26, i32* %24
ret void
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32 }
%struct.TYPE_3__ = type { i32 }
@STDIN_FILENO = global i32 0
@_IOLBF = global i32 0
@_IOFBF = global i32 0
@stdin = global %struct.TYPE_4__* null
@STDOUT_FILENO = global i32 0
@stdout = global %struct.TYPE_3__* null
define void @__set_std_buffering() {
%1 = load i32, i32* @STDIN_FILENO
%2 = tail call i64 @isatty(i32 %1)
%3 = icmp eq i64 %2, 0
%4 = load i32, i32* @_IOLBF
%5 = load i32, i32* @_IOFBF
%6 = select i1 %3, i32 %5, i32 %4
%7 = load %struct.TYPE_4__*, %struct.TYPE_4__** @stdin
%8 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i64 0, i32 0
%9 = load i32, i32* %8
%10 = or i32 %9, %6
store i32 %10, i32* %8
%11 = load i32, i32* @STDOUT_FILENO
%12 = tail call i64 @isatty(i32 %11)
%13 = icmp eq i64 %12, 0
%14 = load i32, i32* @_IOLBF
%15 = load i32, i32* @_IOFBF
%16 = select i1 %13, i32 %15, i32 %14
%17 = load %struct.TYPE_3__*, %struct.TYPE_3__** @stdout
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i64 0, i32 0
%19 = load i32, i32* %18
%20 = or i32 %19, %16
store i32 %20, i32* %18
ret void
}