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

/* Variables and functions */
int /*<<< orphan*/ addNewNode(struct node *, int);
int /*<<< orphan*/ deleteList(struct node *);
struct node *initNode(int /*<<< orphan*/);
int /*<<< orphan*/ partialOrderList(struct node *, int);
int /*<<< orphan*/ printList(struct node *);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  struct node *ptr = initNode(0);
  srand(time(NULL));
  for (int i = 1; i < 10; i++) {
    addNewNode(ptr, rand() % 200);
  }
  addNewNode(ptr, 100);
  printf("List: ");
  printList(ptr);
  printf("Order list around 100: ");
  partialOrderList(ptr, 100);
  printList(ptr);
  deleteList(ptr);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1030 <initNode@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11fb <main+0x6b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
mov    -0x20(%rbp),%rdi
mov    $0xc8,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
call   1040 <addNewNode@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c1 <main+0x31>
mov    -0x10(%rbp),%rdi
mov    $0x64,%esi
call   1040 <addNewNode@plt>
lea    0xdf0(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   10b0 <printList@plt>
lea    0xde2(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x64,%esi
call   1070 <partialOrderList@plt>
mov    -0x10(%rbp),%rdi
call   10b0 <printList@plt>
mov    -0x10(%rbp),%rdi
call   1080 <deleteList@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1030 <initNode@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rsi
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0xc8,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1040 <addNewNode@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rsi
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0xc8,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1040 <addNewNode@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rsi
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0xc8,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1040 <addNewNode@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rsi
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0xc8,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1040 <addNewNode@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rsi
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0xc8,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1040 <addNewNode@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rsi
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0xc8,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1040 <addNewNode@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rsi
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0xc8,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1040 <addNewNode@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rsi
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0xc8,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1040 <addNewNode@plt>
xor    %eax,%eax
call   10a0 <rand@plt>
movslq %eax,%rsi
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0xc8,%eax,%eax
sub    %eax,%esi
mov    %rbx,%rdi
call   1040 <addNewNode@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1040 <addNewNode@plt>
lea    0xca5(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   10b0 <printList@plt>
lea    0xc98(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1070 <partialOrderList@plt>
mov    %rbx,%rdi
call   10b0 <printList@plt>
mov    %rbx,%rdi
call   1080 <deleteList@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [7 x i8] c"List: \00"
@.str.1 = [24 x i8] c"Order list around 100: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.node*
%3 = alloca i32
store i32 0, i32* %1
%4 = call %struct.node* @initNode(i32 0)
store %struct.node* %4, %struct.node** %2
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
store i32 1, i32* %3
br label %7
7: ; preds = %15, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = load %struct.node*, %struct.node** %2
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 200
%14 = call i32 @addNewNode(%struct.node* %11, i32 %13)
br label %15
15: ; preds = %10
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %7
18: ; preds = %7
%19 = load %struct.node*, %struct.node** %2
%20 = call i32 @addNewNode(%struct.node* %19, i32 100)
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%22 = load %struct.node*, %struct.node** %2
%23 = call i32 @printList(%struct.node* %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%25 = load %struct.node*, %struct.node** %2
%26 = call i32 @partialOrderList(%struct.node* %25, i32 100)
%27 = load %struct.node*, %struct.node** %2
%28 = call i32 @printList(%struct.node* %27)
%29 = load %struct.node*, %struct.node** %2
%30 = call i32 @deleteList(%struct.node* %29)
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [7 x i8] c"List: \00"
@.str.1 = [24 x i8] c"Order list around 100: \00"
define i32 @main() {
%1 = tail call %struct.node* @initNode(i32 0)
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 200
%6 = tail call i32 @addNewNode(%struct.node* %1, i32 %5)
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 200
%9 = tail call i32 @addNewNode(%struct.node* %1, i32 %8)
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 200
%12 = tail call i32 @addNewNode(%struct.node* %1, i32 %11)
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 200
%15 = tail call i32 @addNewNode(%struct.node* %1, i32 %14)
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 200
%18 = tail call i32 @addNewNode(%struct.node* %1, i32 %17)
%19 = tail call i32 (...) @rand()
%20 = srem i32 %19, 200
%21 = tail call i32 @addNewNode(%struct.node* %1, i32 %20)
%22 = tail call i32 (...) @rand()
%23 = srem i32 %22, 200
%24 = tail call i32 @addNewNode(%struct.node* %1, i32 %23)
%25 = tail call i32 (...) @rand()
%26 = srem i32 %25, 200
%27 = tail call i32 @addNewNode(%struct.node* %1, i32 %26)
%28 = tail call i32 (...) @rand()
%29 = srem i32 %28, 200
%30 = tail call i32 @addNewNode(%struct.node* %1, i32 %29)
%31 = tail call i32 @addNewNode(%struct.node* %1, i32 100)
%32 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%33 = tail call i32 @printList(%struct.node* %1)
%34 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%35 = tail call i32 @partialOrderList(%struct.node* %1, i32 100)
%36 = tail call i32 @printList(%struct.node* %1)
%37 = tail call i32 @deleteList(%struct.node* %1)
ret i32 0
}