#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 */
struct ListNode {
  int dummy;
};

/* Variables and functions */
struct ListNode *newNode(int, struct ListNode *);
int numComponents(struct ListNode *, int *, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  struct ListNode *l1;
  int G[] = {0, 3, 1, 4};
  l1 = newNode(0, newNode(1, newNode(2, newNode(3, newNode(4, NULL)))));
  printf("%d\n", numComponents(l1, G, 4));
  int G1[] = {0, 3, 1};
  l1 = newNode(0, newNode(1, newNode(2, newNode(3, NULL))));
  printf("%d\n", numComponents(l1, G1, 4));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x4,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <newNode@plt>
mov    %rax,%rsi
mov    $0x3,%edi
call   1050 <newNode@plt>
mov    %rax,%rsi
mov    $0x2,%edi
call   1050 <newNode@plt>
mov    %rax,%rsi
mov    $0x1,%edi
call   1050 <newNode@plt>
mov    %rax,%rsi
xor    %edi,%edi
call   1050 <newNode@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1030 <numComponents@plt>
mov    %eax,%esi
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
mov    0xe5c(%rip),%rax
mov    %rax,-0x2c(%rbp)
mov    0xe5a(%rip),%eax
mov    %eax,-0x24(%rbp)
mov    $0x3,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <newNode@plt>
mov    %rax,%rsi
mov    $0x2,%edi
call   1050 <newNode@plt>
mov    %rax,%rsi
mov    $0x1,%edi
call   1050 <newNode@plt>
mov    %rax,%rsi
xor    %edi,%edi
call   1050 <newNode@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
mov    $0x4,%edx
call   1030 <numComponents@plt>
mov    %eax,%esi
lea    0xdfa(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    $0x4,%edi
xor    %esi,%esi
call   1050 <newNode@plt>
mov    $0x3,%edi
mov    %rax,%rsi
call   1050 <newNode@plt>
mov    $0x2,%edi
mov    %rax,%rsi
call   1050 <newNode@plt>
mov    $0x1,%edi
mov    %rax,%rsi
call   1050 <newNode@plt>
xor    %edi,%edi
mov    %rax,%rsi
call   1050 <newNode@plt>
lea    0x10(%rsp),%rsi
mov    %rax,%rdi
mov    $0x4,%edx
call   1030 <numComponents@plt>
lea    0xe79(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    0xe75(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xe62(%rip),%rax
mov    %rax,(%rsp)
mov    $0x3,%edi
xor    %esi,%esi
call   1050 <newNode@plt>
mov    $0x2,%edi
mov    %rax,%rsi
call   1050 <newNode@plt>
mov    $0x1,%edi
mov    %rax,%rsi
call   1050 <newNode@plt>
xor    %edi,%edi
mov    %rax,%rsi
call   1050 <newNode@plt>
mov    %rsp,%rsi
mov    %rax,%rdi
mov    $0x4,%edx
call   1030 <numComponents@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.ListNode = type { i32 }
@__const.main.G = [4 x i32] [i32 0, i32 3, i32 1, i32 4]
@.str = [4 x i8] c"%d\0A\00"
@__const.main.G1 = [3 x i32] [i32 0, i32 3, i32 1]
define i32 @main() {
%1 = alloca %struct.ListNode*
%2 = alloca [4 x i32]
%3 = alloca [3 x i32]
%4 = bitcast [4 x i32]* %2 to i8*
%5 = call %struct.ListNode* @newNode(i32 4, %struct.ListNode* null)
%6 = call %struct.ListNode* @newNode(i32 3, %struct.ListNode* %5)
%7 = call %struct.ListNode* @newNode(i32 2, %struct.ListNode* %6)
%8 = call %struct.ListNode* @newNode(i32 1, %struct.ListNode* %7)
%9 = call %struct.ListNode* @newNode(i32 0, %struct.ListNode* %8)
store %struct.ListNode* %9, %struct.ListNode** %1
%10 = load %struct.ListNode*, %struct.ListNode** %1
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%12 = call i32 @numComponents(%struct.ListNode* %10, i32* %11, i32 4)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = bitcast [3 x i32]* %3 to i8*
%15 = call %struct.ListNode* @newNode(i32 3, %struct.ListNode* null)
%16 = call %struct.ListNode* @newNode(i32 2, %struct.ListNode* %15)
%17 = call %struct.ListNode* @newNode(i32 1, %struct.ListNode* %16)
%18 = call %struct.ListNode* @newNode(i32 0, %struct.ListNode* %17)
store %struct.ListNode* %18, %struct.ListNode** %1
%19 = load %struct.ListNode*, %struct.ListNode** %1
%20 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%21 = call i32 @numComponents(%struct.ListNode* %19, i32* %20, i32 4)
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
ret i32 0
}

LLVM IR (-O2):
%struct.ListNode = type { i32 }
@__const.main.G = [4 x i32] [i32 0, i32 3, i32 1, i32 4]
@.str = [4 x i8] c"%d\0A\00"
@__const.main.G1 = [3 x i32] [i32 0, i32 3, i32 1]
define i32 @main() {
%1 = alloca [4 x i32]
%2 = alloca [3 x i32]
%3 = bitcast [4 x i32]* %1 to i8*
%4 = tail call %struct.ListNode* @newNode(i32 4, %struct.ListNode* null)
%5 = tail call %struct.ListNode* @newNode(i32 3, %struct.ListNode* %4)
%6 = tail call %struct.ListNode* @newNode(i32 2, %struct.ListNode* %5)
%7 = tail call %struct.ListNode* @newNode(i32 1, %struct.ListNode* %6)
%8 = tail call %struct.ListNode* @newNode(i32 0, %struct.ListNode* %7)
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%10 = call i32 @numComponents(%struct.ListNode* %8, i32* %9, i32 4)
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = bitcast [3 x i32]* %2 to i8*
%13 = call %struct.ListNode* @newNode(i32 3, %struct.ListNode* null)
%14 = call %struct.ListNode* @newNode(i32 2, %struct.ListNode* %13)
%15 = call %struct.ListNode* @newNode(i32 1, %struct.ListNode* %14)
%16 = call %struct.ListNode* @newNode(i32 0, %struct.ListNode* %15)
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%18 = call i32 @numComponents(%struct.ListNode* %16, i32* %17, i32 4)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
ret i32 0
}