#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ dv_error(char *);
scalar_t__ errno;
scalar_t__ fputc(int, int /*<<< orphan*/ *);
void dv_fputc(int c, FILE *stream) {
  if (errno) {
    dv_error("");
  }
  if (fputc(c, stream) == EOF) {
    dv_error("Failed to write to file.");
  }
}


x86 assembly (clang, -O0):
<dv_fputc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea2(%rip),%rax
cmpq   $0x0,(%rax)
je     114c <dv_fputc+0x2c>
lea    0xed1(%rip),%rdi
call   1040 <dv_error@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <fputc@plt>
mov    0x2e89(%rip),%rcx
cmp    (%rcx),%rax
jne    1174 <dv_fputc+0x54>
lea    0xe91(%rip),%rdi
call   1040 <dv_error@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dv_fputc>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2ea9(%rip),%rax
cmpq   $0x0,(%rax)
je     1141 <dv_fputc+0x21>
lea    0xedc(%rip),%rdi
call   1040 <dv_error@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    0x2e96(%rip),%rcx
cmp    (%rcx),%rax
jne    1169 <dv_fputc+0x49>
lea    0xea2(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <dv_error@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i64 0
@.str = [1 x i8] zeroinitializer
@EOF = global i64 0
@.str.1 = [25 x i8] c"Failed to write to file.\00"
define void @dv_fputc(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
store i32 %0, i32* %3
store i32* %1, i32** %4
%5 = load i64, i64* @errno
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 @dv_error(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %2
%10 = load i32, i32* %3
%11 = load i32*, i32** %4
%12 = call i64 @fputc(i32 %10, i32* %11)
%13 = load i64, i64* @EOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 @dv_error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %9
ret void
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [1 x i8] zeroinitializer
@EOF = global i64 0
@.str.1 = [25 x i8] c"Failed to write to file.\00"
define void @dv_fputc(i32 %0, i32* nocapture %1) {
%3 = load i64, i64* @errno
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @dv_error(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %2
%8 = tail call i64 @fputc(i32 %0, i32* %1)
%9 = load i64, i64* @EOF
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @dv_error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %7
ret void
}