#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 /*<<< orphan*/ assert(int);
int suzerain_inorder_wavenumber_diff(const int N, const int dN, const int i) {
  assert(N <= dN);
  assert(0 <= i && i < dN);
  if (i < (N + 1) / 2) {
    return i;
  } else if (i >= dN - (N - 1) / 2) {
    return -dN + i;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<suzerain_inorder_wavenumber_diff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
xor    %ecx,%ecx
cmp    -0x10(%rbp),%ecx
mov    %al,-0x11(%rbp)
jg     1150 <suzerain_inorder_wavenumber_diff+0x40>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
setl   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    1189 <suzerain_inorder_wavenumber_diff+0x79>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c6 <suzerain_inorder_wavenumber_diff+0xb6>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x1c(%rbp),%eax
sub    %edx,%ecx
cmp    %ecx,%eax
jl     11bf <suzerain_inorder_wavenumber_diff+0xaf>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c6 <suzerain_inorder_wavenumber_diff+0xb6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<suzerain_inorder_wavenumber_diff>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%ebp
xor    %edi,%edi
cmp    %esi,%ebp
setle  %dil
call   1030 <assert@plt>
test   %ebx,%ebx
setns  %al
mov    %ebx,%r15d
sub    %r14d,%r15d
setl   %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <assert@plt>
lea    0x1(%rbp),%eax
shr    $0x1f,%eax
add    %ebp,%eax
add    $0x1,%eax
sar    %eax
cmp    %ebx,%eax
jg     1172 <suzerain_inorder_wavenumber_diff+0x62>
mov    %ebp,%eax
add    $0xffffffff,%eax
shr    $0x1f,%eax
add    %ebp,%eax
add    $0xffffffff,%eax
sar    %eax
sub    %eax,%r14d
xor    %eax,%eax
cmp    %ebx,%r14d
cmovg  %eax,%r15d
mov    %r15d,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @suzerain_inorder_wavenumber_diff(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %5
%9 = load i32, i32* %6
%10 = icmp sle i32 %8, %9
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32, i32* %7
%14 = icmp sle i32 0, %13
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = icmp slt i32 %16, %17
br label %19
19: ; preds = %15, %3
%20 = phi i1 [ false, %3 ], [ %18, %15 ]
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i32, i32* %7
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
%26 = sdiv i32 %25, 2
%27 = icmp slt i32 %23, %26
br i1 %27, label %28, label %30
28: ; preds = %19
%29 = load i32, i32* %7
store i32 %29, i32* %4
br label %44
30: ; preds = %19
%31 = load i32, i32* %7
%32 = load i32, i32* %6
%33 = load i32, i32* %5
%34 = sub nsw i32 %33, 1
%35 = sdiv i32 %34, 2
%36 = sub nsw i32 %32, %35
%37 = icmp sge i32 %31, %36
br i1 %37, label %38, label %43
38: ; preds = %30
%39 = load i32, i32* %6
%40 = sub nsw i32 0, %39
%41 = load i32, i32* %7
%42 = add nsw i32 %40, %41
store i32 %42, i32* %4
br label %44
43: ; preds = %30
store i32 0, i32* %4
br label %44
44: ; preds = %43, %38, %28
%45 = load i32, i32* %4
ret i32 %45
}

LLVM IR (-O2):
define i32 @suzerain_inorder_wavenumber_diff(i32 %0, i32 %1, i32 %2) {
%4 = icmp sle i32 %0, %1
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = icmp sgt i32 %2, -1
%8 = icmp slt i32 %2, %1
%9 = and i1 %7, %8
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = add nsw i32 %0, 1
%13 = sdiv i32 %12, 2
%14 = icmp sgt i32 %13, %2
br i1 %14, label %22, label %15
15: ; preds = %3
%16 = add nsw i32 %0, -1
%17 = sdiv i32 %16, -2
%18 = add i32 %17, %1
%19 = icmp sgt i32 %18, %2
%20 = sub i32 %2, %1
%21 = select i1 %19, i32 0, i32 %20
br label %22
22: ; preds = %15, %3
%23 = phi i32 [ %2, %3 ], [ %21, %15 ]
ret i32 %23
}