#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 Wfnd_substr(char *, char *);
int /*<<< orphan*/ Wstrcpy(char *, char *);
void HandleAtEscape(char *ln) {
  int i;
  while (i = Wfnd_substr(ln, "@(@)")) {
    Wstrcpy(ln + i, ln + i + 3);
    ln += i;
  }
}


x86 assembly (clang, -O0):
<HandleAtEscape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1030 <Wfnd_substr@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     117d <HandleAtEscape+0x5d>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
add    $0x3,%rsi
call   1040 <Wstrcpy@plt>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    112c <HandleAtEscape+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HandleAtEscape>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xed1(%rip),%rsi
call   1030 <Wfnd_substr@plt>
test   %eax,%eax
je     1168 <HandleAtEscape+0x48>
lea    0xec1(%rip),%r14
nop
cltq
lea    (%rbx,%rax,1),%r15
lea    (%rbx,%rax,1),%rsi
add    $0x3,%rsi
mov    %r15,%rdi
call   1040 <Wstrcpy@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <Wfnd_substr@plt>
mov    %r15,%rbx
test   %eax,%eax
jne    1140 <HandleAtEscape+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"@(@)\00"
define void @HandleAtEscape(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
br label %4
4: ; preds = %8, %1
%5 = load i8*, i8** %2
%6 = call i32 @Wfnd_substr(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %6, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %23
8: ; preds = %4
%9 = load i8*, i8** %2
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8*, i8** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = getelementptr inbounds i8, i8* %16, i64 3
%18 = call i32 @Wstrcpy(i8* %12, i8* %17)
%19 = load i32, i32* %3
%20 = load i8*, i8** %2
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds i8, i8* %20, i64 %21
store i8* %22, i8** %2
br label %4
23: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"@(@)\00"
define void @HandleAtEscape(i8* %0) {
%2 = tail call i32 @Wfnd_substr(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %1, %4
%5 = phi i32 [ %11, %4 ], [ %2, %1 ]
%6 = phi i8* [ %8, %4 ], [ %0, %1 ]
%7 = sext i32 %5 to i64
%8 = getelementptr inbounds i8, i8* %6, i64 %7
%9 = getelementptr inbounds i8, i8* %8, i64 3
%10 = tail call i32 @Wstrcpy(i8* %8, i8* %9)
%11 = tail call i32 @Wfnd_substr(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %4
13: ; preds = %4, %1
ret void
}