#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 COLS;
int TABSIZE;
int /*<<< orphan*/ getyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ stdscr;
void advcursor(char c) {
  int row, column;
  getyx(stdscr, row, column);
  if (c == '\n') {
    row++;
    column = 0;
  } else if (c == '\t') {
    do
      column++;
    while (column % TABSIZE != 0);
  } else {
    column++;
  }
  if (column >= COLS) {
    row++;
    column = 0;
  }
  move(row, column);
}


x86 assembly (clang, -O0):
<advcursor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    0x2eab(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <getyx@plt>
movsbl -0x1(%rbp),%eax
cmp    $0xa,%eax
jne    1164 <advcursor+0x44>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
jmp    11a8 <advcursor+0x88>
movsbl -0x1(%rbp),%eax
cmp    $0x9,%eax
jne    119a <advcursor+0x7a>
jmp    1176 <advcursor+0x56>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e5f(%rip),%rcx
cltd
idivl  (%rcx)
cmp    $0x0,%edx
jne    1176 <advcursor+0x56>
jmp    11a3 <advcursor+0x83>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a8 <advcursor+0x88>
mov    -0xc(%rbp),%eax
mov    0x2e26(%rip),%rcx
cmp    (%rcx),%eax
jl     11ca <advcursor+0xaa>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <move@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<advcursor>:
push   %rax
mov    0x2ec0(%rip),%rax
mov    (%rax),%edi
call   1030 <getyx@plt>
xor    %esi,%esi
pop    %rax
jmp    1040 <move@plt>

LLVM IR (-O0):
@stdscr = global i32 0
@TABSIZE = global i32 0
@COLS = global i32 0
define void @advcursor(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i8 %0, i8* %2
%5 = load i32, i32* @stdscr
%6 = load i32, i32* %3
%7 = load i32, i32* %4
%8 = call i32 @getyx(i32 %5, i32 %6, i32 %7)
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 10
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
store i32 0, i32* %4
br label %33
15: ; preds = %1
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 9
br i1 %18, label %19, label %29
19: ; preds = %15
br label %20
20: ; preds = %23, %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %23
23: ; preds = %20
%24 = load i32, i32* %4
%25 = load i32, i32* @TABSIZE
%26 = srem i32 %24, %25
%27 = icmp ne i32 %26, 0
br i1 %27, label %20, label %28
28: ; preds = %23
br label %32
29: ; preds = %15
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %32
32: ; preds = %29, %28
br label %33
33: ; preds = %32, %12
%34 = load i32, i32* %4
%35 = load i32, i32* @COLS
%36 = icmp sge i32 %34, %35
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
store i32 0, i32* %4
br label %40
40: ; preds = %37, %33
%41 = load i32, i32* %3
%42 = load i32, i32* %4
%43 = call i32 @move(i32 %41, i32 %42)
ret void
}

LLVM IR (-O2):
@stdscr = global i32 0
@TABSIZE = global i32 0
@COLS = global i32 0
define void @advcursor(i8 signext %0) {
%2 = load i32, i32* @stdscr
%3 = tail call i32 @getyx(i32 %2, i32 undef, i32 undef)
%4 = tail call i32 @move(i32 undef, i32 0)
ret void
}