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

/* Variables and functions */
int /*<<< orphan*/ fwrite(int *, int, int, int /*<<< orphan*/ *);
int fwrite_file(FILE *f, int *array, int len) {
  int i = 0;
  int n = 0;
  for (i = 0; i < len; i++) {
    n = array[i];
    fwrite(&n, sizeof(n), 1, f);
  }
  return 1;
}


x86 assembly (clang, -O0):
<fwrite_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1177 <fwrite_file+0x67>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rcx
lea    -0x1c(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fwrite@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1138 <fwrite_file+0x28>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fwrite_file>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edx,%edx
jle    1166 <fwrite_file+0x56>
mov    %rsi,%r14
mov    %rdi,%r12
mov    %edx,%r13d
xor    %ebx,%ebx
lea    0xc(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,4),%eax
mov    %eax,0xc(%rsp)
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1030 <fwrite@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1140 <fwrite_file+0x30>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @fwrite_file(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %7
br label %9
9: ; preds = %21, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = load i32*, i32** %5
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = load i32, i32* %17
store i32 %18, i32* %8
%19 = load i32*, i32** %4
%20 = call i32 @fwrite(i32* %8, i32 4, i32 1, i32* %19)
br label %21
21: ; preds = %13
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
br label %9
24: ; preds = %9
ret i32 1
}

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