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

/* Variables and functions */
double frexp(double, int *);
void R_frexp(double v[], int *nv, double mantissa[], int exp[]) {
  int i, tmpi;
  for (i = 0; i < *nv; i++) {
    mantissa[i] = frexp(v[i], &tmpi);
    exp[i] = tmpi;
  }
}


x86 assembly (clang, -O0):
<R_frexp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    117d <R_frexp+0x6d>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    -0x28(%rbp),%rdi
call   1030 <frexp@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112f <R_frexp+0x1f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<R_frexp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmpl   $0x0,(%rsi)
jle    1168 <R_frexp+0x58>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r12
xor    %ebp,%ebp
lea    0x4(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%r12,%rbp,8),%xmm0
mov    %r13,%rdi
call   1030 <frexp@plt>
movsd  %xmm0,(%r15,%rbp,8)
mov    0x4(%rsp),%eax
mov    %eax,(%r14,%rbp,4)
add    $0x1,%rbp
movslq (%rbx),%rax
cmp    %rax,%rbp
jl     1140 <R_frexp+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @R_frexp(double* nocapture %0, i32* nocapture %1, double* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %4, %9
%10 = phi i64 [ %17, %9 ], [ 0, %4 ]
%11 = getelementptr inbounds double, double* %0, i64 %10
%12 = load double, double* %11
%13 = call double @frexp(double %12, i32* %5)
%14 = getelementptr inbounds double, double* %2, i64 %10
store double %13, double* %14
%15 = load i32, i32* %5
%16 = getelementptr inbounds i32, i32* %3, i64 %10
store i32 %15, i32* %16
%17 = add nuw nsw i64 %10, 1
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %9, label %21
21: ; preds = %9, %4
ret void
}