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

/* Variables and functions */
int /*<<< orphan*/ fwrite(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
int output_zeros(FILE *dest, int amount) {
  if (amount & 3 != 0) {
    return -1;
  }
  if (amount <= 0) {
    return 0;
  }
  int i;
  for (i = 0; i < (amount >> 2); i++) {
    uint32_t byte = 0;
    fwrite(&byte, 1, 4, dest);
  }
  return 0;
}


x86 assembly (clang, -O0):
<output_zeros>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     113a <output_zeros+0x2a>
movl   $0xffffffff,-0x4(%rbp)
jmp    119b <output_zeros+0x8b>
cmpl   $0x0,-0x14(%rbp)
jg     1150 <output_zeros+0x40>
movl   $0x0,-0x4(%rbp)
jmp    119b <output_zeros+0x8b>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sar    $0x2,%ecx
cmp    %ecx,%eax
jge    1194 <output_zeros+0x84>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x1c(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fwrite@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1157 <output_zeros+0x47>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_zeros>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    $0xffffffff,%r14d
test   $0x1,%bpl
jne    1162 <output_zeros+0x52>
xor    %r14d,%r14d
cmp    $0x4,%ebp
jl     1162 <output_zeros+0x52>
mov    %rdi,%rbx
shr    $0x2,%ebp
lea    0x4(%rsp),%r15
nopl   0x0(%rax,%rax,1)
movl   $0x0,0x4(%rsp)
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fwrite@plt>
add    $0xffffffff,%ebp
jne    1140 <output_zeros+0x30>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @output_zeros(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = and i32 %8, 1
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %29
12: ; preds = %2
%13 = load i32, i32* %5
%14 = icmp sle i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 0, i32* %3
br label %29
16: ; preds = %12
store i32 0, i32* %6
br label %17
17: ; preds = %25, %16
%18 = load i32, i32* %6
%19 = load i32, i32* %5
%20 = ashr i32 %19, 2
%21 = icmp slt i32 %18, %20
br i1 %21, label %22, label %28
22: ; preds = %17
store i32 0, i32* %7
%23 = load i32*, i32** %4
%24 = call i32 @fwrite(i32* %7, i32 1, i32 4, i32* %23)
br label %25
25: ; preds = %22
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %17
28: ; preds = %17
store i32 0, i32* %3
br label %29
29: ; preds = %28, %15, %11
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @output_zeros(i32* nocapture %0, i32 %1) {
%3 = alloca i32
%4 = and i32 %1, 1
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = icmp sgt i32 %1, 3
br i1 %7, label %8, label %16
8: ; preds = %6
%9 = lshr i32 %1, 2
%10 = bitcast i32* %3 to i8*
br label %11
11: ; preds = %8, %11
%12 = phi i32 [ 0, %8 ], [ %14, %11 ]
store i32 0, i32* %3
%13 = call i32 @fwrite(i32* %3, i32 1, i32 4, i32* %0)
%14 = add nuw nsw i32 %12, 1
%15 = icmp eq i32 %14, %9
br i1 %15, label %16, label %11
16: ; preds = %11, %6, %2
%17 = phi i32 [ -1, %2 ], [ 0, %6 ], [ 0, %11 ]
ret i32 %17
}