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

/* Variables and functions */
struct mark *mark_next(struct mark *);
struct mark *mark_prev(struct mark *);
scalar_t__ mark_same(struct mark *, struct mark *);
int /*<<< orphan*/ mark_to_mark_noref(struct mark *, struct mark *);
int /*<<< orphan*/ notify_point_moving(struct mark *);
void mark_step(struct mark *m, int forward) {
  struct mark *m2, *target = m;
  notify_point_moving(m);
  if (forward) {
    for (m2 = mark_next(m); m2 && mark_same(m, m2); m2 = mark_next(m2))
      target = m2;
  } else {
    for (m2 = mark_prev(m); m2 && mark_same(m, m2); m2 = mark_prev(m2))
      target = m2;
  }
  mark_to_mark_noref(m, target);
}


x86 assembly (clang, -O0):
<mark_step>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <notify_point_moving@plt>
cmpl   $0x0,-0xc(%rbp)
je     11dd <mark_step+0x8d>
mov    -0x8(%rbp),%rdi
call   1060 <mark_next@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x21(%rbp)
je     11ae <mark_step+0x5e>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <mark_same@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11be <mark_step+0x6e>
jmp    11d8 <mark_step+0x88>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <mark_next@plt>
mov    %rax,-0x18(%rbp)
jmp    1187 <mark_step+0x37>
jmp    1240 <mark_step+0xf0>
mov    -0x8(%rbp),%rdi
call   1050 <mark_prev@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x22(%rbp)
je     1211 <mark_step+0xc1>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <mark_same@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
test   $0x1,%al
jne    1221 <mark_step+0xd1>
jmp    123b <mark_step+0xeb>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <mark_prev@plt>
mov    %rax,-0x18(%rbp)
jmp    11ea <mark_step+0x9a>
jmp    1240 <mark_step+0xf0>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <mark_to_mark_noref@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mark_step>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
call   1030 <notify_point_moving@plt>
mov    %r14,%rdi
test   %ebx,%ebx
je     11b5 <mark_step+0x65>
call   1060 <mark_next@plt>
mov    %r14,%r15
test   %rax,%rax
je     1203 <mark_step+0xb3>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <mark_same@plt>
mov    %r14,%r15
test   %rax,%rax
je     1203 <mark_step+0xb3>
nopl   (%rax)
mov    %rbx,%r15
mov    %rbx,%rdi
call   1060 <mark_next@plt>
test   %rax,%rax
je     1203 <mark_step+0xb3>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <mark_same@plt>
test   %rax,%rax
jne    1190 <mark_step+0x40>
jmp    1203 <mark_step+0xb3>
call   1050 <mark_prev@plt>
mov    %r14,%r15
test   %rax,%rax
je     1203 <mark_step+0xb3>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <mark_same@plt>
mov    %r14,%r15
test   %rax,%rax
je     1203 <mark_step+0xb3>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%r15
mov    %rbx,%rdi
call   1050 <mark_prev@plt>
test   %rax,%rax
je     1203 <mark_step+0xb3>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <mark_same@plt>
test   %rax,%rax
jne    11e0 <mark_step+0x90>
mov    %r14,%rdi
mov    %r15,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1070 <mark_to_mark_noref@plt>

