#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 */

/* Variables and functions */
int tiling(int);
int aysm_tiling(int n) {
  int all = tiling(n);
  if (n % 2 == 0) {
    return all - tiling(n / 2) - tiling(n / 2 - 1);
  } else {
    return all - tiling(n / 2);
  }
}


x86 assembly (clang, -O0):
<aysm_tiling>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <tiling@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1180 <aysm_tiling+0x70>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <tiling@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
sub    $0x1,%edi
call   1030 <tiling@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <aysm_tiling+0x92>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <tiling@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aysm_tiling>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
call   1030 <tiling@plt>
mov    %eax,%r15d
mov    %ebx,%ebp
shr    $0x1f,%ebp
add    %ebx,%ebp
sar    %ebp
mov    %ebp,%edi
call   1030 <tiling@plt>
mov    %eax,%r14d
test   $0x1,%bl
jne    1146 <aysm_tiling+0x36>
add    $0xffffffff,%ebp
mov    %ebp,%edi
call   1030 <tiling@plt>
add    %eax,%r14d
sub    %r14d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @aysm_tiling(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = call i32 @tiling(i32 %5)
store i32 %6, i32* %4
%7 = load i32, i32* %3
%8 = srem i32 %7, 2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %1
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = sdiv i32 %12, 2
%14 = call i32 @tiling(i32 %13)
%15 = sub nsw i32 %11, %14
%16 = load i32, i32* %3
%17 = sdiv i32 %16, 2
%18 = sub nsw i32 %17, 1
%19 = call i32 @tiling(i32 %18)
%20 = sub nsw i32 %15, %19
store i32 %20, i32* %2
br label %27
21: ; preds = %1
%22 = load i32, i32* %4
%23 = load i32, i32* %3
%24 = sdiv i32 %23, 2
%25 = call i32 @tiling(i32 %24)
%26 = sub nsw i32 %22, %25
store i32 %26, i32* %2
br label %27
27: ; preds = %21, %10
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
define i32 @aysm_tiling(i32 %0) {
%2 = tail call i32 @tiling(i32 %0)
%3 = and i32 %0, 1
%4 = icmp eq i32 %3, 0
%5 = sdiv i32 %0, 2
%6 = tail call i32 @tiling(i32 %5)
br i1 %4, label %7, label %11
7: ; preds = %1
%8 = add nsw i32 %5, -1
%9 = tail call i32 @tiling(i32 %8)
%10 = add i32 %9, %6
br label %11
11: ; preds = %1, %7
%12 = phi i32 [ %10, %7 ], [ %6, %1 ]
%13 = sub i32 %2, %12
ret i32 %13
}