#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ nlopt_rescale(unsigned int, double const *, double const *,
                                 double *);
double *nlopt_new_rescaled(unsigned n, const double *s, const double *x) {
  double *xs = (double *)malloc(sizeof(double) * n);
  if (!xs)
    return NULL;
  nlopt_rescale(n, s, x, xs);
  return xs;
}


x86 assembly (clang, -O0):
<nlopt_new_rescaled>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    115d <nlopt_new_rescaled+0x3d>
movq   $0x0,-0x8(%rbp)
jmp    1179 <nlopt_new_rescaled+0x59>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1040 <nlopt_rescale@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nlopt_new_rescaled>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r12d
lea    0x0(,%r12,8),%edi
call   1030 <malloc@plt>
test   %rax,%rax
je     1159 <nlopt_new_rescaled+0x39>
mov    %rax,%rbx
mov    %r12d,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %rax,%rcx
call   1040 <nlopt_rescale@plt>
jmp    115b <nlopt_new_rescaled+0x3b>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double* @nlopt_new_rescaled(i32 %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
%9 = load i32, i32* %5
%10 = zext i32 %9 to i64
%11 = mul i64 8, %10
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to double*
store double* %14, double** %8
%15 = load double*, double** %8
%16 = icmp ne double* %15, null
br i1 %16, label %18, label %17
17: ; preds = %3
store double* null, double** %4
br label %25
18: ; preds = %3
%19 = load i32, i32* %5
%20 = load double*, double** %6
%21 = load double*, double** %7
%22 = load double*, double** %8
%23 = call i32 @nlopt_rescale(i32 %19, double* %20, double* %21, double* %22)
%24 = load double*, double** %8
store double* %24, double** %4
br label %25
25: ; preds = %18, %17
%26 = load double*, double** %4
ret double* %26
}

LLVM IR (-O2):
define double* @nlopt_new_rescaled(i32 %0, double* %1, double* %2) {
%4 = shl i32 %0, 3
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to double*
%7 = icmp eq i64 %5, 0
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = tail call i32 @nlopt_rescale(i32 %0, double* %1, double* %2, double* %6)
br label %10
10: ; preds = %3, %8
%11 = phi double* [ %6, %8 ], [ null, %3 ]
ret double* %11
}