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

/* Variables and functions */
struct link *create_list_dead();
struct link *create_list_loop();
scalar_t__ isloop_reverse(struct link *);
scalar_t__ isloop_twowalker(struct link *);
int /*<<< orphan*/ print_list(struct link *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  struct link *head;
  srand(time(NULL));
  head = create_list_dead();
  print_list(head);
  if (isloop_twowalker(head))
    printf("twowalker: loop\n");
  else
    printf("twowalker: not loop\n");
  if (isloop_reverse(head))
    printf("reverse: loop\n");
  else
    printf("reverse: not loop\n");
  head = create_list_loop();
  print_list(head);
  if (isloop_twowalker(head))
    printf("twowalker: loop\n");
  else
    printf("twowalker: not loop\n");
  if (isloop_reverse(head))
    printf("reverse: loop\n");
  else
    printf("reverse: not loop\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x0,%al
call   1090 <create_list_dead@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <print_list@plt>
mov    -0x10(%rbp),%rdi
call   1080 <isloop_twowalker@plt>
cmp    $0x0,%rax
je     11d7 <main+0x57>
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
jmp    11e3 <main+0x63>
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <isloop_reverse@plt>
cmp    $0x0,%rax
je     1207 <main+0x87>
lea    0xe29(%rip),%rdi
call   1040 <printf@plt>
jmp    1213 <main+0x93>
lea    0xe27(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <create_list_loop@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <print_list@plt>
mov    -0x10(%rbp),%rdi
call   1080 <isloop_twowalker@plt>
cmp    $0x0,%rax
je     124b <main+0xcb>
lea    0xdbf(%rip),%rdi
call   1040 <printf@plt>
jmp    1257 <main+0xd7>
lea    0xdbf(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <isloop_reverse@plt>
cmp    $0x0,%rax
je     127b <main+0xfb>
lea    0xdb5(%rip),%rdi
call   1040 <printf@plt>
jmp    1287 <main+0x107>
lea    0xdb3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   1090 <create_list_dead@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <print_list@plt>
mov    %rbx,%rdi
call   1080 <isloop_twowalker@plt>
test   %rax,%rax
lea    0xe45(%rip),%r12
lea    0xe72(%rip),%r14
mov    %r14,%rdi
cmove  %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <isloop_reverse@plt>
test   %rax,%rax
lea    0xe34(%rip),%r13
lea    0xe3f(%rip),%r15
mov    %r15,%rdi
cmove  %r13,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   10a0 <create_list_loop@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <print_list@plt>
mov    %rbx,%rdi
call   1080 <isloop_twowalker@plt>
test   %rax,%rax
cmove  %r12,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <isloop_reverse@plt>
test   %rax,%rax
cmove  %r13,%r15
mov    %r15,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.link = type { i32 }
@.str = [17 x i8] c"twowalker: loop\0A\00"
@.str.1 = [21 x i8] c"twowalker: not loop\0A\00"
@.str.2 = [15 x i8] c"reverse: loop\0A\00"
@.str.3 = [19 x i8] c"reverse: not loop\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.link*
store i32 0, i32* %1
%3 = call i32 @time(i32* null)
%4 = call i32 @srand(i32 %3)
%5 = call %struct.link* (...) @create_list_dead()
store %struct.link* %5, %struct.link** %2
%6 = load %struct.link*, %struct.link** %2
%7 = call i32 @print_list(%struct.link* %6)
%8 = load %struct.link*, %struct.link** %2
%9 = call i64 @isloop_twowalker(%struct.link* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %15
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %11
%16 = load %struct.link*, %struct.link** %2
%17 = call i64 @isloop_reverse(%struct.link* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %23
21: ; preds = %15
%22 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
%24 = call %struct.link* (...) @create_list_loop()
store %struct.link* %24, %struct.link** %2
%25 = load %struct.link*, %struct.link** %2
%26 = call i32 @print_list(%struct.link* %25)
%27 = load %struct.link*, %struct.link** %2
%28 = call i64 @isloop_twowalker(%struct.link* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %23
%31 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %34
32: ; preds = %23
%33 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
%35 = load %struct.link*, %struct.link** %2
%36 = call i64 @isloop_reverse(%struct.link* %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %42
40: ; preds = %34
%41 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40, %38
ret i32 0
}

LLVM IR (-O2):
%struct.link = type { i32 }
@str.5 = [20 x i8] c"twowalker: not loop\00"
@str.6 = [18 x i8] c"reverse: not loop\00"
@str.9 = [14 x i8] c"reverse: loop\00"
@str.10 = [16 x i8] c"twowalker: loop\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call %struct.link* (...) @create_list_dead()
%4 = tail call i32 @print_list(%struct.link* %3)
%5 = tail call i64 @isloop_twowalker(%struct.link* %3)
%6 = icmp eq i64 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str.10, i64 0, i64 0)
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
%9 = tail call i64 @isloop_reverse(%struct.link* %3)
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @str.9, i64 0, i64 0)
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
%13 = tail call %struct.link* (...) @create_list_loop()
%14 = tail call i32 @print_list(%struct.link* %13)
%15 = tail call i64 @isloop_twowalker(%struct.link* %13)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str.10, i64 0, i64 0)
%18 = tail call i32 @puts(i8* dereferenceable(1) %17)
%19 = tail call i64 @isloop_reverse(%struct.link* %13)
%20 = icmp eq i64 %19, 0
%21 = select i1 %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @str.9, i64 0, i64 0)
%22 = tail call i32 @puts(i8* dereferenceable(1) %21)
ret i32 0
}