#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, unsigned int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ perror(char *);
int funct_in_shared_libr_dynamically_loaded(unsigned int numb_elements) {
  char *ptr;
  if (numb_elements < 1)
    return 0;
  ptr = (char *)calloc(sizeof(char *), numb_elements);
  if (ptr) {
    free(ptr);
    return 1;
  } else {
    perror("ERROR: funct_in_shared_libr_dynamically_loaded");
    return -1;
  }
}


x86 assembly (clang, -O0):
<funct_in_shared_libr_dynamically_loaded>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jae    1151 <funct_in_shared_libr_dynamically_loaded+0x21>
movl   $0x0,-0x4(%rbp)
jmp    1195 <funct_in_shared_libr_dynamically_loaded+0x65>
mov    -0x8(%rbp),%esi
mov    $0x8,%edi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1182 <funct_in_shared_libr_dynamically_loaded+0x52>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1195 <funct_in_shared_libr_dynamically_loaded+0x65>
lea    0xe77(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<funct_in_shared_libr_dynamically_loaded>:
push   %rax
test   %edi,%edi
je     1155 <funct_in_shared_libr_dynamically_loaded+0x25>
mov    %edi,%esi
mov    $0x8,%edi
call   1040 <calloc@plt>
test   %rax,%rax
je     1159 <funct_in_shared_libr_dynamically_loaded+0x29>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x1,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret
lea    0xea0(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [47 x i8] c"ERROR: funct_in_shared_libr_dynamically_loaded\00"
define i32 @funct_in_shared_libr_dynamically_loaded(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp ult i32 %5, 1
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 0, i32* %2
br label %19
8: ; preds = %1
%9 = load i32, i32* %3
%10 = call i64 @calloc(i32 8, i32 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = load i8*, i8** %4
%16 = call i32 @free(i8* %15)
store i32 1, i32* %2
br label %19
17: ; preds = %8
%18 = call i32 @perror(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %19
19: ; preds = %17, %14, %7
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@.str = [47 x i8] c"ERROR: funct_in_shared_libr_dynamically_loaded\00"
define i32 @funct_in_shared_libr_dynamically_loaded(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = tail call i64 @calloc(i32 8, i32 %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = inttoptr i64 %4 to i8*
%8 = tail call i32 @free(i8* %7)
br label %11
9: ; preds = %3
%10 = tail call i32 @perror(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %1, %9, %6
%12 = phi i32 [ 1, %6 ], [ -1, %9 ], [ 0, %1 ]
ret i32 %12
}