#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__ calloc(int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ svd_errm();
double **svd_calloc_double2(int n1, int n2) {
  int i;
  double **a;
  if (!(a = (double **)malloc(n1 * sizeof(double *))))
    svd_errm();
  if (!(a[0] = (double *)calloc(n1 * n2, sizeof(double))))
    svd_errm();
  for (i = 1; i < n1; i++)
    a[i] = a[0] + i * n2;
  return a;
}


x86 assembly (clang, -O0):
<svd_calloc_double2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1162 <svd_calloc_double2+0x32>
mov    $0x0,%al
call   1050 <svd_errm@plt>
mov    -0x4(%rbp),%edi
imul   -0x8(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    -0x18(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    118b <svd_calloc_double2+0x5b>
mov    $0x0,%al
call   1050 <svd_errm@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11cf <svd_calloc_double2+0x9f>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
mov    -0xc(%rbp),%eax
imul   -0x8(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1192 <svd_calloc_double2+0x62>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<svd_calloc_double2>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
lea    0x0(,%rbp,8),%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1154 <svd_calloc_double2+0x24>
xor    %eax,%eax
call   1050 <svd_errm@plt>
mov    %r14d,%edi
imul   %ebp,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     1176 <svd_calloc_double2+0x46>
cmp    $0x2,%ebp
jge    1186 <svd_calloc_double2+0x56>
jmp    1230 <svd_calloc_double2+0x100>
xor    %eax,%eax
call   1050 <svd_errm@plt>
cmp    $0x2,%ebp
jl     1230 <svd_calloc_double2+0x100>
mov    (%rbx),%r8
movslq %r14d,%r9
mov    %ebp,%eax
lea    -0x1(%rax),%r11
add    $0xfffffffffffffffe,%rax
mov    %r11d,%r10d
and    $0x3,%r10d
mov    $0x1,%edi
cmp    $0x3,%rax
jb     11fd <svd_calloc_double2+0xcd>
and    $0xfffffffffffffffc,%r11
mov    %r9,%rax
shl    $0x5,%rax
lea    (%r8,%rax,1),%rbp
lea    (%r9,%r9,2),%rcx
lea    (%r8,%rcx,8),%rdx
lea    (%r8,%r9,8),%rcx
mov    %r9,%rsi
shl    $0x4,%rsi
add    %r8,%rsi
xor    %edi,%edi
nop
mov    %rcx,0x8(%rbx,%rdi,8)
mov    %rsi,0x10(%rbx,%rdi,8)
mov    %rdx,0x18(%rbx,%rdi,8)
mov    %rbp,0x20(%rbx,%rdi,8)
add    $0x4,%rdi
add    %rax,%rbp
add    %rax,%rdx
add    %rax,%rcx
add    %rax,%rsi
cmp    %rdi,%r11
jne    11d0 <svd_calloc_double2+0xa0>
add    $0x1,%rdi
test   %r10,%r10
je     1230 <svd_calloc_double2+0x100>
lea    (%rbx,%rdi,8),%rax
imul   %r9,%rdi
lea    (%r8,%rdi,8),%rcx
shl    $0x3,%r9
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rcx,(%rax,%rdx,8)
add    $0x1,%rdx
add    %r9,%rcx
cmp    %rdx,%r10
jne    1220 <svd_calloc_double2+0xf0>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double** @svd_calloc_double2(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double**
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = mul i64 %8, 8
%10 = trunc i64 %9 to i32
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to double**
store double** %12, double*** %6
%13 = icmp ne double** %12, null
br i1 %13, label %16, label %14
14: ; preds = %2
%15 = call i32 (...) @svd_errm()
br label %16
16: ; preds = %14, %2
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = mul nsw i32 %17, %18
%20 = call i64 @calloc(i32 %19, i32 8)
%21 = inttoptr i64 %20 to double*
%22 = load double**, double*** %6
%23 = getelementptr inbounds double*, double** %22, i64 0
store double* %21, double** %23
%24 = icmp ne double* %21, null
br i1 %24, label %27, label %25
25: ; preds = %16
%26 = call i32 (...) @svd_errm()
br label %27
27: ; preds = %25, %16
store i32 1, i32* %5
br label %28
28: ; preds = %45, %27
%29 = load i32, i32* %5
%30 = load i32, i32* %3
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %48
32: ; preds = %28
%33 = load double**, double*** %6
%34 = getelementptr inbounds double*, double** %33, i64 0
%35 = load double*, double** %34
%36 = load i32, i32* %5
%37 = load i32, i32* %4
%38 = mul nsw i32 %36, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %35, i64 %39
%41 = load double**, double*** %6
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double*, double** %41, i64 %43
store double* %40, double** %44
br label %45
45: ; preds = %32
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %28
48: ; preds = %28
%49 = load double**, double*** %6
ret double** %49
}

LLVM IR (-O2):
define double** @svd_calloc_double2(i32 %0, i32 %1) {
%3 = shl i32 %0, 3
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to double**
%6 = icmp eq i64 %4, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 (...) @svd_errm()
br label %9
9: ; preds = %7, %2
%10 = mul nsw i32 %1, %0
%11 = tail call i64 @calloc(i32 %10, i32 8)
%12 = inttoptr i64 %11 to double*
store double* %12, double** %5
%13 = icmp eq i64 %11, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 (...) @svd_errm()
br label %16
16: ; preds = %14, %9
%17 = icmp sgt i32 %0, 1
br i1 %17, label %18, label %61
18: ; preds = %16
%19 = load double*, double** %5
%20 = sext i32 %1 to i64
%21 = zext i32 %0 to i64
%22 = add nsw i64 %21, -1
%23 = add nsw i64 %21, -2
%24 = and i64 %22, 3
%25 = icmp ult i64 %23, 3
br i1 %25, label %49, label %26
26: ; preds = %18
%27 = and i64 %22, -4
br label %28
28: ; preds = %28, %26
%29 = phi i64 [ 1, %26 ], [ %46, %28 ]
%30 = phi i64 [ 0, %26 ], [ %47, %28 ]
%31 = mul nsw i64 %29, %20
%32 = getelementptr inbounds double, double* %19, i64 %31
%33 = getelementptr inbounds double*, double** %5, i64 %29
store double* %32, double** %33
%34 = add nuw nsw i64 %29, 1
%35 = mul nsw i64 %34, %20
%36 = getelementptr inbounds double, double* %19, i64 %35
%37 = getelementptr inbounds double*, double** %5, i64 %34
store double* %36, double** %37
%38 = add nuw nsw i64 %29, 2
%39 = mul nsw i64 %38, %20
%40 = getelementptr inbounds double, double* %19, i64 %39
%41 = getelementptr inbounds double*, double** %5, i64 %38
store double* %40, double** %41
%42 = add nuw nsw i64 %29, 3
%43 = mul nsw i64 %42, %20
%44 = getelementptr inbounds double, double* %19, i64 %43
%45 = getelementptr inbounds double*, double** %5, i64 %42
store double* %44, double** %45
%46 = add nuw nsw i64 %29, 4
%47 = add nuw i64 %30, 4
%48 = icmp eq i64 %47, %27
br i1 %48, label %49, label %28
49: ; preds = %28, %18
%50 = phi i64 [ 1, %18 ], [ %46, %28 ]
%51 = icmp eq i64 %24, 0
br i1 %51, label %61, label %52
52: ; preds = %49, %52
%53 = phi i64 [ %58, %52 ], [ %50, %49 ]
%54 = phi i64 [ %59, %52 ], [ 0, %49 ]
%55 = mul nsw i64 %53, %20
%56 = getelementptr inbounds double, double* %19, i64 %55
%57 = getelementptr inbounds double*, double** %5, i64 %53
store double* %56, double** %57
%58 = add nuw nsw i64 %53, 1
%59 = add i64 %54, 1
%60 = icmp eq i64 %59, %24
br i1 %60, label %61, label %52
61: ; preds = %49, %52, %16
ret double** %5
}