int run_test() {
  int (*check_type)() = resolve_symbol("kfun:check_type()");
  int (*check_not_type)() = resolve_symbol("kfun:check_not_type()");
  int (*check_interface)() = resolve_symbol("kfun:check_interface()");
  if (!check_type())
    return 1;
  if (!check_not_type())
    return 1;
  if (!check_interface())
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<run_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <resolve_symbol@plt>
cltq
mov    %rax,-0x10(%rbp)
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <resolve_symbol@plt>
cltq
mov    %rax,-0x18(%rbp)
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <resolve_symbol@plt>
cltq
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   *-0x10(%rbp)
cmp    $0x0,%eax
jne    116e <run_test+0x5e>
movl   $0x1,-0x4(%rbp)
jmp    11a9 <run_test+0x99>
mov    $0x0,%al
call   *-0x18(%rbp)
cmp    $0x0,%eax
jne    1188 <run_test+0x78>
movl   $0x1,-0x4(%rbp)
jmp    11a9 <run_test+0x99>
mov    $0x0,%al
call   *-0x20(%rbp)
cmp    $0x0,%eax
jne    11a2 <run_test+0x92>
movl   $0x1,-0x4(%rbp)
jmp    11a9 <run_test+0x99>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_test>:
push   %rbp
push   %r14
push   %rbx
lea    0xee5(%rip),%rdi
xor    %eax,%eax
call   1030 <resolve_symbol@plt>
movslq %eax,%rbx
lea    0xee6(%rip),%rdi
xor    %eax,%eax
call   1030 <resolve_symbol@plt>
mov    %eax,%ebp
lea    0xeec(%rip),%rdi
xor    %eax,%eax
call   1030 <resolve_symbol@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   *%rbx
mov    $0x1,%ebx
test   %eax,%eax
je     116c <run_test+0x5c>
movslq %ebp,%rcx
xor    %eax,%eax
call   *%rcx
test   %eax,%eax
je     116c <run_test+0x5c>
movslq %r14d,%rcx
xor    %eax,%eax
call   *%rcx
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"kfun:check_type()\00"
@.str.1 = [22 x i8] c"kfun:check_not_type()\00"
@.str.2 = [23 x i8] c"kfun:check_interface()\00"
define i32 @run_test() {
%1 = alloca i32
%2 = alloca i32 (...)*
%3 = alloca i32 (...)*
%4 = alloca i32 (...)*
%5 = call i32 (i8*, ...) bitcast (i32 (...)* @resolve_symbol to i32 (i8*, ...)*)(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i32 (...)*
store i32 (...)* %7, i32 (...)** %2
%8 = call i32 (i8*, ...) bitcast (i32 (...)* @resolve_symbol to i32 (i8*, ...)*)(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i32 (...)*
store i32 (...)* %10, i32 (...)** %3
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @resolve_symbol to i32 (i8*, ...)*)(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i32 (...)*
store i32 (...)* %13, i32 (...)** %4
%14 = load i32 (...)*, i32 (...)** %2
%15 = call i32 (...) %14()
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %0
store i32 1, i32* %1
br label %29
18: ; preds = %0
%19 = load i32 (...)*, i32 (...)** %3
%20 = call i32 (...) %19()
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %18
store i32 1, i32* %1
br label %29
23: ; preds = %18
%24 = load i32 (...)*, i32 (...)** %4
%25 = call i32 (...) %24()
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %23
store i32 1, i32* %1
br label %29
28: ; preds = %23
store i32 0, i32* %1
br label %29
29: ; preds = %28, %27, %22, %17
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [18 x i8] c"kfun:check_type()\00"
@.str.1 = [22 x i8] c"kfun:check_not_type()\00"
@.str.2 = [23 x i8] c"kfun:check_interface()\00"
define i32 @run_test() {
%1 = tail call i32 (i8*, ...) bitcast (i32 (...)* @resolve_symbol to i32 (i8*, ...)*)(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%2 = sext i32 %1 to i64
%3 = inttoptr i64 %2 to i32 (...)*
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @resolve_symbol to i32 (i8*, ...)*)(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) bitcast (i32 (...)* @resolve_symbol to i32 (i8*, ...)*)(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i32 (...)*
%8 = tail call i32 (...) %3()
%9 = icmp eq i32 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %0
%11 = sext i32 %4 to i64
%12 = inttoptr i64 %11 to i32 (...)*
%13 = tail call i32 (...) %12()
%14 = icmp eq i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %10
%16 = tail call i32 (...) %7()
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %15, %10, %0
%20 = phi i32 [ 1, %0 ], [ 1, %10 ], [ %18, %15 ]
ret i32 %20
}