#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*/ asprintf(char **, char *, int /*<<< orphan*/);
scalar_t__ extract_val(int /*<<< orphan*/ *, size_t, int /*<<< orphan*/ *);
char *field_debug_num(u_int8_t *buf, size_t len, struct constant_map **maps) {
  char *retval;
  u_int32_t val;
  if (extract_val(buf, len, &val))
    return 0;
  asprintf(&retval, "%u", val);
  return retval;
}


x86 assembly (clang, -O0):
<field_debug_num>:
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    -0x2c(%rbp),%rdx
call   1040 <extract_val@plt>
cmp    $0x0,%rax
je     115c <field_debug_num+0x3c>
movq   $0x0,-0x8(%rbp)
jmp    1177 <field_debug_num+0x57>
mov    -0x2c(%rbp),%edx
lea    -0x28(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1030 <asprintf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<field_debug_num>:
sub    $0x18,%rsp
lea    0xc(%rsp),%rdx
call   1040 <extract_val@plt>
test   %rax,%rax
je     113a <field_debug_num+0x1a>
xor    %eax,%eax
add    $0x18,%rsp
ret
mov    0xc(%rsp),%edx
lea    0xebb(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <asprintf@plt>
mov    0x10(%rsp),%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.constant_map = type { i32 }
@.str = [3 x i8] c"%u\00"
define i8* @field_debug_num(i32* %0, i64 %1, %struct.constant_map** %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca %struct.constant_map**
%8 = alloca i8*
%9 = alloca i32
store i32* %0, i32** %5
store i64 %1, i64* %6
store %struct.constant_map** %2, %struct.constant_map*** %7
%10 = load i32*, i32** %5
%11 = load i64, i64* %6
%12 = call i64 @extract_val(i32* %10, i64 %11, i32* %9)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %3
store i8* null, i8** %4
br label %19
15: ; preds = %3
%16 = load i32, i32* %9
%17 = call i32 @asprintf(i8** %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load i8*, i8** %8
store i8* %18, i8** %4
br label %19
19: ; preds = %15, %14
%20 = load i8*, i8** %4
ret i8* %20
}

LLVM IR (-O2):
%struct.constant_map = type { i32 }
@.str = [3 x i8] c"%u\00"
define i8* @field_debug_num(i32* %0, i64 %1, %struct.constant_map** nocapture readnone %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = bitcast i8** %4 to i8*
%7 = bitcast i32* %5 to i8*
%8 = call i64 @extract_val(i32* %0, i64 %1, i32* %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i32, i32* %5
%12 = call i32 @asprintf(i8** %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i8*, i8** %4
br label %14
14: ; preds = %3, %10
%15 = phi i8* [ %13, %10 ], [ null, %3 ]
ret i8* %15
}