#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 */
int /*<<< orphan*/ errmsg(char *);
int write(int, char *, int);
int wframe_c(int fd, int frame, int npix, int nrast, char *buff) {
  int nbytes = npix * nrast * sizeof(float);
  int c;
  if ((c = write(fd, buff, nbytes)) != nbytes) {
    errmsg("Error: Writing frame of binary data");
    return (-1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<wframe_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x28(%rbp)
cmp    -0x24(%rbp),%eax
je     117b <wframe_c+0x5b>
lea    0xe96(%rip),%rdi
call   1040 <errmsg@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1182 <wframe_c+0x62>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wframe_c>:
push   %rbx
mov    %r8,%rsi
mov    %edx,%ebx
imul   %ecx,%ebx
shl    $0x2,%ebx
mov    %ebx,%edx
call   1030 <write@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ebx,%ecx
je     114c <wframe_c+0x2c>
lea    0xebe(%rip),%rdi
call   1040 <errmsg@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Error: Writing frame of binary data\00"
define i32 @wframe_c(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i8* %4, i8** %11
%14 = load i32, i32* %9
%15 = load i32, i32* %10
%16 = mul nsw i32 %14, %15
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 4
%19 = trunc i64 %18 to i32
store i32 %19, i32* %12
%20 = load i32, i32* %7
%21 = load i8*, i8** %11
%22 = load i32, i32* %12
%23 = call i32 @write(i32 %20, i8* %21, i32 %22)
store i32 %23, i32* %13
%24 = load i32, i32* %12
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %5
%27 = call i32 @errmsg(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %6
br label %29
28: ; preds = %5
store i32 0, i32* %6
br label %29
29: ; preds = %28, %26
%30 = load i32, i32* %6
ret i32 %30
}

LLVM IR (-O2):
@.str = [36 x i8] c"Error: Writing frame of binary data\00"
define i32 @wframe_c(i32 %0, i32 %1, i32 %2, i32 %3, i8* nocapture %4) {
%6 = shl i32 %2, 2
%7 = mul i32 %6, %3
%8 = tail call i32 @write(i32 %0, i8* %4, i32 %7)
%9 = icmp eq i32 %8, %7
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = tail call i32 @errmsg(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %5, %10
%13 = phi i32 [ -1, %10 ], [ 0, %5 ]
ret i32 %13
}