#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) {
  if (n == 0)
    return NULL;
  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)
cmpl   $0x0,-0xc(%rbp)
jne    114a <nlopt_new_rescaled+0x2a>
movq   $0x0,-0x8(%rbp)
jmp    1190 <nlopt_new_rescaled+0x70>
mov    -0xc(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1174 <nlopt_new_rescaled+0x54>
movq   $0x0,-0x8(%rbp)
jmp    1190 <nlopt_new_rescaled+0x70>
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
test   %edi,%edi
je     115a <nlopt_new_rescaled+0x3a>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebx
lea    0x0(,%rbx,8),%edi
call   1030 <malloc@plt>
test   %rax,%rax
je     115a <nlopt_new_rescaled+0x3a>
mov    %rax,%r12
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %rax,%rcx
call   1040 <nlopt_rescale@plt>
jmp    115d <nlopt_new_rescaled+0x3d>
xor    %r12d,%r12d
mov    %r12,%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 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %3
store double* null, double** %4
br label %29
12: ; preds = %3
%13 = load i32, i32* %5
%14 = zext i32 %13 to i64
%15 = mul i64 8, %14
%16 = trunc i64 %15 to i32
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to double*
store double* %18, double** %8
%19 = load double*, double** %8
%20 = icmp ne double* %19, null
br i1 %20, label %22, label %21
21: ; preds = %12
store double* null, double** %4
br label %29
22: ; preds = %12
%23 = load i32, i32* %5
%24 = load double*, double** %6
%25 = load double*, double** %7
%26 = load double*, double** %8
%27 = call i32 @nlopt_rescale(i32 %23, double* %24, double* %25, double* %26)
%28 = load double*, double** %8
store double* %28, double** %4
br label %29
29: ; preds = %22, %21, %11
%30 = load double*, double** %4
ret double* %30
}

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