#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 */
struct constant_map {
  int dummy;
};

/* Variables and functions */
char *constant_lookup(struct constant_map *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
char *constant_name(struct constant_map *map, int value) {
  static char tmp[32];
  char *retval = constant_lookup(map, value);
  if (!retval) {
    snprintf(tmp, sizeof tmp, "<Unknown %d>", value);
    return tmp;
  }
  return retval;
}


x86 assembly (clang, -O0):
<constant_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <constant_lookup@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1175 <constant_name+0x55>
mov    -0x14(%rbp),%ecx
lea    0x2eec(%rip),%rdi
mov    $0x20,%esi
lea    0xea0(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2ed4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117d <constant_name+0x5d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<constant_name>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
call   1040 <constant_lookup@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    114f <constant_name+0x2f>
lea    0x2f07(%rip),%rbx
lea    0xec0(%rip),%rdx
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %ebp,%ecx
call   1030 <snprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.constant_map = type { i32 }
@constant_name.tmp = internal global [32 x i8] zeroinitializer
@.str = [13 x i8] c"<Unknown %d>\00"
define i8* @constant_name(%struct.constant_map* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca %struct.constant_map*
%5 = alloca i32
%6 = alloca i8*
store %struct.constant_map* %0, %struct.constant_map** %4
store i32 %1, i32* %5
%7 = load %struct.constant_map*, %struct.constant_map** %4
%8 = load i32, i32* %5
%9 = call i8* @constant_lookup(%struct.constant_map* %7, i32 %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = load i32, i32* %5
%14 = call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @constant_name.tmp, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %13)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @constant_name.tmp, i64 0, i64 0), i8** %3
br label %17
15: ; preds = %2
%16 = load i8*, i8** %6
store i8* %16, i8** %3
br label %17
17: ; preds = %15, %12
%18 = load i8*, i8** %3
ret i8* %18
}

LLVM IR (-O2):
%struct.constant_map = type { i32 }
@constant_name.tmp = internal global [32 x i8] zeroinitializer
@.str = [13 x i8] c"<Unknown %d>\00"
define i8* @constant_name(%struct.constant_map* %0, i32 %1) {
%3 = tail call i8* @constant_lookup(%struct.constant_map* %0, i32 %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @constant_name.tmp, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %7
7: ; preds = %2, %5
%8 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @constant_name.tmp, i64 0, i64 0), %5 ], [ %3, %2 ]
ret i8* %8
}