#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 */
char *calloc(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
char *mm_alloc_char(int size) {
  if (size < 1) {
    fprintf(stderr, "mm_alloc_char: size is too small\n");
    return NULL;
  }
  char *data = calloc(size, sizeof(char));
  if (!data) {
    fprintf(stderr, "mm_alloc_char: unable to allocate %d\n", size);
    return NULL;
  }
  return data;
}


x86 assembly (clang, -O0):
<mm_alloc_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    1159 <mm_alloc_char+0x39>
mov    0x2ea4(%rip),%rax
mov    (%rax),%edi
lea    0xebb(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11a4 <mm_alloc_char+0x84>
mov    -0xc(%rbp),%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119c <mm_alloc_char+0x7c>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xe9a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11a4 <mm_alloc_char+0x84>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mm_alloc_char>:
push   %rbp
push   %rbx
push   %rax
test   %edi,%edi
jle    1158 <mm_alloc_char+0x38>
mov    %edi,%ebp
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1171 <mm_alloc_char+0x51>
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
lea    0xed7(%rip),%rsi
xor    %ebx,%ebx
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1171 <mm_alloc_char+0x51>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"mm_alloc_char: size is too small\0A\00"
@.str.1 = [38 x i8] c"mm_alloc_char: unable to allocate %d\0A\00"
define i8* @mm_alloc_char(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 1
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %2
br label %21
10: ; preds = %1
%11 = load i32, i32* %3
%12 = call i8* @calloc(i32 %11, i32 1)
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = icmp ne i8* %13, null
br i1 %14, label %19, label %15
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = load i32, i32* %3
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %17)
store i8* null, i8** %2
br label %21
19: ; preds = %10
%20 = load i8*, i8** %4
store i8* %20, i8** %2
br label %21
21: ; preds = %19, %15, %7
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"mm_alloc_char: size is too small\0A\00"
@.str.1 = [38 x i8] c"mm_alloc_char: unable to allocate %d\0A\00"
define noalias i8* @mm_alloc_char(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %12
6: ; preds = %1
%7 = tail call i8* @calloc(i32 %0, i32 1)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %12
12: ; preds = %9, %6, %3
%13 = phi i8* [ null, %3 ], [ null, %9 ], [ %7, %6 ]
ret i8* %13
}