#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 dlansy_(char *, char *, int *, double const *, int *, double *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
double call_dlansy(char norm, char uplo, int n, const double *a, int lda) {
  double res = 0.0;
  double *work = NULL;
  work = (double *)malloc(sizeof(double) * n);
  if (work == NULL) {
    fputs("ERROR: memory allocation (malloc) failed in call_dlansy\n", stderr);
    return res;
  }
  res = dlansy_(&norm, &uplo, &n, a, &lda, work);
  free(work);
  return res;
}


x86 assembly (clang, -O0):
<call_dlansy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %dil,%sil
mov    %sil,-0x9(%rbp)
mov    %al,-0xa(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11b2 <call_dlansy+0x72>
mov    0x2e4b(%rip),%rax
mov    (%rax),%esi
lea    0xe62(%rip),%rdi
call   1040 <fputs@plt>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e7 <call_dlansy+0xa7>
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%r9
lea    -0x9(%rbp),%rdi
lea    -0xa(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x1c(%rbp),%r8
call   1050 <dlansy_@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<call_dlansy>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %dil,0x7(%rsp)
mov    %sil,0x6(%rsp)
mov    %edx,0xc(%rsp)
mov    %r8d,0x8(%rsp)
lea    0x0(,%rdx,8),%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11a6 <call_dlansy+0x66>
mov    %rax,%rbx
lea    0x7(%rsp),%rdi
lea    0x6(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%r8
mov    %r14,%rcx
mov    %rax,%r9
call   1050 <dlansy_@plt>
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
call   1030 <free@plt>
movsd  0x10(%rsp),%xmm0
jmp    11be <call_dlansy+0x7e>
mov    0x2e33(%rip),%rax
mov    (%rax),%esi
lea    0xe4a(%rip),%rdi
call   1040 <fputs@plt>
xorps  %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [57 x i8] c"ERROR: memory allocation (malloc) failed in call_dlansy\0A\00"
@stderr = global i32 0
define double @call_dlansy(i8 signext %0, i8 signext %1, i32 %2, double* %3, i32 %4) {
%6 = alloca double
%7 = alloca i8
%8 = alloca i8
%9 = alloca i32
%10 = alloca double*
%11 = alloca i32
%12 = alloca double
%13 = alloca double*
store i8 %0, i8* %7
store i8 %1, i8* %8
store i32 %2, i32* %9
store double* %3, double** %10
store i32 %4, i32* %11
store double 0.000000e+00, double* %12
store double* null, double** %13
%14 = load i32, i32* %9
%15 = sext i32 %14 to i64
%16 = mul i64 8, %15
%17 = trunc i64 %16 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to double*
store double* %19, double** %13
%20 = load double*, double** %13
%21 = icmp eq double* %20, null
br i1 %21, label %22, label %26
22: ; preds = %5
%23 = load i32, i32* @stderr
%24 = call i32 @fputs(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load double, double* %12
store double %25, double* %6
br label %33
26: ; preds = %5
%27 = load double*, double** %10
%28 = load double*, double** %13
%29 = call double @dlansy_(i8* %7, i8* %8, i32* %9, double* %27, i32* %11, double* %28)
store double %29, double* %12
%30 = load double*, double** %13
%31 = call i32 @free(double* %30)
%32 = load double, double* %12
store double %32, double* %6
br label %33
33: ; preds = %26, %22
%34 = load double, double* %6
ret double %34
}

LLVM IR (-O2):
@.str = [57 x i8] c"ERROR: memory allocation (malloc) failed in call_dlansy\0A\00"
@stderr = global i32 0
define double @call_dlansy(i8 signext %0, i8 signext %1, i32 %2, double* %3, i32 %4) {
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
store i8 %0, i8* %6
store i8 %1, i8* %7
store i32 %2, i32* %8
store i32 %4, i32* %9
%10 = shl i32 %2, 3
%11 = tail call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to double*
%13 = icmp eq i64 %11, 0
br i1 %13, label %14, label %17
14: ; preds = %5
%15 = load i32, i32* @stderr
%16 = tail call i32 @fputs(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %20
17: ; preds = %5
%18 = call double @dlansy_(i8* %6, i8* %7, i32* %8, double* %3, i32* %9, double* %12)
%19 = call i32 @free(double* %12)
br label %20
20: ; preds = %17, %14
%21 = phi double [ 0.000000e+00, %14 ], [ %18, %17 ]
ret double %21
}