#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 canFinish(int, int **, int, int);
void *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int **prerequisites = malloc(4 * sizeof(int *));
  prerequisites[0] = malloc(2 * sizeof(int));
  prerequisites[1] = malloc(2 * sizeof(int));
  prerequisites[2] = malloc(2 * sizeof(int));
  prerequisites[3] = malloc(2 * sizeof(int));
  prerequisites[0][0] = 0;
  prerequisites[0][1] = 1;
  prerequisites[1][0] = 3;
  prerequisites[1][1] = 2;
  prerequisites[2][0] = 1;
  prerequisites[2][1] = 3;
  prerequisites[3][0] = 3;
  prerequisites[3][1] = 1;
  printf("%d\n", canFinish(4, prerequisites, 4, 2));
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x20,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x1,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x3,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x2,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x3,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x3,(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x1,0x4(%rax)
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
mov    $0x2,%ecx
mov    %edx,%edi
call   1040 <canFinish@plt>
mov    %eax,%esi
lea    0xdd0(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x20,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    %rax,(%rbx)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %rax,0x8(%rbx)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    %rax,0x10(%rbx)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,0x18(%rbx)
movabs $0x100000000,%rcx
mov    %rcx,(%r14)
movabs $0x200000003,%rcx
mov    %rcx,(%r15)
movabs $0x300000001,%rcx
mov    %rcx,(%r12)
movabs $0x100000003,%rcx
mov    %rcx,(%rax)
mov    $0x4,%edi
mov    %rbx,%rsi
mov    $0x4,%edx
mov    $0x2,%ecx
call   1040 <canFinish@plt>
lea    0xe28(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32**
store i32 0, i32* %1
%3 = call i8* @malloc(i32 32)
%4 = bitcast i8* %3 to i32**
store i32** %4, i32*** %2
%5 = call i8* @malloc(i32 8)
%6 = bitcast i8* %5 to i32*
%7 = load i32**, i32*** %2
%8 = getelementptr inbounds i32*, i32** %7, i64 0
store i32* %6, i32** %8
%9 = call i8* @malloc(i32 8)
%10 = bitcast i8* %9 to i32*
%11 = load i32**, i32*** %2
%12 = getelementptr inbounds i32*, i32** %11, i64 1
store i32* %10, i32** %12
%13 = call i8* @malloc(i32 8)
%14 = bitcast i8* %13 to i32*
%15 = load i32**, i32*** %2
%16 = getelementptr inbounds i32*, i32** %15, i64 2
store i32* %14, i32** %16
%17 = call i8* @malloc(i32 8)
%18 = bitcast i8* %17 to i32*
%19 = load i32**, i32*** %2
%20 = getelementptr inbounds i32*, i32** %19, i64 3
store i32* %18, i32** %20
%21 = load i32**, i32*** %2
%22 = getelementptr inbounds i32*, i32** %21, i64 0
%23 = load i32*, i32** %22
%24 = getelementptr inbounds i32, i32* %23, i64 0
store i32 0, i32* %24
%25 = load i32**, i32*** %2
%26 = getelementptr inbounds i32*, i32** %25, i64 0
%27 = load i32*, i32** %26
%28 = getelementptr inbounds i32, i32* %27, i64 1
store i32 1, i32* %28
%29 = load i32**, i32*** %2
%30 = getelementptr inbounds i32*, i32** %29, i64 1
%31 = load i32*, i32** %30
%32 = getelementptr inbounds i32, i32* %31, i64 0
store i32 3, i32* %32
%33 = load i32**, i32*** %2
%34 = getelementptr inbounds i32*, i32** %33, i64 1
%35 = load i32*, i32** %34
%36 = getelementptr inbounds i32, i32* %35, i64 1
store i32 2, i32* %36
%37 = load i32**, i32*** %2
%38 = getelementptr inbounds i32*, i32** %37, i64 2
%39 = load i32*, i32** %38
%40 = getelementptr inbounds i32, i32* %39, i64 0
store i32 1, i32* %40
%41 = load i32**, i32*** %2
%42 = getelementptr inbounds i32*, i32** %41, i64 2
%43 = load i32*, i32** %42
%44 = getelementptr inbounds i32, i32* %43, i64 1
store i32 3, i32* %44
%45 = load i32**, i32*** %2
%46 = getelementptr inbounds i32*, i32** %45, i64 3
%47 = load i32*, i32** %46
%48 = getelementptr inbounds i32, i32* %47, i64 0
store i32 3, i32* %48
%49 = load i32**, i32*** %2
%50 = getelementptr inbounds i32*, i32** %49, i64 3
%51 = load i32*, i32** %50
%52 = getelementptr inbounds i32, i32* %51, i64 1
store i32 1, i32* %52
%53 = load i32**, i32*** %2
%54 = call i32 @canFinish(i32 4, i32** %53, i32 4, i32 2)
%55 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %54)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(32) i8* @malloc(i32 32)
%2 = bitcast i8* %1 to i32**
%3 = tail call dereferenceable_or_null(8) i8* @malloc(i32 8)
%4 = bitcast i8* %1 to i8**
store i8* %3, i8** %4
%5 = tail call dereferenceable_or_null(8) i8* @malloc(i32 8)
%6 = getelementptr inbounds i32*, i32** %2, i64 1
%7 = bitcast i32** %6 to i8**
store i8* %5, i8** %7
%8 = tail call dereferenceable_or_null(8) i8* @malloc(i32 8)
%9 = getelementptr inbounds i32*, i32** %2, i64 2
%10 = bitcast i32** %9 to i8**
store i8* %8, i8** %10
%11 = tail call dereferenceable_or_null(8) i8* @malloc(i32 8)
%12 = getelementptr inbounds i32*, i32** %2, i64 3
%13 = bitcast i32** %12 to i8**
store i8* %11, i8** %13
%14 = bitcast i8* %3 to i32*
store i32 0, i32* %14
%15 = getelementptr inbounds i32, i32* %14, i64 1
store i32 1, i32* %15
%16 = bitcast i8* %5 to i32*
store i32 3, i32* %16
%17 = getelementptr inbounds i32, i32* %16, i64 1
store i32 2, i32* %17
%18 = bitcast i8* %8 to i32*
store i32 1, i32* %18
%19 = getelementptr inbounds i32, i32* %18, i64 1
store i32 3, i32* %19
%20 = bitcast i8* %11 to i32*
store i32 3, i32* %20
%21 = getelementptr inbounds i32, i32* %20, i64 1
store i32 1, i32* %21
%22 = tail call i32 @canFinish(i32 4, i32** %2, i32 4, i32 2)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
ret i32 0
}