#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 size_t ssize_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ stderr;
size_t write(int, void const *, size_t);
void checked_write(int fd, const void *buf, size_t count) {
  ssize_t rc = write(fd, buf, count);
  do {
    if (!(rc == count)) {
      fprintf(stderr, "FAILED at %s:%d\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Cisco-Talos/pyrebox/refs/heads/master/"
              "qemu/tests/tcg/multiarch/test-mmap.c",
              435);
      exit(EXIT_FAILURE);
    }
  } while (0);
}


x86 assembly (clang, -O0):
<checked_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <write@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     1194 <checked_write+0x64>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
lea    0xe95(%rip),%rdx
mov    $0x1b3,%ecx
call   1040 <fprintf@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    1199 <checked_write+0x69>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checked_write>:
push   %rbx
mov    %rdx,%rbx
call   1030 <write@plt>
cmp    %rbx,%rax
jne    1140 <checked_write+0x10>
pop    %rbx
ret
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
lea    0xeb0(%rip),%rsi
lea    0xeba(%rip),%rdx
mov    $0x1b3,%ecx
call   1040 <fprintf@plt>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [17 x i8] c"FAILED at %s:%d\0A\00"
@.str.1 = [165 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Cisco-Talos/pyrebox/refs/heads/master/qemu/tests/tcg/multiarch/test-mmap.c\00"
@EXIT_FAILURE = global i32 0
define void @checked_write(i32 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i32 %0, i32* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load i32, i32* %4
%9 = load i8*, i8** %5
%10 = load i64, i64* %6
%11 = call i64 @write(i32 %8, i8* %9, i64 %10)
store i64 %11, i64* %7
br label %12
12: ; preds = %3
%13 = load i64, i64* %7
%14 = load i64, i64* %6
%15 = icmp eq i64 %13, %14
br i1 %15, label %21, label %16
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([165 x i8], [165 x i8]* @.str.1, i64 0, i64 0), i32 435)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %12
br label %22
22: ; preds = %21
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [17 x i8] c"FAILED at %s:%d\0A\00"
@.str.1 = [165 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Cisco-Talos/pyrebox/refs/heads/master/qemu/tests/tcg/multiarch/test-mmap.c\00"
@EXIT_FAILURE = global i32 0
define void @checked_write(i32 %0, i8* nocapture %1, i64 %2) {
%4 = tail call i64 @write(i32 %0, i8* %1, i64 %2)
%5 = icmp eq i64 %4, %2
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([165 x i8], [165 x i8]* @.str.1, i64 0, i64 0), i32 435)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %3
ret void
}