#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int get_nxny(unsigned char *, unsigned char *, unsigned char *,
             unsigned char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ unpk_bds(float *, unsigned char *, unsigned char *,
                            unsigned char *, unsigned char *, int);
float *get_unpk_bds(unsigned char *pds, unsigned char *gds, unsigned char *bms,
                    unsigned char *bds) {
  int nxny;
  float *array;
  nxny = get_nxny(pds, gds, bms, bds);
  if ((array = (float *)malloc(nxny * sizeof(float))) == NULL) {
    fprintf(stderr, "memory allocation problem: get_unpk_bds\n");
    exit(8);
  }
  unpk_bds(array, pds, gds, bms, bds, nxny);
  return array;
}


x86 assembly (clang, -O0):
<get_unpk_bds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1060 <get_nxny@plt>
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11bc <get_unpk_bds+0x6c>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x8,%edi
call   1070 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
call   1030 <unpk_bds@plt>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_unpk_bds>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
call   1060 <get_nxny@plt>
mov    %eax,%ebx
lea    0x0(,%rbx,4),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11ab <get_unpk_bds+0x5b>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
mov    %ebx,%r9d
call   1030 <unpk_bds@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
lea    0xe45(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x8,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [41 x i8] c"memory allocation problem: get_unpk_bds\0A\00"
define float* @get_unpk_bds(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca float*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = load i8*, i8** %7
%14 = load i8*, i8** %8
%15 = call i32 @get_nxny(i8* %11, i8* %12, i8* %13, i8* %14)
store i32 %15, i32* %9
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 4
%19 = trunc i64 %18 to i32
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to float*
store float* %21, float** %10
%22 = icmp eq float* %21, null
br i1 %22, label %23, label %27
23: ; preds = %4
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @exit(i32 8)
unreachable
27: ; preds = %4
%28 = load float*, float** %10
%29 = load i8*, i8** %5
%30 = load i8*, i8** %6
%31 = load i8*, i8** %7
%32 = load i8*, i8** %8
%33 = load i32, i32* %9
%34 = call i32 @unpk_bds(float* %28, i8* %29, i8* %30, i8* %31, i8* %32, i32 %33)
%35 = load float*, float** %10
ret float* %35
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"memory allocation problem: get_unpk_bds\0A\00"
define float* @get_unpk_bds(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i32 @get_nxny(i8* %0, i8* %1, i8* %2, i8* %3)
%6 = shl i32 %5, 2
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to float*
%9 = icmp eq i64 %7, 0
br i1 %9, label %10, label %14
10: ; preds = %4
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 8)
unreachable
14: ; preds = %4
%15 = tail call i32 @unpk_bds(float* %8, i8* %0, i8* %1, i8* %2, i8* %3, i32 %5)
ret float* %8
}