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

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
int /*<<< orphan*/ writeint(int);
void typechecker(int lineno, const void *destVFT, void *newObj) {
  char msg[] = "Runtime error: mismatched types on line ";
  if (newObj == NULL) {
    return;
  }
  int newObjVFT = *((int *)newObj);
  if ((int)destVFT == newObjVFT) {
    return;
  } else if (newObjVFT == 0) {
    write(1, msg, sizeof(msg) - 1);
    writeint(lineno);
    exit(0);
  } else {
    typechecker(lineno, destVFT, (void *)newObjVFT);
  }
}


x86 assembly (clang, -O0):
<typechecker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe92(%rip),%rsi
mov    $0x29,%edx
call   1050 <memcpy@plt>
cmpq   $0x0,-0x18(%rbp)
jne    1188 <typechecker+0x38>
jmp    11e4 <typechecker+0x94>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x54(%rbp),%eax
jne    11a3 <typechecker+0x53>
jmp    11e4 <typechecker+0x94>
cmpl   $0x0,-0x54(%rbp)
jne    11cf <typechecker+0x7f>
lea    -0x50(%rbp),%rsi
mov    $0x1,%edi
mov    $0x28,%edx
call   1040 <write@plt>
mov    -0x4(%rbp),%edi
call   1030 <writeint@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movslq -0x54(%rbp),%rdx
call   1070 <typechecker@plt>
jmp    11e4 <typechecker+0x94>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<typechecker>:
push   %rbx
sub    $0x30,%rsp
movups 0xecd(%rip),%xmm0
movups %xmm0,0x19(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,(%rsp)
test   %rdx,%rdx
je     1174 <typechecker+0x34>
movslq (%rdx),%rdx
cmp    %esi,%edx
jne    117a <typechecker+0x3a>
add    $0x30,%rsp
pop    %rbx
ret
mov    %edi,%ebx
test   %edx,%edx
je     118c <typechecker+0x4c>
mov    %ebx,%edi
add    $0x30,%rsp
pop    %rbx
jmp    1060 <typechecker@plt>
mov    %rsp,%rsi
mov    $0x1,%edi
mov    $0x28,%edx
call   1040 <write@plt>
mov    %ebx,%edi
call   1030 <writeint@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@__const.typechecker.msg = [41 x i8] c"Runtime error: mismatched types on line \00"
define void @typechecker(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [41 x i8]
%8 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = bitcast [41 x i8]* %7 to i8*
%10 = load i8*, i8** %6
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %3
br label %38
13: ; preds = %3
%14 = load i8*, i8** %6
%15 = bitcast i8* %14 to i32*
%16 = load i32, i32* %15
store i32 %16, i32* %8
%17 = load i8*, i8** %5
%18 = ptrtoint i8* %17 to i32
%19 = load i32, i32* %8
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %13
br label %38
22: ; preds = %13
%23 = load i32, i32* %8
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = getelementptr inbounds [41 x i8], [41 x i8]* %7, i64 0, i64 0
%27 = call i32 @write(i32 1, i8* %26, i32 40)
%28 = load i32, i32* %4
%29 = call i32 @writeint(i32 %28)
%30 = call i32 @exit(i32 0)
unreachable
31: ; preds = %22
%32 = load i32, i32* %4
%33 = load i8*, i8** %5
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = inttoptr i64 %35 to i8*
br label %37
37: ; preds = %31
br label %38
38: ; preds = %12, %21, %37
ret void
}

LLVM IR (-O2):
@__const.typechecker.msg = [41 x i8] c"Runtime error: mismatched types on line \00"
define void @typechecker(i32 %0, i8* %1, i8* %2) {
%4 = alloca [41 x i8]
%5 = getelementptr inbounds [41 x i8], [41 x i8]* %4, i64 0, i64 0
%6 = icmp eq i8* %2, null
br i1 %6, label %22, label %7
7: ; preds = %3
%8 = bitcast i8* %2 to i32*
%9 = load i32, i32* %8
%10 = ptrtoint i8* %1 to i64
%11 = trunc i64 %10 to i32
%12 = icmp eq i32 %9, %11
br i1 %12, label %22, label %13
13: ; preds = %7
%14 = icmp eq i32 %9, 0
br i1 %14, label %15, label %19
15: ; preds = %13
%16 = call i32 @write(i32 1, i8* %5, i32 40)
%17 = tail call i32 @writeint(i32 %0)
%18 = tail call i32 @exit(i32 0)
unreachable
19: ; preds = %13
%20 = sext i32 %9 to i64
%21 = inttoptr i64 %20 to i8*
tail call void @typechecker(i32 %0, i8* %1, i8* %21)
br label %22
22: ; preds = %19, %7, %3
ret void
}