void search_by_type(int devfd, int gen_class, char *class_name) {
  int ret, i;
  const char *nodename;
  info(2, "%s: searching for type %d (%s)\n", __FUNCTION__, gen_class,
       class_name);
  for (i = 1; i <= 232; i++) {
    ret = send_then_recv(devfd, 'F', ">?FI0,%d,0,%d", gen_class, i);
    if (ret <= 0)
      break;
    nodename = nodeid_to_nodename(ret);
    if (nodename)
      info(1,
           "%03d ('%s'): %s "
           "(generic class %d, instance %d)\n",
           ret, nodename, class_name, gen_class, i);
    else
      info(1,
           "%03d (unnamed): %s "
           "(generic class %d, instance %d)\n",
           ret, class_name, gen_class, i);
  }
}


x86 assembly (clang, -O0):
<search_by_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%ecx
mov    -0x10(%rbp),%r8
mov    $0x2,%edi
lea    0xeab(%rip),%rsi
lea    0xec4(%rip),%rdx
mov    $0x0,%al
call   1050 <info@plt>
movl   $0x1,-0x18(%rbp)
cmpl   $0xe8,-0x18(%rbp)
jg     1223 <search_by_type+0xf3>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    $0x46,%esi
lea    0xea2(%rip),%rdx
mov    $0x0,%al
call   1040 <send_then_recv@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     11a6 <search_by_type+0x76>
jmp    1223 <search_by_type+0xf3>
mov    -0x14(%rbp),%edi
mov    $0x0,%al
call   1030 <nodeid_to_nodename@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ee <search_by_type+0xbe>
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x8(%rbp),%r9d
mov    -0x18(%rbp),%eax
mov    $0x1,%edi
lea    0xe5e(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1050 <info@plt>
jmp    1210 <search_by_type+0xe0>
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    $0x1,%edi
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1050 <info@plt>
jmp    1215 <search_by_type+0xe5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116a <search_by_type+0x3a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_by_type>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %esi,%ebp
mov    %edi,%r14d
lea    0xeb6(%rip),%rsi
lea    0xecf(%rip),%rdx
mov    $0x2,%edi
mov    %ebp,%ecx
mov    %r15,%r8
xor    %eax,%eax
call   1050 <info@plt>
mov    $0x1,%ebx
lea    0xec1(%rip),%r12
jmp    119a <search_by_type+0x6a>
mov    $0x1,%edi
lea    0xef2(%rip),%rsi
mov    %r13d,%edx
mov    %r15,%rcx
mov    %ebp,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
call   1050 <info@plt>
add    $0x1,%ebx
cmp    $0xe9,%ebx
je     11e9 <search_by_type+0xb9>
mov    %r14d,%edi
mov    $0x46,%esi
mov    %r12,%rdx
mov    %ebp,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1040 <send_then_recv@plt>
test   %eax,%eax
jle    11e9 <search_by_type+0xb9>
mov    %eax,%r13d
mov    %eax,%edi
xor    %eax,%eax
call   1030 <nodeid_to_nodename@plt>
test   %eax,%eax
je     1170 <search_by_type+0x40>
movslq %eax,%rcx
mov    %ebx,(%rsp)
mov    $0x1,%edi
lea    0xe66(%rip),%rsi
mov    %r13d,%edx
mov    %r15,%r8
mov    %ebp,%r9d
xor    %eax,%eax
call   1050 <info@plt>
jmp    118f <search_by_type+0x5f>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"%s: searching for type %d (%s)\0A\00"
@__FUNCTION__.search_by_type = [15 x i8] c"search_by_type\00"
@.str.1 = [14 x i8] c">?FI0,%d,0,%d\00"
@.str.2 = [49 x i8] c"%03d ('%s'): %s (generic class %d, instance %d)\0A\00"
@.str.3 = [52 x i8] c"%03d (unnamed): %s (generic class %d, instance %d)\0A\00"
define void @search_by_type(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%10 = load i32, i32* %5
%11 = load i8*, i8** %6
%12 = call i32 (i32, i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @info to i32 (i32, i8*, i8*, i32, i8*, ...)*)(i32 2, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__FUNCTION__.search_by_type, i64 0, i64 0), i32 %10, i8* %11)
store i32 1, i32* %8
br label %13
13: ; preds = %45, %3
%14 = load i32, i32* %8
%15 = icmp sle i32 %14, 232
br i1 %15, label %16, label %48
16: ; preds = %13
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = load i32, i32* %8
%20 = call i32 (i32, i32, i8*, i32, i32, ...) bitcast (i32 (...)* @send_then_recv to i32 (i32, i32, i8*, i32, i32, ...)*)(i32 %17, i32 70, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %19)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = icmp sle i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %16
br label %48
24: ; preds = %16
%25 = load i32, i32* %7
%26 = call i32 (i32, ...) bitcast (i32 (...)* @nodeid_to_nodename to i32 (i32, ...)*)(i32 %25)
%27 = sext i32 %26 to i64
%28 = inttoptr i64 %27 to i8*
store i8* %28, i8** %9
%29 = load i8*, i8** %9
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %38
31: ; preds = %24
%32 = load i32, i32* %7
%33 = load i8*, i8** %9
%34 = load i8*, i8** %6
%35 = load i32, i32* %5
%36 = load i32, i32* %8
%37 = call i32 (i32, i8*, i32, i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @info to i32 (i32, i8*, i32, i8*, i8*, i32, i32, ...)*)(i32 1, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %32, i8* %33, i8* %34, i32 %35, i32 %36)
br label %44
38: ; preds = %24
%39 = load i32, i32* %7
%40 = load i8*, i8** %6
%41 = load i32, i32* %5
%42 = load i32, i32* %8
%43 = call i32 (i32, i8*, i32, i8*, i32, i32, ...) bitcast (i32 (...)* @info to i32 (i32, i8*, i32, i8*, i32, i32, ...)*)(i32 1, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i32 %39, i8* %40, i32 %41, i32 %42)
br label %44
44: ; preds = %38, %31
br label %45
45: ; preds = %44
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
br label %13
48: ; preds = %23, %13
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"%s: searching for type %d (%s)\0A\00"
@__FUNCTION__.search_by_type = [15 x i8] c"search_by_type\00"
@.str.1 = [14 x i8] c">?FI0,%d,0,%d\00"
@.str.2 = [49 x i8] c"%03d ('%s'): %s (generic class %d, instance %d)\0A\00"
@.str.3 = [52 x i8] c"%03d (unnamed): %s (generic class %d, instance %d)\0A\00"
define void @search_by_type(i32 %0, i32 %1, i8* %2) {
%4 = tail call i32 (i32, i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @info to i32 (i32, i8*, i8*, i32, i8*, ...)*)(i32 2, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__FUNCTION__.search_by_type, i64 0, i64 0), i32 %1, i8* %2)
br label %5
5: ; preds = %3, %18
%6 = phi i32 [ 1, %3 ], [ %19, %18 ]
%7 = tail call i32 (i32, i32, i8*, i32, i32, ...) bitcast (i32 (...)* @send_then_recv to i32 (i32, i32, i8*, i32, i32, ...)*)(i32 %0, i32 70, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %6)
%8 = icmp slt i32 %7, 1
br i1 %8, label %21, label %9
9: ; preds = %5
%10 = tail call i32 (i32, ...) bitcast (i32 (...)* @nodeid_to_nodename to i32 (i32, ...)*)(i32 %7)
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = sext i32 %10 to i64
%14 = inttoptr i64 %13 to i8*
%15 = tail call i32 (i32, i8*, i32, i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @info to i32 (i32, i8*, i32, i8*, i8*, i32, i32, ...)*)(i32 1, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %7, i8* %14, i8* %2, i32 %1, i32 %6)
br label %18
16: ; preds = %9
%17 = tail call i32 (i32, i8*, i32, i8*, i32, i32, ...) bitcast (i32 (...)* @info to i32 (i32, i8*, i32, i8*, i32, i32, ...)*)(i32 1, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i32 %7, i8* %2, i32 %1, i32 %6)
br label %18
18: ; preds = %12, %16
%19 = add nuw nsw i32 %6, 1
%20 = icmp eq i32 %19, 233
br i1 %20, label %21, label %5
21: ; preds = %5, %18
ret void
}