#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;

/* Variables and functions */
char *names_subclass(int /*<<< orphan*/, int /*<<< orphan*/);
int snprintf(char *, size_t, char *, char const *);
int get_subclass_string(char *buf, size_t size, u_int8_t cls, u_int8_t subcls) {
  const char *cp;
  if (size < 1)
    return 0;
  *buf = 0;
  if (!(cp = names_subclass(cls, subcls)))
    return 0;
  return snprintf(buf, size, "%s", cp);
}


x86 assembly (clang, -O0):
<get_subclass_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
cmpq   $0x1,-0x18(%rbp)
jae    114d <get_subclass_string+0x2d>
movl   $0x0,-0x4(%rbp)
jmp    1194 <get_subclass_string+0x74>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1040 <names_subclass@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1179 <get_subclass_string+0x59>
movl   $0x0,-0x4(%rbp)
jmp    1194 <get_subclass_string+0x74>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rcx
lea    0xe74(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_subclass_string>:
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     115c <get_subclass_string+0x3c>
mov    %rsi,%rbx
mov    %rdi,%r14
movb   $0x0,(%rdi)
mov    %edx,%edi
mov    %ecx,%esi
call   1040 <names_subclass@plt>
test   %rax,%rax
je     115c <get_subclass_string+0x3c>
lea    0xeb9(%rip),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <snprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i32 @get_subclass_string(i8* %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %6
store i64 %1, i64* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%11 = load i64, i64* %7
%12 = icmp ult i64 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %4
store i32 0, i32* %5
br label %26
14: ; preds = %4
%15 = load i8*, i8** %6
store i8 0, i8* %15
%16 = load i32, i32* %8
%17 = load i32, i32* %9
%18 = call i8* @names_subclass(i32 %16, i32 %17)
store i8* %18, i8** %10
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %14
store i32 0, i32* %5
br label %26
21: ; preds = %14
%22 = load i8*, i8** %6
%23 = load i64, i64* %7
%24 = load i8*, i8** %10
%25 = call i32 @snprintf(i8* %22, i64 %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %24)
store i32 %25, i32* %5
br label %26
26: ; preds = %21, %20, %13
%27 = load i32, i32* %5
ret i32 %27
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @get_subclass_string(i8* %0, i64 %1, i32 %2, i32 %3) {
%5 = icmp eq i64 %1, 0
br i1 %5, label %11, label %6
6: ; preds = %4
store i8 0, i8* %0
%7 = tail call i8* @names_subclass(i32 %2, i32 %3)
%8 = icmp eq i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %11
11: ; preds = %6, %4, %9
%12 = phi i32 [ %10, %9 ], [ 0, %4 ], [ 0, %6 ]
ret i32 %12
}