#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void callback(void *closure, int event, const unsigned char *info_hash,
              const void *data, size_t data_len) {
  if (event == 3)
    printf("Search done.\n");
  else if (event == 4)
    printf("IPv6 search done.\n");
  else if (event == 1)
    printf("Received %d values.\n", (int)(data_len / 6));
  else if (event == 2)
    printf("Received %d IPv6 values.\n", (int)(data_len / 18));
  else
    printf("Unknown DHT event %d.\n", event);
}


x86 assembly (clang, -O0):
<callback>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
cmpl   $0x3,-0xc(%rbp)
jne    1148 <callback+0x38>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11df <callback+0xcf>
cmpl   $0x4,-0xc(%rbp)
jne    1165 <callback+0x55>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11da <callback+0xca>
cmpl   $0x1,-0xc(%rbp)
jne    1192 <callback+0x82>
mov    -0x28(%rbp),%rax
mov    $0x6,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d5 <callback+0xc5>
cmpl   $0x2,-0xc(%rbp)
jne    11bf <callback+0xaf>
mov    -0x28(%rbp),%rax
mov    $0x12,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d0 <callback+0xc0>
mov    -0xc(%rbp),%esi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d5 <callback+0xc5>
jmp    11da <callback+0xca>
jmp    11df <callback+0xcf>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<callback>:
lea    -0x1(%rsi),%eax
cmp    $0x3,%eax
ja     1155 <callback+0x35>
lea    0xed1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movabs $0xaaaaaaaaaaaaaaab,%rcx
aa aa aa
mov    %r8,%rax
mul    %rcx
shr    $0x2,%rdx
lea    0xebd(%rip),%rdi
jmp    117e <callback+0x5e>
lea    0xee3(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
movabs $0xe38e38e38e38e38f,%rcx
38 8e e3
mov    %r8,%rax
mul    %rcx
shr    $0x4,%rdx
lea    0xea7(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
jmp    1040 <printf@plt>
lea    0xeda(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xebc(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"Search done.\0A\00"
@.str.1 = [19 x i8] c"IPv6 search done.\0A\00"
@.str.2 = [21 x i8] c"Received %d values.\0A\00"
@.str.3 = [26 x i8] c"Received %d IPv6 values.\0A\00"
@.str.4 = [23 x i8] c"Unknown DHT event %d.\0A\00"
define void @callback(i8* %0, i32 %1, i8* %2, i8* %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i64 %4, i64* %10
%11 = load i32, i32* %7
%12 = icmp eq i32 %11, 3
br i1 %12, label %13, label %15
13: ; preds = %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %42
15: ; preds = %5
%16 = load i32, i32* %7
%17 = icmp eq i32 %16, 4
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %41
20: ; preds = %15
%21 = load i32, i32* %7
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i64, i64* %10
%25 = udiv i64 %24, 6
%26 = trunc i64 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %40
28: ; preds = %20
%29 = load i32, i32* %7
%30 = icmp eq i32 %29, 2
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = load i64, i64* %10
%33 = udiv i64 %32, 18
%34 = trunc i64 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %39
36: ; preds = %28
%37 = load i32, i32* %7
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %36, %31
br label %40
40: ; preds = %39, %23
br label %41
41: ; preds = %40, %18
br label %42
42: ; preds = %41, %13
ret void
}

LLVM IR (-O2):
@.str.2 = [21 x i8] c"Received %d values.\0A\00"
@.str.3 = [26 x i8] c"Received %d IPv6 values.\0A\00"
@.str.4 = [23 x i8] c"Unknown DHT event %d.\0A\00"
@str = [18 x i8] c"IPv6 search done.\00"
@str.5 = [13 x i8] c"Search done.\00"
define void @callback(i8* nocapture readnone %0, i32 %1, i8* nocapture readnone %2, i8* nocapture readnone %3, i64 %4) {
switch i32 %1, label %18 [
i32 3, label %6
i32 4, label %8
i32 1, label %10
i32 2, label %14
]
6: ; preds = %5
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.5, i64 0, i64 0))
br label %20
8: ; preds = %5
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %20
10: ; preds = %5
%11 = udiv i64 %4, 6
%12 = trunc i64 %11 to i32
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %12)
br label %20
14: ; preds = %5
%15 = udiv i64 %4, 18
%16 = trunc i64 %15 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %16)
br label %20
18: ; preds = %5
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %1)
br label %20
20: ; preds = %8, %14, %18, %10, %6
ret void
}