#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 RandomListNode {
  int dummy;
};

/* Variables and functions */
struct RandomListNode *copyRandomList(struct RandomListNode *);
int /*<<< orphan*/ initList(struct RandomListNode **, int);
int /*<<< orphan*/ printList(struct RandomListNode *);
int /*<<< orphan*/ puts(char *);
int main(int argc, char **argv) {
  struct RandomListNode *head = NULL;
  struct RandomListNode *head2 = NULL;
  initList(&head, 10);
  puts("=========== head ===========");
  printList(head);
  head2 = copyRandomList(head);
  puts("=========== head ===========");
  printList(head);
  puts("=========== head2 ===========");
  printList(head2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
mov    $0xa,%esi
call   1050 <initList@plt>
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
mov    -0x18(%rbp),%rdi
call   1060 <printList@plt>
mov    -0x18(%rbp),%rdi
call   1040 <copyRandomList@plt>
mov    %rax,-0x20(%rbp)
lea    0xe63(%rip),%rdi
call   1030 <puts@plt>
mov    -0x18(%rbp),%rdi
call   1060 <printList@plt>
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
mov    -0x20(%rbp),%rdi
call   1060 <printList@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movq   $0x0,(%rsp)
mov    %rsp,%rdi
mov    $0xa,%esi
call   1050 <initList@plt>
lea    0xea0(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    (%rsp),%rdi
call   1060 <printList@plt>
mov    (%rsp),%rdi
call   1040 <copyRandomList@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <puts@plt>
mov    (%rsp),%rdi
call   1060 <printList@plt>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1060 <printList@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.RandomListNode = type { i32 }
@.str = [29 x i8] c"=========== head ===========\00"
@.str.1 = [30 x i8] c"=========== head2 ===========\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.RandomListNode*
%7 = alloca %struct.RandomListNode*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.RandomListNode* null, %struct.RandomListNode** %6
store %struct.RandomListNode* null, %struct.RandomListNode** %7
%8 = call i32 @initList(%struct.RandomListNode** %6, i32 10)
%9 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%10 = load %struct.RandomListNode*, %struct.RandomListNode** %6
%11 = call i32 @printList(%struct.RandomListNode* %10)
%12 = load %struct.RandomListNode*, %struct.RandomListNode** %6
%13 = call %struct.RandomListNode* @copyRandomList(%struct.RandomListNode* %12)
store %struct.RandomListNode* %13, %struct.RandomListNode** %7
%14 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%15 = load %struct.RandomListNode*, %struct.RandomListNode** %6
%16 = call i32 @printList(%struct.RandomListNode* %15)
%17 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%18 = load %struct.RandomListNode*, %struct.RandomListNode** %7
%19 = call i32 @printList(%struct.RandomListNode* %18)
ret i32 0
}

LLVM IR (-O2):
%struct.RandomListNode = type { i32 }
@.str = [29 x i8] c"=========== head ===========\00"
@.str.1 = [30 x i8] c"=========== head2 ===========\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.RandomListNode*
%4 = bitcast %struct.RandomListNode** %3 to i8*
store %struct.RandomListNode* null, %struct.RandomListNode** %3
%5 = call i32 @initList(%struct.RandomListNode** %3, i32 10)
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%7 = load %struct.RandomListNode*, %struct.RandomListNode** %3
%8 = call i32 @printList(%struct.RandomListNode* %7)
%9 = load %struct.RandomListNode*, %struct.RandomListNode** %3
%10 = call %struct.RandomListNode* @copyRandomList(%struct.RandomListNode* %9)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%12 = load %struct.RandomListNode*, %struct.RandomListNode** %3
%13 = call i32 @printList(%struct.RandomListNode* %12)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @printList(%struct.RandomListNode* %10)
ret i32 0
}