#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 */
scalar_t__ mark_same(struct mark *, struct mark *);
int /*<<< orphan*/ mark_valid(struct mark *);
struct mark *vmark_next(struct mark *);
struct mark *vmark_prev(struct mark *);
struct mark *vmark_matching(struct mark *m) {
  struct mark *m2;
  if (!mark_valid(m))
    return NULL;
  m2 = vmark_prev(m);
  if (m2 && mark_same(m, m2))
    return m2;
  m2 = vmark_next(m);
  if (m2 && mark_same(m, m2))
    return m2;
  return NULL;
}


x86 assembly (clang, -O0):
<vmark_matching>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <mark_valid@plt>
cmp    $0x0,%eax
jne    116b <vmark_matching+0x2b>
movq   $0x0,-0x8(%rbp)
jmp    11eb <vmark_matching+0xab>
mov    -0x10(%rbp),%rdi
call   1060 <vmark_prev@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a7 <vmark_matching+0x67>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <mark_same@plt>
cmp    $0x0,%rax
je     11a7 <vmark_matching+0x67>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11eb <vmark_matching+0xab>
mov    -0x10(%rbp),%rdi
call   1050 <vmark_next@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11e3 <vmark_matching+0xa3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <mark_same@plt>
cmp    $0x0,%rax
je     11e3 <vmark_matching+0xa3>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11eb <vmark_matching+0xab>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vmark_matching>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <mark_valid@plt>
test   %eax,%eax
je     1190 <vmark_matching+0x50>
mov    %r14,%rdi
call   1060 <vmark_prev@plt>
test   %rax,%rax
je     1170 <vmark_matching+0x30>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <mark_same@plt>
test   %rax,%rax
jne    1192 <vmark_matching+0x52>
mov    %r14,%rdi
call   1050 <vmark_next@plt>
test   %rax,%rax
je     1190 <vmark_matching+0x50>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <mark_same@plt>
test   %rax,%rax
jne    1192 <vmark_matching+0x52>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.mark = type { i32 }
define %struct.mark* @vmark_matching(%struct.mark* %0) {
%2 = alloca %struct.mark*
%3 = alloca %struct.mark*
%4 = alloca %struct.mark*
store %struct.mark* %0, %struct.mark** %3
%5 = load %struct.mark*, %struct.mark** %3
%6 = call i32 @mark_valid(%struct.mark* %5)
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %1
store %struct.mark* null, %struct.mark** %2
br label %34
9: ; preds = %1
%10 = load %struct.mark*, %struct.mark** %3
%11 = call %struct.mark* @vmark_prev(%struct.mark* %10)
store %struct.mark* %11, %struct.mark** %4
%12 = load %struct.mark*, %struct.mark** %4
%13 = icmp ne %struct.mark* %12, null
br i1 %13, label %14, label %21
14: ; preds = %9
%15 = load %struct.mark*, %struct.mark** %3
%16 = load %struct.mark*, %struct.mark** %4
%17 = call i64 @mark_same(%struct.mark* %15, %struct.mark* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = load %struct.mark*, %struct.mark** %4
store %struct.mark* %20, %struct.mark** %2
br label %34
21: ; preds = %14, %9
%22 = load %struct.mark*, %struct.mark** %3
%23 = call %struct.mark* @vmark_next(%struct.mark* %22)
store %struct.mark* %23, %struct.mark** %4
%24 = load %struct.mark*, %struct.mark** %4
%25 = icmp ne %struct.mark* %24, null
br i1 %25, label %26, label %33
26: ; preds = %21
%27 = load %struct.mark*, %struct.mark** %3
%28 = load %struct.mark*, %struct.mark** %4
%29 = call i64 @mark_same(%struct.mark* %27, %struct.mark* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = load %struct.mark*, %struct.mark** %4
store %struct.mark* %32, %struct.mark** %2
br label %34
33: ; preds = %26, %21
store %struct.mark* null, %struct.mark** %2
br label %34
34: ; preds = %33, %31, %19, %8
%35 = load %struct.mark*, %struct.mark** %2
ret %struct.mark* %35
}

LLVM IR (-O2):
%struct.mark = type { i32 }
define %struct.mark* @vmark_matching(%struct.mark* %0) {
%2 = tail call i32 @mark_valid(%struct.mark* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1
%5 = tail call %struct.mark* @vmark_prev(%struct.mark* %0)
%6 = icmp eq %struct.mark* %5, null
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i64 @mark_same(%struct.mark* %0, %struct.mark* %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %7, %4
%11 = tail call %struct.mark* @vmark_next(%struct.mark* %0)
%12 = icmp eq %struct.mark* %11, null
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call i64 @mark_same(%struct.mark* %0, %struct.mark* %11)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13, %10
br label %17
17: ; preds = %13, %7, %1, %16
%18 = phi %struct.mark* [ null, %16 ], [ null, %1 ], [ %5, %7 ], [ %11, %13 ]
ret %struct.mark* %18
}