#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*/ mpfr_t;

/* Variables and functions */
int /*<<< orphan*/ mpfr_get_default_rounding_mode();
scalar_t__ mpfr_set_si(int /*<<< orphan*/, long, int /*<<< orphan*/);
int fillArrayLinearly(mpfr_t *array, const size_t size) {
  int err = 0;
  for (long int i = 0; i < size; ++i) {
    err += mpfr_set_si(array[i], i + 1, mpfr_get_default_rounding_mode());
  }
  return err;
}


x86 assembly (clang, -O0):
<fillArrayLinearly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    119a <fillArrayLinearly+0x7a>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1030 <mpfr_get_default_rounding_mode@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1040 <mpfr_set_si@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113f <fillArrayLinearly+0x1f>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fillArrayLinearly>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %rsi,%rsi
je     116f <fillArrayLinearly+0x4f>
mov    %rsi,%r15
mov    %rdi,%r14
neg    %r15
mov    $0x1,%ebx
xor    %ebp,%ebp
nopl   (%rax)
mov    -0x4(%r14,%rbx,4),%r12d
xor    %eax,%eax
call   1030 <mpfr_get_default_rounding_mode@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <mpfr_set_si@plt>
add    %eax,%ebp
lea    (%r15,%rbx,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    $0x1,%rax
jne    1140 <fillArrayLinearly+0x20>
jmp    1171 <fillArrayLinearly+0x51>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @fillArrayLinearly(i32* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %6, %2
%5 = phi i32 [ 0, %2 ], [ %15, %6 ]
ret i32 %5
6: ; preds = %2, %6
%7 = phi i64 [ %11, %6 ], [ 0, %2 ]
%8 = phi i32 [ %15, %6 ], [ 0, %2 ]
%9 = getelementptr inbounds i32, i32* %0, i64 %7
%10 = load i32, i32* %9
%11 = add nuw i64 %7, 1
%12 = tail call i32 (...) @mpfr_get_default_rounding_mode()
%13 = tail call i64 @mpfr_set_si(i32 %10, i64 %11, i32 %12)
%14 = trunc i64 %13 to i32
%15 = add i32 %8, %14
%16 = icmp eq i64 %11, %1
br i1 %16, label %4, label %6
}