#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 char wchar_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
wchar_t *wcscat(wchar_t *s1, const wchar_t *s2) {
  wchar_t *p;
  wchar_t *q;
  const wchar_t *r;
  assert(s1 != NULL);
  assert(s2 != NULL);
  p = s1;
  while (*p)
    p++;
  q = p;
  r = s2;
  while (*r)
    *q++ = *r++;
  *q = '\0';
  return s1;
}


x86 assembly (clang, -O0):
<wcscat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     116a <wcscat+0x5a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    114c <wcscat+0x3c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ae <wcscat+0x9e>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    117a <wcscat+0x6a>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcscat>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
mov    %r14,%rax
nopl   0x0(%rax)
mov    %rax,%rdx
add    $0x1,%rax
cmpb   $0x0,(%rdx)
jne    1140 <wcscat+0x30>
mov    (%rbx),%cl
test   %cl,%cl
je     1176 <wcscat+0x66>
mov    $0xffffffffffffffff,%rdx
nopl   0x0(%rax)
mov    %cl,(%rax,%rdx,1)
movzbl 0x2(%rbx,%rdx,1),%ecx
add    $0x1,%rdx
test   %cl,%cl
jne    1160 <wcscat+0x50>
add    %rdx,%rax
mov    %rax,%rdx
movb   $0x0,(%rdx)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @wcscat(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i8*, i8** %4
%13 = icmp ne i8* %12, null
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i8*, i8** %3
store i8* %16, i8** %5
br label %17
17: ; preds = %21, %2
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
%20 = icmp ne i8 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %5
br label %17
24: ; preds = %17
%25 = load i8*, i8** %5
store i8* %25, i8** %6
%26 = load i8*, i8** %4
store i8* %26, i8** %7
br label %27
27: ; preds = %31, %24
%28 = load i8*, i8** %7
%29 = load i8, i8* %28
%30 = icmp ne i8 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %27
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %7
%34 = load i8, i8* %32
%35 = load i8*, i8** %6
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %6
store i8 %34, i8* %35
br label %27
37: ; preds = %27
%38 = load i8*, i8** %6
store i8 0, i8* %38
%39 = load i8*, i8** %3
ret i8* %39
}

LLVM IR (-O2):
define i8* @wcscat(i8* returned %0, i8* %1) {
%3 = icmp ne i8* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp ne i8* %1, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
br label %9
9: ; preds = %9, %2
%10 = phi i8* [ %0, %2 ], [ %13, %9 ]
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
%13 = getelementptr inbounds i8, i8* %10, i64 1
br i1 %12, label %14, label %9
14: ; preds = %9
%15 = load i8, i8* %1
%16 = icmp eq i8 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %14, %17
%18 = phi i8 [ %23, %17 ], [ %15, %14 ]
%19 = phi i8* [ %21, %17 ], [ %1, %14 ]
%20 = phi i8* [ %22, %17 ], [ %10, %14 ]
%21 = getelementptr inbounds i8, i8* %19, i64 1
%22 = getelementptr inbounds i8, i8* %20, i64 1
store i8 %18, i8* %20
%23 = load i8, i8* %21
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %17
25: ; preds = %17, %14
%26 = phi i8* [ %10, %14 ], [ %22, %17 ]
store i8 0, i8* %26
ret i8* %0
}