#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;
  char const *humanname;
};

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, int);
const char *sym_ntop(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->humanname);
    }
  }
  sprintf(unname, "%d", number);
  if (success)
    *success = 0;
  return (unname);
}


x86 assembly (clang, -O0):
<sym_ntop>:
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     117d <sym_ntop+0x6d>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    0x8(%rcx),%eax
jne    1167 <sym_ntop+0x57>
cmpq   $0x0,-0x20(%rbp)
je     1156 <sym_ntop+0x46>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11b3 <sym_ntop+0xa3>
jmp    116c <sym_ntop+0x5c>
mov    -0x10(%rbp),%rax
add    $0x18,%rax
mov    %rax,-0x10(%rbp)
jmp    1123 <sym_ntop+0x13>
mov    -0x14(%rbp),%edx
lea    0x2eb9(%rip),%rdi
lea    0xe72(%rip),%rsi
call   1030 <sprintf@plt>
cmpq   $0x0,-0x20(%rbp)
je     11a8 <sym_ntop+0x98>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
lea    0x2e91(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sym_ntop>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%edx
cmpq   $0x0,(%rdi)
je     113f <sym_ntop+0x2f>
add    $0x18,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %edx,-0x10(%rdi)
je     1163 <sym_ntop+0x53>
cmpq   $0x0,(%rdi)
lea    0x18(%rdi),%rdi
jne    1130 <sym_ntop+0x20>
lea    0x2efa(%rip),%rbx
lea    0xeb3(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
test   %r14,%r14
je     1173 <sym_ntop+0x63>
movl   $0x0,(%r14)
jmp    1173 <sym_ntop+0x63>
test   %r14,%r14
je     116f <sym_ntop+0x5f>
movl   $0x1,(%r14)
mov    -0x8(%rdi),%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.res_sym = type { i64, i32, i8* }
@sym_ntop.unname = internal global [20 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
define i8* @sym_ntop(%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 = %29, %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 %32
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 %28
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 2
%27 = load i8*, i8** %26
store i8* %27, i8** %4
br label %40
28: ; preds = %13
br label %29
29: ; preds = %28
%30 = load %struct.res_sym*, %struct.res_sym** %5
%31 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %30, i32 1
store %struct.res_sym* %31, %struct.res_sym** %5
br label %8
32: ; preds = %8
%33 = load i32, i32* %6
%34 = call i32 @sprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @sym_ntop.unname, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = load i32*, i32** %7
%36 = icmp ne i32* %35, null
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = load i32*, i32** %7
store i32 0, i32* %38
br label %39
39: ; preds = %37, %32
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @sym_ntop.unname, i64 0, i64 0), i8** %4
br label %40
40: ; preds = %39, %24
%41 = load i8*, i8** %4
ret i8* %41
}

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