#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 */
size_t fwrite(void *, size_t, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ invertsmp(void *, size_t, size_t);
size_t fwritesmp(void *buf, size_t ss, size_t count, FILE *stream, int neg,
                 void *outbuf) {
  size_t rd;
  if (neg) {
    if (outbuf != NULL) {
      invertsmp(outbuf, ss, count);
      rd = fwrite(outbuf, ss, count, stream);
    } else {
      invertsmp(buf, ss, count);
      rd = fwrite(buf, ss, count, stream);
    }
  } else
    rd = fwrite(buf, ss, count, stream);
  return rd;
}


x86 assembly (clang, -O0):
<fwritesmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11b3 <fwritesmp+0x93>
cmpq   $0x0,-0x30(%rbp)
je     1184 <fwritesmp+0x64>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <invertsmp@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <fwrite@plt>
mov    %rax,-0x38(%rbp)
jmp    11ae <fwritesmp+0x8e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <invertsmp@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <fwrite@plt>
mov    %rax,-0x38(%rbp)
jmp    11cc <fwritesmp+0xac>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <fwrite@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fwritesmp>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
test   %r8d,%r8d
je     1163 <fwritesmp+0x43>
mov    %r9,%rbx
test   %r9,%r9
je     1155 <fwritesmp+0x35>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1030 <invertsmp@plt>
mov    %rbx,%rdi
jmp    1166 <fwritesmp+0x46>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1030 <invertsmp@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <fwrite@plt>

LLVM IR (-O0):
define i64 @fwritesmp(i8* %0, i64 %1, i64 %2, i32* %3, i32 %4, i8* %5) {
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
store i8* %0, i8** %7
store i64 %1, i64* %8
store i64 %2, i64* %9
store i32* %3, i32** %10
store i32 %4, i32* %11
store i8* %5, i8** %12
%14 = load i32, i32* %11
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %40
16: ; preds = %6
%17 = load i8*, i8** %12
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = load i8*, i8** %12
%21 = load i64, i64* %8
%22 = load i64, i64* %9
%23 = call i32 @invertsmp(i8* %20, i64 %21, i64 %22)
%24 = load i8*, i8** %12
%25 = load i64, i64* %8
%26 = load i64, i64* %9
%27 = load i32*, i32** %10
%28 = call i64 @fwrite(i8* %24, i64 %25, i64 %26, i32* %27)
store i64 %28, i64* %13
br label %39
29: ; preds = %16
%30 = load i8*, i8** %7
%31 = load i64, i64* %8
%32 = load i64, i64* %9
%33 = call i32 @invertsmp(i8* %30, i64 %31, i64 %32)
%34 = load i8*, i8** %7
%35 = load i64, i64* %8
%36 = load i64, i64* %9
%37 = load i32*, i32** %10
%38 = call i64 @fwrite(i8* %34, i64 %35, i64 %36, i32* %37)
store i64 %38, i64* %13
br label %39
39: ; preds = %29, %19
br label %46
40: ; preds = %6
%41 = load i8*, i8** %7
%42 = load i64, i64* %8
%43 = load i64, i64* %9
%44 = load i32*, i32** %10
%45 = call i64 @fwrite(i8* %41, i64 %42, i64 %43, i32* %44)
store i64 %45, i64* %13
br label %46
46: ; preds = %40, %39
%47 = load i64, i64* %13
ret i64 %47
}

LLVM IR (-O2):
define i64 @fwritesmp(i8* %0, i64 %1, i64 %2, i32* nocapture %3, i32 %4, i8* %5) {
%7 = icmp eq i32 %4, 0
br i1 %7, label %16, label %8
8: ; preds = %6
%9 = icmp eq i8* %5, null
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = tail call i32 @invertsmp(i8* %5, i64 %1, i64 %2)
%12 = tail call i64 @fwrite(i8* %5, i64 %1, i64 %2, i32* %3)
br label %18
13: ; preds = %8
%14 = tail call i32 @invertsmp(i8* %0, i64 %1, i64 %2)
%15 = tail call i64 @fwrite(i8* %0, i64 %1, i64 %2, i32* %3)
br label %18
16: ; preds = %6
%17 = tail call i64 @fwrite(i8* %0, i64 %1, i64 %2, i32* %3)
br label %18
18: ; preds = %10, %13, %16
%19 = phi i64 [ %12, %10 ], [ %15, %13 ], [ %17, %16 ]
ret i64 %19
}