#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 */
typedef int wchar_t;

/* Variables and functions */
wchar_t *__wcscat(wchar_t *dest, const wchar_t *src) {
  wchar_t *s1 = dest;
  const wchar_t *s2 = src;
  wchar_t c;
  do
    c = *s1++;
  while (c != L'\0');
  s1 -= 2;
  do {
    c = *s2++;
    *++s1 = c;
  } while (c != L'\0');
  return dest;
}


x86 assembly (clang, -O0):
<__wcscat>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    111c <__wcscat+0x1c>
mov    -0x18(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x18(%rbp)
mov    %ecx,0x4(%rax)
cmpl   $0x0,-0x24(%rbp)
jne    1146 <__wcscat+0x46>
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__wcscat>:
mov    %rdi,%rax
mov    %rdi,%rcx
cs nopw 0x0(%rax,%rax,1)
cmpl   $0x0,(%rcx)
lea    0x4(%rcx),%rcx
jne    1110 <__wcscat+0x10>
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
mov    (%rsi,%rdx,1),%edi
mov    %edi,-0x4(%rcx,%rdx,1)
add    $0x4,%rdx
test   %edi,%edi
jne    1120 <__wcscat+0x20>
ret

LLVM IR (-O0):
define i32* @__wcscat(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%8 = load i32*, i32** %3
store i32* %8, i32** %5
%9 = load i32*, i32** %4
store i32* %9, i32** %6
br label %10
10: ; preds = %14, %2
%11 = load i32*, i32** %5
%12 = getelementptr inbounds i32, i32* %11, i32 1
store i32* %12, i32** %5
%13 = load i32, i32* %11
store i32 %13, i32* %7
br label %14
14: ; preds = %10
%15 = load i32, i32* %7
%16 = icmp ne i32 %15, 0
br i1 %16, label %10, label %17
17: ; preds = %14
%18 = load i32*, i32** %5
%19 = getelementptr inbounds i32, i32* %18, i64 -2
store i32* %19, i32** %5
br label %20
20: ; preds = %27, %17
%21 = load i32*, i32** %6
%22 = getelementptr inbounds i32, i32* %21, i32 1
store i32* %22, i32** %6
%23 = load i32, i32* %21
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = load i32*, i32** %5
%26 = getelementptr inbounds i32, i32* %25, i32 1
store i32* %26, i32** %5
store i32 %24, i32* %26
br label %27
27: ; preds = %20
%28 = load i32, i32* %7
%29 = icmp ne i32 %28, 0
br i1 %29, label %20, label %30
30: ; preds = %27
%31 = load i32*, i32** %3
ret i32* %31
}

LLVM IR (-O2):
define i32* @__wcscat(i32* returned %0, i32* nocapture %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i32* [ %0, %2 ], [ %5, %3 ]
%5 = getelementptr inbounds i32, i32* %4, i64 1
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %3
8: ; preds = %3
%9 = getelementptr inbounds i32, i32* %4, i64 -1
br label %10
10: ; preds = %10, %8
%11 = phi i32* [ %9, %8 ], [ %15, %10 ]
%12 = phi i32* [ %1, %8 ], [ %13, %10 ]
%13 = getelementptr inbounds i32, i32* %12, i64 1
%14 = load i32, i32* %12
%15 = getelementptr inbounds i32, i32* %11, i64 1
store i32 %14, i32* %15
%16 = icmp eq i32 %14, 0
br i1 %16, label %17, label %10
17: ; preds = %10
ret i32* %0
}