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

/* Variables and functions */
int direct_link_hor(struct llk_info *, int, int, int);
int direct_link_ver(struct llk_info *, int, int, int);
int direct_link(struct llk_info *info, int row1, int col1, int row2, int col2) {
  if (row1 == row2) {
    return direct_link_hor(info, row1, col1, col2);
  }
  if (col1 == col2) {
    return direct_link_ver(info, row1, row2, col1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<direct_link>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    115f <direct_link+0x3f>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1040 <direct_link_hor@plt>
mov    %eax,-0x4(%rbp)
jmp    118c <direct_link+0x6c>
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    1185 <direct_link+0x65>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <direct_link_ver@plt>
mov    %eax,-0x4(%rbp)
jmp    118c <direct_link+0x6c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<direct_link>:
mov    %edx,%eax
cmp    %ecx,%esi
jne    1130 <direct_link+0x10>
mov    %eax,%edx
mov    %r8d,%ecx
jmp    1040 <direct_link_hor@plt>
cmp    %r8d,%eax
jne    113e <direct_link+0x1e>
mov    %ecx,%edx
mov    %eax,%ecx
jmp    1030 <direct_link_ver@plt>
xor    %eax,%eax
ret

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

LLVM IR (-O2):
%struct.llk_info = type { i32 }
define i32 @direct_link(%struct.llk_info* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %1, %3
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i32 @direct_link_hor(%struct.llk_info* %0, i32 %1, i32 %2, i32 %4)
br label %13
9: ; preds = %5
%10 = icmp eq i32 %2, %4
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = tail call i32 @direct_link_ver(%struct.llk_info* %0, i32 %1, i32 %3, i32 %2)
br label %13
13: ; preds = %9, %11, %7
%14 = phi i32 [ %8, %7 ], [ %12, %11 ], [ 0, %9 ]
ret i32 %14
}