#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*/ abort();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, void *, void *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int ptrToInt(void *ptr) {
  int int32_handle = (int)(intptr_t)ptr;
  if (!((intptr_t)int32_handle == (intptr_t)ptr)) {
    printf("%s:%d: error: assertion failed: %s\n",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/sheijk/Zomp/refs/heads/master/source/"
           "runtime.c",
           259, "(intptr_t)int32_handle == (intptr_t)ptr");
    printf("32-bit: %p, 64-bit: %p\n", (void *)(intptr_t)int32_handle, ptr);
    ;
    fflush(stdout);
    fflush(stderr);
    abort();
  };
  return int32_handle;
}


x86 assembly (clang, -O0):
<ptrToInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rax
mov    -0x8(%rbp),%rcx
cmp    %rcx,%rax
je     11ae <ptrToInt+0x7e>
lea    0xea5(%rip),%rdi
lea    0xec2(%rip),%rsi
mov    $0x103,%edx
lea    0xf3f(%rip),%rcx
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0xc(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xf51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptrToInt>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movslq %ebx,%r14
cmp    %rdi,%r14
jne    1149 <ptrToInt+0x19>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xeb0(%rip),%rdi
lea    0xecd(%rip),%rsi
lea    0xf4f(%rip),%rcx
mov    $0x103,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf64(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"%s:%d: error: assertion failed: %s\0A\00"
@.str.1 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/sheijk/Zomp/refs/heads/master/source/runtime.c\00"
@.str.2 = [40 x i8] c"(intptr_t)int32_handle == (intptr_t)ptr\00"
@.str.3 = [24 x i8] c"32-bit: %p, 64-bit: %p\0A\00"
@stdout = global i32 0
@stderr = global i32 0
define i32 @ptrToInt(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = ptrtoint i8* %4 to i64
%6 = trunc i64 %5 to i32
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = load i8*, i8** %2
%10 = ptrtoint i8* %9 to i64
%11 = icmp eq i64 %8, %10
br i1 %11, label %24, label %12
12: ; preds = %1
%13 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i8* inttoptr (i64 259 to i8*), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i8*
%17 = load i8*, i8** %2
%18 = call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %16, i8* %17)
%19 = load i32, i32* @stdout
%20 = call i32 @fflush(i32 %19)
%21 = load i32, i32* @stderr
%22 = call i32 @fflush(i32 %21)
%23 = call i32 (...) @abort()
unreachable
24: ; preds = %1
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [36 x i8] c"%s:%d: error: assertion failed: %s\0A\00"
@.str.1 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/sheijk/Zomp/refs/heads/master/source/runtime.c\00"
@.str.2 = [40 x i8] c"(intptr_t)int32_handle == (intptr_t)ptr\00"
@.str.3 = [24 x i8] c"32-bit: %p, 64-bit: %p\0A\00"
@stdout = global i32 0
@stderr = global i32 0
define i32 @ptrToInt(i8* %0) {
%2 = ptrtoint i8* %0 to i64
%3 = shl i64 %2, 32
%4 = ashr exact i64 %3, 32
%5 = icmp eq i64 %4, %2
br i1 %5, label %15, label %6
6: ; preds = %1
%7 = tail call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i8* inttoptr (i64 259 to i8*), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%8 = inttoptr i64 %4 to i8*
%9 = tail call i32 (i8*, i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %8, i8* %0)
%10 = load i32, i32* @stdout
%11 = tail call i32 @fflush(i32 %10)
%12 = load i32, i32* @stderr
%13 = tail call i32 @fflush(i32 %12)
%14 = tail call i32 (...) @abort()
unreachable
15: ; preds = %1
%16 = trunc i64 %2 to i32
ret i32 %16
}