#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 */
scalar_t__ EPIPE;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
scalar_t__ close_stream(int /*<<< orphan*/);
scalar_t__ errno;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ warn(char *);
int /*<<< orphan*/ warnx(char *);
void close_stdout(void) {
  if (close_stream(stdout) != 0 && !(errno == EPIPE)) {
    if (errno)
      warn("write error");
    else
      warnx("write error");
    _exit(EXIT_FAILURE);
  }
  if (close_stream(stderr) != 0)
    _exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<close_stdout>:
push   %rbp
mov    %rsp,%rbp
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
call   1060 <close_stream@plt>
cmp    $0x0,%rax
je     11b2 <close_stdout+0x72>
mov    0x2e6d(%rip),%rax
mov    (%rax),%rax
mov    0x2e6b(%rip),%rcx
cmp    (%rcx),%rax
je     11b2 <close_stdout+0x72>
mov    0x2e53(%rip),%rax
cmpq   $0x0,(%rax)
je     1198 <close_stdout+0x58>
lea    0xe72(%rip),%rdi
call   1040 <warn@plt>
jmp    11a4 <close_stdout+0x64>
lea    0xe61(%rip),%rdi
call   1050 <warnx@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
call   1060 <close_stream@plt>
cmp    $0x0,%rax
je     11d8 <close_stdout+0x98>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<close_stdout>:
push   %rax
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
call   1060 <close_stream@plt>
test   %rax,%rax
je     116a <close_stdout+0x2a>
mov    0x2e75(%rip),%rax
mov    (%rax),%rax
mov    0x2e73(%rip),%rcx
cmp    (%rcx),%rax
jne    117f <close_stdout+0x3f>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
call   1060 <close_stream@plt>
test   %rax,%rax
jne    1197 <close_stdout+0x57>
pop    %rax
ret
lea    0xe7a(%rip),%rdi
test   %rax,%rax
jne    1192 <close_stdout+0x52>
call   1050 <warnx@plt>
jmp    1197 <close_stdout+0x57>
call   1040 <warn@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@errno = global i64 0
@EPIPE = global i64 0
@.str = [12 x i8] c"write error\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
define void @close_stdout() {
%1 = load i32, i32* @stdout
%2 = call i64 @close_stream(i32 %1)
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %18
4: ; preds = %0
%5 = load i64, i64* @errno
%6 = load i64, i64* @EPIPE
%7 = icmp eq i64 %5, %6
br i1 %7, label %18, label %8
8: ; preds = %4
%9 = load i64, i64* @errno
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 @warn(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %15
13: ; preds = %8
%14 = call i32 @warnx(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %11
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @_exit(i32 %16)
unreachable
18: ; preds = %4, %0
%19 = load i32, i32* @stderr
%20 = call i64 @close_stream(i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @_exit(i32 %23)
unreachable
25: ; preds = %18
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@errno = global i64 0
@EPIPE = global i64 0
@.str = [12 x i8] c"write error\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
define void @close_stdout() {
%1 = load i32, i32* @stdout
%2 = tail call i64 @close_stream(i32 %1)
%3 = icmp eq i64 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %0
%5 = load i64, i64* @errno
%6 = load i64, i64* @EPIPE
%7 = icmp eq i64 %5, %6
br i1 %7, label %17, label %8
8: ; preds = %4
%9 = icmp eq i64 %5, 0
br i1 %9, label %12, label %10
10: ; preds = %8
%11 = tail call i32 @warn(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %14
12: ; preds = %8
%13 = tail call i32 @warnx(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %10
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @_exit(i32 %15)
unreachable
17: ; preds = %4, %0
%18 = load i32, i32* @stderr
%19 = tail call i64 @close_stream(i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @_exit(i32 %22)
unreachable
24: ; preds = %17
ret void
}