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


x86 assembly (clang, -O0):
<call_dsytri>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movq   $0x0,-0x38(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11aa <call_dsytri+0x6a>
mov    0x2e50(%rip),%rax
mov    (%rax),%esi
lea    0xe67(%rip),%rdi
call   1050 <fputs@plt>
movl   $0xfffffc19,-0x4(%rbp)
jmp    11de <call_dsytri+0x9e>
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%r8
mov    -0x38(%rbp),%r9
lea    -0x5(%rbp),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x1c(%rbp),%rcx
lea    -0x2c(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <dsytri_@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<call_dsytri>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %r8,%r14
mov    %rdx,%r15
mov    %dil,0x13(%rsp)
mov    %esi,0x1c(%rsp)
mov    %ecx,0x18(%rsp)
movl   $0x0,0x14(%rsp)
lea    0x0(,%rsi,8),%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11ac <call_dsytri+0x6c>
mov    %rax,%rbx
lea    0x14(%rsp),%rax
mov    %rax,(%rsp)
lea    0x13(%rsp),%rdi
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rcx
mov    %r15,%rdx
mov    %r14,%r8
mov    %rbx,%r9
call   1030 <dsytri_@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    0x14(%rsp),%eax
jmp    11c6 <call_dsytri+0x86>
mov    0x2e2d(%rip),%rax
mov    (%rax),%esi
lea    0xe44(%rip),%rdi
call   1050 <fputs@plt>
mov    $0xfffffc19,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [57 x i8] c"ERROR: memory allocation (malloc) failed in call_dsytri\0A\00"
@stderr = global i32 0
define i32 @call_dsytri(i8 signext %0, i32 %1, double* %2, i32 %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
%13 = alloca double*
store i8 %0, i8* %7
store i32 %1, i32* %8
store double* %2, double** %9
store i32 %3, i32* %10
store i32* %4, i32** %11
store i32 0, i32* %12
store double* null, double** %13
%14 = load i32, i32* %8
%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 %25
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)
store i32 -999, i32* %6
br label %33
25: ; preds = %5
%26 = load double*, double** %9
%27 = load i32*, i32** %11
%28 = load double*, double** %13
%29 = call i32 @dsytri_(i8* %7, i32* %8, double* %26, i32* %10, i32* %27, double* %28, i32* %12)
%30 = load double*, double** %13
%31 = call i32 @free(double* %30)
%32 = load i32, i32* %12
store i32 %32, i32* %6
br label %33
33: ; preds = %25, %22
%34 = load i32, i32* %6
ret i32 %34
}

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