#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*/ ENOENT;
int /*<<< orphan*/ ENOMEM;
char *cw_character_to_representation_internal(int);
int /*<<< orphan*/ errno;
char *strdup(char const *);
char *cw_character_to_representation(int c) {
  const char *representation = cw_character_to_representation_internal(c);
  if (representation) {
    char *r = strdup(representation);
    if (r) {
      return r;
    } else {
      errno = ENOMEM;
      return NULL;
    }
  } else {
    errno = ENOENT;
    return NULL;
  }
}


x86 assembly (clang, -O0):
<cw_character_to_representation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <cw_character_to_representation_internal@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1186 <cw_character_to_representation+0x66>
mov    -0x18(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1167 <cw_character_to_representation+0x47>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a0 <cw_character_to_representation+0x80>
mov    0x2e72(%rip),%rax
mov    (%rax),%ecx
mov    0x2e61(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    11a0 <cw_character_to_representation+0x80>
mov    0x2e3b(%rip),%rax
mov    (%rax),%ecx
mov    0x2e42(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cw_character_to_representation>:
push   %rax
call   1030 <cw_character_to_representation_internal@plt>
test   %rax,%rax
je     113a <cw_character_to_representation+0x1a>
mov    %rax,%rdi
call   1040 <strdup@plt>
test   %rax,%rax
je     1143 <cw_character_to_representation+0x23>
pop    %rcx
ret
mov    0x2e87(%rip),%rax
jmp    114a <cw_character_to_representation+0x2a>
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
mov    0x2e85(%rip),%rcx
mov    %eax,(%rcx)
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@ENOMEM = global i32 0
@errno = global i32 0
@ENOENT = global i32 0
define i8* @cw_character_to_representation(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = call i8* @cw_character_to_representation_internal(i32 %6)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %19
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = call i8* @strdup(i8* %11)
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = load i8*, i8** %5
store i8* %16, i8** %2
br label %21
17: ; preds = %10
%18 = load i32, i32* @ENOMEM
store i32 %18, i32* @errno
store i8* null, i8** %2
br label %21
19: ; preds = %1
%20 = load i32, i32* @ENOENT
store i32 %20, i32* @errno
store i8* null, i8** %2
br label %21
21: ; preds = %19, %17, %15
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
@ENOMEM = global i32 0
@errno = global i32 0
@ENOENT = global i32 0
define noalias i8* @cw_character_to_representation(i32 %0) {
%2 = tail call i8* @cw_character_to_representation_internal(i32 %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i8* @strdup(i8* %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %1, %4
%8 = phi i32* [ @ENOMEM, %4 ], [ @ENOENT, %1 ]
%9 = load i32, i32* %8
store i32 %9, i32* @errno
br label %10
10: ; preds = %7, %4
%11 = phi i8* [ %5, %4 ], [ null, %7 ]
ret i8* %11
}