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

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ mfd_assert_size(int, int);
int /*<<< orphan*/ printf(char *);
int pwrite(int, char *, int, int /*<<< orphan*/);
void mfd_assert_grow_write(int fd) {
  static char buf[8192 * 8];
  ssize_t l;
  l = pwrite(fd, buf, sizeof(buf), 0);
  if (l != sizeof(buf)) {
    printf("pwrite() failed: %m\n");
    abort();
  }
  mfd_assert_size(fd, 8192 * 8);
}


x86 assembly (clang, -O0):
<mfd_assert_grow_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    0x2efb(%rip),%rsi
mov    $0x10000,%edx
xor    %ecx,%ecx
call   1050 <pwrite@plt>
mov    %eax,-0x8(%rbp)
movslq -0x8(%rbp),%rax
cmp    $0x10000,%rax
je     1187 <mfd_assert_grow_write+0x47>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%edi
mov    $0x10000,%esi
call   1060 <mfd_assert_size@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mfd_assert_grow_write>:
push   %rbx
mov    %edi,%ebx
lea    0x2f06(%rip),%rsi
mov    $0x10000,%edx
xor    %ecx,%ecx
call   1050 <pwrite@plt>
cmp    $0x10000,%eax
jne    116a <mfd_assert_grow_write+0x2a>
mov    %ebx,%edi
mov    $0x10000,%esi
pop    %rbx
jmp    1060 <mfd_assert_size@plt>
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@mfd_assert_grow_write.buf = internal global [65536 x i8] zeroinitializer
@.str = [21 x i8] c"pwrite() failed: %m\0A\00"
define void @mfd_assert_grow_write(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @pwrite(i32 %4, i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @mfd_assert_grow_write.buf, i64 0, i64 0), i32 65536, i32 0)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = icmp ne i64 %7, 65536
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (...) @abort()
unreachable
12: ; preds = %1
%13 = load i32, i32* %2
%14 = call i32 @mfd_assert_size(i32 %13, i32 65536)
ret void
}

LLVM IR (-O2):
@mfd_assert_grow_write.buf = internal global [65536 x i8] zeroinitializer
@.str = [21 x i8] c"pwrite() failed: %m\0A\00"
define void @mfd_assert_grow_write(i32 %0) {
%2 = tail call i32 @pwrite(i32 %0, i8* getelementptr inbounds ([65536 x i8], [65536 x i8]* @mfd_assert_grow_write.buf, i64 0, i64 0), i32 65536, i32 0)
%3 = icmp eq i32 %2, 65536
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (...) @abort()
unreachable
7: ; preds = %1
%8 = tail call i32 @mfd_assert_size(i32 %0, i32 65536)
ret void
}