#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 *createList(int *, int);
int /*<<< orphan*/ freeList(struct ListNode *);
int /*<<< orphan*/ printList(struct ListNode *);
int /*<<< orphan*/ printf(char *);
struct ListNode *reverseList(struct ListNode *);
int main(void) {
  struct ListNode *head = NULL;
  int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  for (int i = 1; i < 11; i++) {
    head = createList(arr, i);
    printList(head);
    head = reverseList(head);
    printList(head);
    freeList(head);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe7e(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
movl   $0x1,-0x44(%rbp)
cmpl   $0xb,-0x44(%rbp)
jge    11ef <main+0x8f>
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1060 <createList@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <printList@plt>
mov    -0x10(%rbp),%rdi
call   1070 <reverseList@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <printList@plt>
mov    -0x10(%rbp),%rdi
call   1030 <freeList@plt>
lea    0xe4c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1193 <main+0x33>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    0xec2(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xea6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe8a(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x1,%esi
call   1050 <createList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1060 <reverseList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1040 <freeList@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x2,%esi
call   1050 <createList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1060 <reverseList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1040 <freeList@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x3,%esi
call   1050 <createList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1060 <reverseList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1040 <freeList@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x4,%esi
call   1050 <createList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1060 <reverseList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1040 <freeList@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x5,%esi
call   1050 <createList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1060 <reverseList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1040 <freeList@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x6,%esi
call   1050 <createList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1060 <reverseList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1040 <freeList@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x7,%esi
call   1050 <createList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1060 <reverseList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1040 <freeList@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x8,%esi
call   1050 <createList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1060 <reverseList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1040 <freeList@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x9,%esi
call   1050 <createList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1060 <reverseList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1040 <freeList@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1050 <createList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1060 <reverseList@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <printList@plt>
mov    %rbx,%rdi
call   1040 <freeList@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.ListNode = type { i32 }
@__const.main.arr = [10 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10]
@.str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.ListNode*
%3 = alloca [10 x i32]
%4 = alloca i32
store i32 0, i32* %1
store %struct.ListNode* null, %struct.ListNode** %2
%5 = bitcast [10 x i32]* %3 to i8*
store i32 1, i32* %4
br label %6
6: ; preds = %22, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 11
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%11 = load i32, i32* %4
%12 = call %struct.ListNode* @createList(i32* %10, i32 %11)
store %struct.ListNode* %12, %struct.ListNode** %2
%13 = load %struct.ListNode*, %struct.ListNode** %2
%14 = call i32 @printList(%struct.ListNode* %13)
%15 = load %struct.ListNode*, %struct.ListNode** %2
%16 = call %struct.ListNode* @reverseList(%struct.ListNode* %15)
store %struct.ListNode* %16, %struct.ListNode** %2
%17 = load %struct.ListNode*, %struct.ListNode** %2
%18 = call i32 @printList(%struct.ListNode* %17)
%19 = load %struct.ListNode*, %struct.ListNode** %2
%20 = call i32 @freeList(%struct.ListNode* %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %9
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %6
25: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
%struct.ListNode = type { i32 }
@__const.main.arr = [10 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10]
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = call %struct.ListNode* @createList(i32* %3, i32 1)
%5 = call i32 @printList(%struct.ListNode* %4)
%6 = call %struct.ListNode* @reverseList(%struct.ListNode* %4)
%7 = call i32 @printList(%struct.ListNode* %6)
%8 = call i32 @freeList(%struct.ListNode* %6)
%9 = call i32 @putchar(i32 10)
%10 = call %struct.ListNode* @createList(i32* %3, i32 2)
%11 = call i32 @printList(%struct.ListNode* %10)
%12 = call %struct.ListNode* @reverseList(%struct.ListNode* %10)
%13 = call i32 @printList(%struct.ListNode* %12)
%14 = call i32 @freeList(%struct.ListNode* %12)
%15 = call i32 @putchar(i32 10)
%16 = call %struct.ListNode* @createList(i32* %3, i32 3)
%17 = call i32 @printList(%struct.ListNode* %16)
%18 = call %struct.ListNode* @reverseList(%struct.ListNode* %16)
%19 = call i32 @printList(%struct.ListNode* %18)
%20 = call i32 @freeList(%struct.ListNode* %18)
%21 = call i32 @putchar(i32 10)
%22 = call %struct.ListNode* @createList(i32* %3, i32 4)
%23 = call i32 @printList(%struct.ListNode* %22)
%24 = call %struct.ListNode* @reverseList(%struct.ListNode* %22)
%25 = call i32 @printList(%struct.ListNode* %24)
%26 = call i32 @freeList(%struct.ListNode* %24)
%27 = call i32 @putchar(i32 10)
%28 = call %struct.ListNode* @createList(i32* %3, i32 5)
%29 = call i32 @printList(%struct.ListNode* %28)
%30 = call %struct.ListNode* @reverseList(%struct.ListNode* %28)
%31 = call i32 @printList(%struct.ListNode* %30)
%32 = call i32 @freeList(%struct.ListNode* %30)
%33 = call i32 @putchar(i32 10)
%34 = call %struct.ListNode* @createList(i32* %3, i32 6)
%35 = call i32 @printList(%struct.ListNode* %34)
%36 = call %struct.ListNode* @reverseList(%struct.ListNode* %34)
%37 = call i32 @printList(%struct.ListNode* %36)
%38 = call i32 @freeList(%struct.ListNode* %36)
%39 = call i32 @putchar(i32 10)
%40 = call %struct.ListNode* @createList(i32* %3, i32 7)
%41 = call i32 @printList(%struct.ListNode* %40)
%42 = call %struct.ListNode* @reverseList(%struct.ListNode* %40)
%43 = call i32 @printList(%struct.ListNode* %42)
%44 = call i32 @freeList(%struct.ListNode* %42)
%45 = call i32 @putchar(i32 10)
%46 = call %struct.ListNode* @createList(i32* %3, i32 8)
%47 = call i32 @printList(%struct.ListNode* %46)
%48 = call %struct.ListNode* @reverseList(%struct.ListNode* %46)
%49 = call i32 @printList(%struct.ListNode* %48)
%50 = call i32 @freeList(%struct.ListNode* %48)
%51 = call i32 @putchar(i32 10)
%52 = call %struct.ListNode* @createList(i32* %3, i32 9)
%53 = call i32 @printList(%struct.ListNode* %52)
%54 = call %struct.ListNode* @reverseList(%struct.ListNode* %52)
%55 = call i32 @printList(%struct.ListNode* %54)
%56 = call i32 @freeList(%struct.ListNode* %54)
%57 = call i32 @putchar(i32 10)
%58 = call %struct.ListNode* @createList(i32* %3, i32 10)
%59 = call i32 @printList(%struct.ListNode* %58)
%60 = call %struct.ListNode* @reverseList(%struct.ListNode* %58)
%61 = call i32 @printList(%struct.ListNode* %60)
%62 = call i32 @freeList(%struct.ListNode* %60)
%63 = call i32 @putchar(i32 10)
ret i32 0
}