#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 */
int /*<<< orphan*/ ivec_fwrite(int /*<<< orphan*/ *, int const *, int);
int ivecs_fwrite(FILE *f, int d, int n, const int *v) {
  int i;
  for (i = 0; i < n; i++) {
    ivec_fwrite(f, v, d);
    v += d;
  }
  return n;
}


x86 assembly (clang, -O0):
<ivecs_fwrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    116c <ivecs_fwrite+0x5c>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <ivec_fwrite@plt>
mov    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112d <ivecs_fwrite+0x1d>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ivecs_fwrite>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
test   %edx,%edx
jle    1156 <ivecs_fwrite+0x46>
mov    %rcx,%rbx
mov    %esi,%r12d
mov    %rdi,%r15
movslq %esi,%r13
shl    $0x2,%r13
mov    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1030 <ivec_fwrite@plt>
add    %r13,%rbx
add    $0xffffffff,%ebp
jne    1140 <ivecs_fwrite+0x30>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @ivecs_fwrite(i32* %0, i32 %1, i32 returned %2, i32* %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %15
6: ; preds = %4
%7 = sext i32 %1 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i32 [ 0, %6 ], [ %13, %8 ]
%10 = phi i32* [ %3, %6 ], [ %12, %8 ]
%11 = tail call i32 @ivec_fwrite(i32* %0, i32* %10, i32 %1)
%12 = getelementptr inbounds i32, i32* %10, i64 %7
%13 = add nuw nsw i32 %9, 1
%14 = icmp eq i32 %13, %2
br i1 %14, label %15, label %8
15: ; preds = %8, %4
ret i32 %2
}