#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 */
unsigned int curposCalc(char const *const, unsigned int, unsigned int,
                        unsigned int, int);
int /*<<< orphan*/ outc(char);
unsigned eraseLine(const char *const str_top, unsigned posfrom, unsigned posto,
                   unsigned orgx, unsigned orgy) {
  unsigned rc;
  unsigned cpfrom, cpto, count;
  cpto = curposCalc(str_top, posto, orgx, orgy, 0);
  cpfrom = curposCalc(str_top, posfrom, orgx, orgy, 1);
  count = rc = cpfrom < cpto ? (cpto - cpfrom) : 0;
  while (count--)
    outc(' ');
  return rc;
}


x86 assembly (clang, -O0):
<eraseLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
xor    %r8d,%r8d
call   1040 <curposCalc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    $0x1,%r8d
call   1040 <curposCalc@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jae    1186 <eraseLine+0x66>
mov    -0x24(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1190 <eraseLine+0x70>
xor    %eax,%eax
mov    %eax,-0x2c(%rbp)
jmp    1190 <eraseLine+0x70>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x28(%rbp)
cmp    $0x0,%eax
je     11bc <eraseLine+0x9c>
mov    $0x20,%edi
call   1030 <outc@plt>
jmp    1199 <eraseLine+0x79>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eraseLine>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r12d
mov    %ecx,%ebp
mov    %esi,%r15d
mov    %rdi,%rbx
xor    %r13d,%r13d
mov    %edx,%esi
mov    %ecx,%edx
mov    %r8d,%ecx
xor    %r8d,%r8d
call   1040 <curposCalc@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
mov    $0x1,%r8d
call   1040 <curposCalc@plt>
mov    %r14d,%ebx
sub    %eax,%ebx
cmovb  %r13d,%ebx
jbe    118e <eraseLine+0x6e>
mov    %eax,%ebp
cmovb  %r14d,%ebp
sub    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x20,%edi
call   1030 <outc@plt>
inc    %ebp
jne    1180 <eraseLine+0x60>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @eraseLine(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%15 = load i8*, i8** %6
%16 = load i32, i32* %8
%17 = load i32, i32* %9
%18 = load i32, i32* %10
%19 = call i32 @curposCalc(i8* %15, i32 %16, i32 %17, i32 %18, i32 0)
store i32 %19, i32* %13
%20 = load i8*, i8** %6
%21 = load i32, i32* %7
%22 = load i32, i32* %9
%23 = load i32, i32* %10
%24 = call i32 @curposCalc(i8* %20, i32 %21, i32 %22, i32 %23, i32 1)
store i32 %24, i32* %12
%25 = load i32, i32* %12
%26 = load i32, i32* %13
%27 = icmp ult i32 %25, %26
br i1 %27, label %28, label %32
28: ; preds = %5
%29 = load i32, i32* %13
%30 = load i32, i32* %12
%31 = sub i32 %29, %30
br label %33
32: ; preds = %5
br label %33
33: ; preds = %32, %28
%34 = phi i32 [ %31, %28 ], [ 0, %32 ]
store i32 %34, i32* %11
store i32 %34, i32* %14
br label %35
35: ; preds = %39, %33
%36 = load i32, i32* %14
%37 = add i32 %36, -1
store i32 %37, i32* %14
%38 = icmp ne i32 %36, 0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 @outc(i8 signext 32)
br label %35
41: ; preds = %35
%42 = load i32, i32* %11
ret i32 %42
}

LLVM IR (-O2):
define i32 @eraseLine(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 @curposCalc(i8* %0, i32 %2, i32 %3, i32 %4, i32 0)
%7 = tail call i32 @curposCalc(i8* %0, i32 %1, i32 %3, i32 %4, i32 1)
%8 = tail call i32 @llvm.usub.sat.i32(i32 %6, i32 %7)
%9 = icmp ugt i32 %6, %7
br i1 %9, label %10, label %15
10: ; preds = %5, %10
%11 = phi i32 [ %12, %10 ], [ %8, %5 ]
%12 = add i32 %11, -1
%13 = tail call i32 @outc(i8 signext 32)
%14 = icmp eq i32 %12, 0
br i1 %14, label %15, label %10
15: ; preds = %10, %5
ret i32 %8
}