#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*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void changeCommand(char line[], char current[], char old[], int *cursorPos) {
  memset(current, 0, 100 * (sizeof current[0]));
  if (strcmp(old, "") != 0)
    strcpy(current, old);
  else
    strcpy(current, line);
  *cursorPos = strlen(current);
}


x86 assembly (clang, -O0):
<changeCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
mov    -0x18(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1194 <changeCommand+0x54>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11a1 <changeCommand+0x61>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<changeCommand>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    0xe96(%rip),%rsi
mov    %r15,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
cmovne %r15,%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %eax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define void @changeCommand(i8* %0, i8* %1, i8* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32* %3, i32** %8
%9 = load i8*, i8** %6
%10 = call i32 @memset(i8* %9, i32 0, i32 100)
%11 = load i8*, i8** %7
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %4
%15 = load i8*, i8** %6
%16 = load i8*, i8** %7
%17 = call i32 @strcpy(i8* %15, i8* %16)
br label %22
18: ; preds = %4
%19 = load i8*, i8** %6
%20 = load i8*, i8** %5
%21 = call i32 @strcpy(i8* %19, i8* %20)
br label %22
22: ; preds = %18, %14
%23 = load i8*, i8** %6
%24 = call i32 @strlen(i8* %23)
%25 = load i32*, i32** %8
store i32 %24, i32* %25
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define void @changeCommand(i8* %0, i8* %1, i8* %2, i32* nocapture writeonly %3) {
%5 = tail call i32 @memset(i8* %1, i32 0, i32 100)
%6 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i8* %0, i8* %2
%9 = tail call i32 @strcpy(i8* %1, i8* %8)
%10 = tail call i32 @strlen(i8* %1)
store i32 %10, i32* %3
ret void
}