#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 */
typedef int /*<<< orphan*/ WINDOW;

/* Variables and functions */
int COLS;
int /*<<< orphan*/ getyx(int /*<<< orphan*/ *, int, int);
int wmove(int /*<<< orphan*/ *, int, int);
int my_wmove(WINDOW *win, int dir) {
  int x, y;
  getyx(win, y, x);
  if (dir > 0) {
    if (++x > (COLS - 1)) {
      x = 0;
      y++;
    }
  } else {
    if (--x < 0) {
      x = COLS - 1;
      y--;
    }
  }
  return wmove(win, y, x);
}


x86 assembly (clang, -O0):
<my_wmove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <getyx@plt>
cmpl   $0x0,-0xc(%rbp)
jle    117a <my_wmove+0x5a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    0x2e90(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jle    1175 <my_wmove+0x55>
movl   $0x0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a9 <my_wmove+0x89>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    11a4 <my_wmove+0x84>
mov    0x2e55(%rip),%rax
mov    (%rax),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11a9 <my_wmove+0x89>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <wmove@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_wmove>:
push   %rbx
mov    %rdi,%rbx
call   1030 <getyx@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <wmove@plt>

LLVM IR (-O0):
@COLS = global i32 0
define i32 @my_wmove(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32*, i32** %3
%8 = load i32, i32* %6
%9 = load i32, i32* %5
%10 = call i32 @getyx(i32* %7, i32 %8, i32 %9)
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %2
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
store i32 %15, i32* %5
%16 = load i32, i32* @COLS
%17 = sub nsw i32 %16, 1
%18 = icmp sgt i32 %15, %17
br i1 %18, label %19, label %22
19: ; preds = %13
store i32 0, i32* %5
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %22
22: ; preds = %19, %13
br label %33
23: ; preds = %2
%24 = load i32, i32* %5
%25 = add nsw i32 %24, -1
store i32 %25, i32* %5
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %23
%28 = load i32, i32* @COLS
%29 = sub nsw i32 %28, 1
store i32 %29, i32* %5
%30 = load i32, i32* %6
%31 = add nsw i32 %30, -1
store i32 %31, i32* %6
br label %32
32: ; preds = %27, %23
br label %33
33: ; preds = %32, %22
%34 = load i32*, i32** %3
%35 = load i32, i32* %6
%36 = load i32, i32* %5
%37 = call i32 @wmove(i32* %34, i32 %35, i32 %36)
ret i32 %37
}

LLVM IR (-O2):
@COLS = global i32 0
define i32 @my_wmove(i32* %0, i32 %1) {
%3 = tail call i32 @getyx(i32* %0, i32 undef, i32 undef)
%4 = tail call i32 @wmove(i32* %0, i32 undef, i32 undef)
ret i32 %4
}