#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 res_sym {
  scalar_t__ name;
  int number;
};

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, int);
const char *sym_ntos(const struct res_sym *syms, int number, int *success) {
  static char unname[20];
  for ((void)NULL; syms->name != 0; syms++) {
    if (number == syms->number) {
      if (success)
        *success = 1;
      return (syms->name);
    }
  }
  sprintf(unname, "%d", number);
  if (success)
    *success = 0;
  return (unname);
}


x86 assembly (clang, -O0):
<sym_ntos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     117c <sym_ntos+0x6c>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    0x8(%rcx),%eax
jne    1166 <sym_ntos+0x56>
cmpq   $0x0,-0x20(%rbp)
je     1156 <sym_ntos+0x46>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11b2 <sym_ntos+0xa2>
jmp    116b <sym_ntos+0x5b>
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
jmp    1123 <sym_ntos+0x13>
mov    -0x14(%rbp),%edx
lea    0x2eba(%rip),%rdi
lea    0xe73(%rip),%rsi
call   1030 <sprintf@plt>
cmpq   $0x0,-0x20(%rbp)
je     11a7 <sym_ntos+0x97>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
lea    0x2e92(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sym_ntos>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%edx
mov    (%rdi),%rbx
test   %rbx,%rbx
je     1152 <sym_ntos+0x42>
cmp    %edx,0x8(%rdi)
je     1144 <sym_ntos+0x34>
add    $0x18,%rdi
nopw   0x0(%rax,%rax,1)
mov    -0x8(%rdi),%rbx
test   %rbx,%rbx
je     1152 <sym_ntos+0x42>
lea    0x10(%rdi),%rax
cmp    %edx,(%rdi)
mov    %rax,%rdi
jne    1130 <sym_ntos+0x20>
test   %r14,%r14
je     1174 <sym_ntos+0x64>
movl   $0x1,(%r14)
jmp    1174 <sym_ntos+0x64>
lea    0x2ee7(%rip),%rbx
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
test   %r14,%r14
je     1174 <sym_ntos+0x64>
movl   $0x0,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.res_sym = type { i64, i32 }
@sym_ntos.unname = internal global [20 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
define i8* @sym_ntos(%struct.res_sym* %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca %struct.res_sym*
%6 = alloca i32
%7 = alloca i32*
store %struct.res_sym* %0, %struct.res_sym** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
br label %8
8: ; preds = %30, %3
%9 = load %struct.res_sym*, %struct.res_sym** %5
%10 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %9, i32 0, i32 0
%11 = load i64, i64* %10
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %33
13: ; preds = %8
%14 = load i32, i32* %6
%15 = load %struct.res_sym*, %struct.res_sym** %5
%16 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %15, i32 0, i32 1
%17 = load i32, i32* %16
%18 = icmp eq i32 %14, %17
br i1 %18, label %19, label %29
19: ; preds = %13
%20 = load i32*, i32** %7
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = load i32*, i32** %7
store i32 1, i32* %23
br label %24
24: ; preds = %22, %19
%25 = load %struct.res_sym*, %struct.res_sym** %5
%26 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %25, i32 0, i32 0
%27 = load i64, i64* %26
%28 = inttoptr i64 %27 to i8*
store i8* %28, i8** %4
br label %41
29: ; preds = %13
br label %30
30: ; preds = %29
%31 = load %struct.res_sym*, %struct.res_sym** %5
%32 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %31, i32 1
store %struct.res_sym* %32, %struct.res_sym** %5
br label %8
33: ; preds = %8
%34 = load i32, i32* %6
%35 = call i32 @sprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @sym_ntos.unname, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = load i32*, i32** %7
%37 = icmp ne i32* %36, null
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = load i32*, i32** %7
store i32 0, i32* %39
br label %40
40: ; preds = %38, %33
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @sym_ntos.unname, i64 0, i64 0), i8** %4
br label %41
41: ; preds = %40, %24
%42 = load i8*, i8** %4
ret i8* %42
}

LLVM IR (-O2):
%struct.res_sym = type { i64, i32 }
@sym_ntos.unname = internal global [20 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
define i8* @sym_ntos(%struct.res_sym* nocapture %0, i32 %1, i32* writeonly %2) {
%4 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %0, i64 0, i32 0
%5 = load i64, i64* %4
%6 = icmp eq i64 %5, 0
br i1 %6, label %27, label %7
7: ; preds = %3
%8 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %0, i64 0, i32 1
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, %1
br i1 %10, label %21, label %11
11: ; preds = %7, %17
%12 = phi %struct.res_sym* [ %13, %17 ], [ %0, %7 ]
%13 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %12, i64 1
%14 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %13, i64 0, i32 0
%15 = load i64, i64* %14
%16 = icmp eq i64 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %11
%18 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %12, i64 1, i32 1
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, %1
br i1 %20, label %21, label %11
21: ; preds = %17, %7
%22 = phi i64 [ %5, %7 ], [ %15, %17 ]
%23 = icmp eq i32* %2, null
br i1 %23, label %25, label %24
24: ; preds = %21
store i32 1, i32* %2
br label %25
25: ; preds = %24, %21
%26 = inttoptr i64 %22 to i8*
br label %31
27: ; preds = %11, %3
%28 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @sym_ntos.unname, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %1)
%29 = icmp eq i32* %2, null
br i1 %29, label %31, label %30
30: ; preds = %27
store i32 0, i32* %2
br label %31
31: ; preds = %27, %30, %25
%32 = phi i8* [ %26, %25 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @sym_ntos.unname, i64 0, i64 0), %30 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @sym_ntos.unname, i64 0, i64 0), %27 ]
ret i8* %32
}