#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*/ _write(int, char *, int);
int /*<<< orphan*/ memset(char *, char, int);
void cli_clear_line(int sockfd, char *cmd, int l, int cursor) {
  memset((char *)cmd, '\b', cursor);
  _write(sockfd, cmd, cursor);
  memset((char *)cmd, ' ', l);
  _write(sockfd, cmd, l);
  memset((char *)cmd, '\b', l);
  _write(sockfd, cmd, l);
  memset((char *)cmd, 0, l);
}


x86 assembly (clang, -O0):
<cli_clear_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    $0x8,%esi
call   1030 <memset@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1040 <_write@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    $0x20,%esi
call   1030 <memset@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <_write@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    $0x8,%esi
call   1030 <memset@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <_write@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1030 <memset@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cli_clear_line>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %rsi,%rdi
mov    $0x8,%esi
mov    %ecx,%edx
call   1030 <memset@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1040 <_write@plt>
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %ebp,%edx
call   1030 <memset@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <_write@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
mov    %ebp,%edx
call   1030 <memset@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <_write@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %ebp,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <memset@plt>

LLVM IR (-O0):
define void @cli_clear_line(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i8*, i8** %6
%10 = load i32, i32* %8
%11 = call i32 @memset(i8* %9, i8 signext 8, i32 %10)
%12 = load i32, i32* %5
%13 = load i8*, i8** %6
%14 = load i32, i32* %8
%15 = call i32 @_write(i32 %12, i8* %13, i32 %14)
%16 = load i8*, i8** %6
%17 = load i32, i32* %7
%18 = call i32 @memset(i8* %16, i8 signext 32, i32 %17)
%19 = load i32, i32* %5
%20 = load i8*, i8** %6
%21 = load i32, i32* %7
%22 = call i32 @_write(i32 %19, i8* %20, i32 %21)
%23 = load i8*, i8** %6
%24 = load i32, i32* %7
%25 = call i32 @memset(i8* %23, i8 signext 8, i32 %24)
%26 = load i32, i32* %5
%27 = load i8*, i8** %6
%28 = load i32, i32* %7
%29 = call i32 @_write(i32 %26, i8* %27, i32 %28)
%30 = load i8*, i8** %6
%31 = load i32, i32* %7
%32 = call i32 @memset(i8* %30, i8 signext 0, i32 %31)
ret void
}

LLVM IR (-O2):
define void @cli_clear_line(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = tail call i32 @memset(i8* %1, i8 signext 8, i32 %3)
%6 = tail call i32 @_write(i32 %0, i8* %1, i32 %3)
%7 = tail call i32 @memset(i8* %1, i8 signext 32, i32 %2)
%8 = tail call i32 @_write(i32 %0, i8* %1, i32 %2)
%9 = tail call i32 @memset(i8* %1, i8 signext 8, i32 %2)
%10 = tail call i32 @_write(i32 %0, i8* %1, i32 %2)
%11 = tail call i32 @memset(i8* %1, i8 signext 0, i32 %2)
ret void
}