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

/* Variables and functions */
int /*<<< orphan*/ constant_name_maps(struct constant_map **,
                                      int /*<<< orphan*/);
scalar_t__ extract_val(int /*<<< orphan*/ *, size_t, int /*<<< orphan*/ *);
char *strdup(int /*<<< orphan*/);
char *field_debug_cst(u_int8_t *buf, size_t len, struct constant_map **maps) {
  u_int32_t val;
  if (extract_val(buf, len, &val))
    return 0;
  return strdup(constant_name_maps(maps, val));
}


x86 assembly (clang, -O0):
<field_debug_cst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1040 <extract_val@plt>
cmp    $0x0,%rax
je     116c <field_debug_cst+0x3c>
movq   $0x0,-0x8(%rbp)
jmp    1183 <field_debug_cst+0x53>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <constant_name_maps@plt>
mov    %eax,%edi
call   1050 <strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<field_debug_cst>:
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
lea    0xc(%rsp),%rdx
call   1040 <extract_val@plt>
test   %rax,%rax
je     114b <field_debug_cst+0x1b>
xor    %eax,%eax
jmp    115e <field_debug_cst+0x2e>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1030 <constant_name_maps@plt>
mov    %eax,%edi
call   1050 <strdup@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.constant_map = type { i32 }
define i8* @field_debug_cst(i32* %0, i64 %1, %struct.constant_map** %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca %struct.constant_map**
%8 = alloca i32
store i32* %0, i32** %5
store i64 %1, i64* %6
store %struct.constant_map** %2, %struct.constant_map*** %7
%9 = load i32*, i32** %5
%10 = load i64, i64* %6
%11 = call i64 @extract_val(i32* %9, i64 %10, i32* %8)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %3
store i8* null, i8** %4
br label %19
14: ; preds = %3
%15 = load %struct.constant_map**, %struct.constant_map*** %7
%16 = load i32, i32* %8
%17 = call i32 @constant_name_maps(%struct.constant_map** %15, i32 %16)
%18 = call i8* @strdup(i32 %17)
store i8* %18, i8** %4
br label %19
19: ; preds = %14, %13
%20 = load i8*, i8** %4
ret i8* %20
}

LLVM IR (-O2):
%struct.constant_map = type { i32 }
define i8* @field_debug_cst(i32* %0, i64 %1, %struct.constant_map** %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = call i64 @extract_val(i32* %0, i64 %1, i32* %4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = load i32, i32* %4
%10 = call i32 @constant_name_maps(%struct.constant_map** %2, i32 %9)
%11 = call i8* @strdup(i32 %10)
br label %12
12: ; preds = %3, %8
%13 = phi i8* [ %11, %8 ], [ null, %3 ]
ret i8* %13
}