#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);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
unsigned short int *get_1d_mem_usi(int dim1) {
  unsigned short int *array_1d;
  if (!(array_1d =
            (unsigned short int *)calloc(dim1, sizeof(unsigned short int)))) {
    fprintf(stderr, "unable to allocate memory in get_1d_mem_usi\n");
    fprintf(stderr, "dimension %d\n", dim1);
    exit(1);
  }
  return array_1d;
}


x86 assembly (clang, -O0):
<get_1d_mem_usi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1030 <calloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1191 <get_1d_mem_usi+0x61>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
lea    0xe9a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xead(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_1d_mem_usi>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0x2,%esi
call   1030 <calloc@plt>
test   %rax,%rax
je     114d <get_1d_mem_usi+0x1d>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e8c(%rip),%r14
mov    (%r14),%edi
lea    0xea2(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0xebe(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [45 x i8] c"unable to allocate memory in get_1d_mem_usi\0A\00"
@.str.1 = [14 x i8] c"dimension %d\0A\00"
define i16* @get_1d_mem_usi(i32 %0) {
%2 = alloca i32
%3 = alloca i16*
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i64 @calloc(i32 %4, i32 2)
%6 = inttoptr i64 %5 to i16*
store i16* %6, i16** %3
%7 = icmp ne i16* %6, null
br i1 %7, label %15, label %8
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = load i32, i32* %2
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %1
%16 = load i16*, i16** %3
ret i16* %16
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [45 x i8] c"unable to allocate memory in get_1d_mem_usi\0A\00"
@.str.1 = [14 x i8] c"dimension %d\0A\00"
define i16* @get_1d_mem_usi(i32 %0) {
%2 = tail call i64 @calloc(i32 %0, i32 2)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %1
%11 = inttoptr i64 %2 to i16*
ret i16* %11
}