LLVM IR (-O0):
%struct.mark = type { i32 }
define void @mark_step(%struct.mark* %0, i32 %1) {
%3 = alloca %struct.mark*
%4 = alloca i32
%5 = alloca %struct.mark*
%6 = alloca %struct.mark*
store %struct.mark* %0, %struct.mark** %3
store i32 %1, i32* %4
%7 = load %struct.mark*, %struct.mark** %3
store %struct.mark* %7, %struct.mark** %6
%8 = load %struct.mark*, %struct.mark** %3
%9 = call i32 @notify_point_moving(%struct.mark* %8)
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %31
12: ; preds = %2
%13 = load %struct.mark*, %struct.mark** %3
%14 = call %struct.mark* @mark_next(%struct.mark* %13)
store %struct.mark* %14, %struct.mark** %5
br label %15
15: ; preds = %27, %12
%16 = load %struct.mark*, %struct.mark** %5
%17 = icmp ne %struct.mark* %16, null
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load %struct.mark*, %struct.mark** %3
%20 = load %struct.mark*, %struct.mark** %5
%21 = call i64 @mark_same(%struct.mark* %19, %struct.mark* %20)
%22 = icmp ne i64 %21, 0
br label %23
23: ; preds = %18, %15
%24 = phi i1 [ false, %15 ], [ %22, %18 ]
br i1 %24, label %25, label %30
25: ; preds = %23
%26 = load %struct.mark*, %struct.mark** %5
store %struct.mark* %26, %struct.mark** %6
br label %27
27: ; preds = %25
%28 = load %struct.mark*, %struct.mark** %5
%29 = call %struct.mark* @mark_next(%struct.mark* %28)
store %struct.mark* %29, %struct.mark** %5
br label %15
30: ; preds = %23
br label %50
31: ; preds = %2
%32 = load %struct.mark*, %struct.mark** %3
%33 = call %struct.mark* @mark_prev(%struct.mark* %32)
store %struct.mark* %33, %struct.mark** %5
br label %34
34: ; preds = %46, %31
%35 = load %struct.mark*, %struct.mark** %5
%36 = icmp ne %struct.mark* %35, null
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load %struct.mark*, %struct.mark** %3
%39 = load %struct.mark*, %struct.mark** %5
%40 = call i64 @mark_same(%struct.mark* %38, %struct.mark* %39)
%41 = icmp ne i64 %40, 0
br label %42
42: ; preds = %37, %34
%43 = phi i1 [ false, %34 ], [ %41, %37 ]
br i1 %43, label %44, label %49
44: ; preds = %42
%45 = load %struct.mark*, %struct.mark** %5
store %struct.mark* %45, %struct.mark** %6
br label %46
46: ; preds = %44
%47 = load %struct.mark*, %struct.mark** %5
%48 = call %struct.mark* @mark_prev(%struct.mark* %47)
store %struct.mark* %48, %struct.mark** %5
br label %34
49: ; preds = %42
br label %50
50: ; preds = %49, %30
%51 = load %struct.mark*, %struct.mark** %3
%52 = load %struct.mark*, %struct.mark** %6
%53 = call i32 @mark_to_mark_noref(%struct.mark* %51, %struct.mark* %52)
ret void
}

LLVM IR (-O2):
%struct.mark = type { i32 }
define void @mark_step(%struct.mark* %0, i32 %1) {
%3 = tail call i32 @notify_point_moving(%struct.mark* %0)
%4 = icmp eq i32 %1, 0
br i1 %4, label %18, label %5
5: ; preds = %2
%6 = tail call %struct.mark* @mark_next(%struct.mark* %0)
%7 = icmp eq %struct.mark* %6, null
br i1 %7, label %31, label %8
8: ; preds = %5
%9 = tail call i64 @mark_same(%struct.mark* %0, %struct.mark* %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %31, label %14
11: ; preds = %14
%12 = tail call i64 @mark_same(%struct.mark* %0, %struct.mark* %16)
%13 = icmp eq i64 %12, 0
br i1 %13, label %31, label %14
14: ; preds = %8, %11
%15 = phi %struct.mark* [ %16, %11 ], [ %6, %8 ]
%16 = tail call %struct.mark* @mark_next(%struct.mark* %15)
%17 = icmp eq %struct.mark* %16, null
br i1 %17, label %31, label %11
18: ; preds = %2
%19 = tail call %struct.mark* @mark_prev(%struct.mark* %0)
%20 = icmp eq %struct.mark* %19, null
br i1 %20, label %31, label %21
21: ; preds = %18
%22 = tail call i64 @mark_same(%struct.mark* %0, %struct.mark* %19)
%23 = icmp eq i64 %22, 0
br i1 %23, label %31, label %27
24: ; preds = %27
%25 = tail call i64 @mark_same(%struct.mark* %0, %struct.mark* %29)
%26 = icmp eq i64 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %21, %24
%28 = phi %struct.mark* [ %29, %24 ], [ %19, %21 ]
%29 = tail call %struct.mark* @mark_prev(%struct.mark* %28)
%30 = icmp eq %struct.mark* %29, null
br i1 %30, label %31, label %24
31: ; preds = %11, %14, %24, %27, %8, %21, %5, %18
%32 = phi %struct.mark* [ %0, %18 ], [ %0, %5 ], [ %0, %21 ], [ %0, %8 ], [ %28, %27 ], [ %28, %24 ], [ %15, %14 ], [ %15, %11 ]
%33 = tail call i32 @mark_to_mark_noref(%struct.mark* %0, %struct.mark* %32)
ret void
}