#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_maps(struct constant_map **maps, int value) {
  static char tmp[32];
  char *retval;
  struct constant_map **map;
  for (map = maps; *map; map++) {
    retval = constant_lookup(*map, value);
    if (retval)
      return retval;
  }
  snprintf(tmp, sizeof tmp, "<Unknown %d>", value);
  return tmp;
}


x86 assembly (clang, -O0):
<constant_name_maps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
je     1186 <constant_name_maps+0x66>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x14(%rbp),%esi
call   1040 <constant_lookup@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1170 <constant_name_maps+0x50>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ac <constant_name_maps+0x8c>
jmp    1175 <constant_name_maps+0x55>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
jmp    1137 <constant_name_maps+0x17>
mov    -0x14(%rbp),%ecx
lea    0x2eb0(%rip),%rdi
mov    $0x20,%esi
lea    0xe64(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2e98(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<constant_name_maps>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1159 <constant_name_maps+0x39>
add    $0x8,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14d,%esi
call   1040 <constant_lookup@plt>
test   %rax,%rax
jne    1179 <constant_name_maps+0x59>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1140 <constant_name_maps+0x20>
lea    0x2ee0(%rip),%rbp
lea    0xe99(%rip),%rdx
mov    %rbp,%rdi
mov    $0x20,%esi
mov    %r14d,%ecx
call   1030 <snprintf@plt>
jmp    117c <constant_name_maps+0x5c>
mov    %rax,%rbp
mov    %rbp,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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