#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*/ sal_strcpy(char *, char const *);
char *sal_strcat(char *s1, const char *s2) {
  char *s = s1;
  if ((((long)s1 & (sizeof(long) - 1)) == 0)) {
    unsigned long *aligned_s1 = (unsigned long *)s1;
    while (!(((*aligned_s1) - 0x01010101) & ~(*aligned_s1) & 0x80808080))
      aligned_s1++;
    s1 = (char *)aligned_s1;
  }
  while (*s1)
    s1++;
  sal_strcpy(s1, s2);
  return s;
}


x86 assembly (clang, -O0):
<sal_strcat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
and    $0x7,%rax
cmp    $0x0,%rax
jne    1199 <sal_strcat+0x89>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
sub    $0x1010101,%rax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%rcx
xor    $0xffffffffffffffff,%rcx
and    %rcx,%rax
movabs $0x80808080,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1180 <sal_strcat+0x70>
jmp    1191 <sal_strcat+0x81>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1142 <sal_strcat+0x32>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    119e <sal_strcat+0x8e>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11bc <sal_strcat+0xac>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    119e <sal_strcat+0x8e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <sal_strcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sal_strcat>:
push   %rbx
mov    %rdi,%rbx
test   $0x7,%bl
jne    114c <sal_strcat+0x3c>
mov    $0x80808080,%eax
lea    -0x8(%rbx),%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x8(%rdi),%ecx
add    $0x8,%rdi
lea    (%rax,%rcx,1),%edx
add    $0x7e7e7e7f,%edx
and    $0x80808080,%ecx
xor    %eax,%ecx
test   %edx,%ecx
je     1130 <sal_strcat+0x20>
add    $0xffffffffffffffff,%rdi
cmpb   $0x0,0x1(%rdi)
lea    0x1(%rdi),%rdi
jne    1150 <sal_strcat+0x40>
call   1030 <sal_strcpy@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @sal_strcat(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
store i8* %7, i8** %5
%8 = load i8*, i8** %3
%9 = ptrtoint i8* %8 to i64
%10 = and i64 %9, 7
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %32
12: ; preds = %2
%13 = load i8*, i8** %3
%14 = bitcast i8* %13 to i64*
store i64* %14, i64** %6
br label %15
15: ; preds = %26, %12
%16 = load i64*, i64** %6
%17 = load i64, i64* %16
%18 = sub i64 %17, 16843009
%19 = load i64*, i64** %6
%20 = load i64, i64* %19
%21 = xor i64 %20, -1
%22 = and i64 %18, %21
%23 = and i64 %22, 2155905152
%24 = icmp ne i64 %23, 0
%25 = xor i1 %24, true
br i1 %25, label %26, label %29
26: ; preds = %15
%27 = load i64*, i64** %6
%28 = getelementptr inbounds i64, i64* %27, i32 1
store i64* %28, i64** %6
br label %15
29: ; preds = %15
%30 = load i64*, i64** %6
%31 = bitcast i64* %30 to i8*
store i8* %31, i8** %3
br label %32
32: ; preds = %29, %2
br label %33
33: ; preds = %37, %32
%34 = load i8*, i8** %3
%35 = load i8, i8* %34
%36 = icmp ne i8 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %3
br label %33
40: ; preds = %33
%41 = load i8*, i8** %3
%42 = load i8*, i8** %4
%43 = call i32 @sal_strcpy(i8* %41, i8* %42)
%44 = load i8*, i8** %5
ret i8* %44
}

LLVM IR (-O2):
define i8* @sal_strcat(i8* returned %0, i8* %1) {
%3 = ptrtoint i8* %0 to i64
%4 = and i64 %3, 7
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %2
%7 = bitcast i8* %0 to i64*
br label %8
8: ; preds = %8, %6
%9 = phi i64* [ %7, %6 ], [ %16, %8 ]
%10 = load i64, i64* %9
%11 = add i64 %10, 4278124287
%12 = and i64 %10, 2155905152
%13 = xor i64 %12, 2155905152
%14 = and i64 %13, %11
%15 = icmp eq i64 %14, 0
%16 = getelementptr inbounds i64, i64* %9, i64 1
br i1 %15, label %8, label %17
17: ; preds = %8
%18 = bitcast i64* %9 to i8*
br label %19
19: ; preds = %17, %2
%20 = phi i8* [ %0, %2 ], [ %18, %17 ]
br label %21
21: ; preds = %19, %21
%22 = phi i8* [ %25, %21 ], [ %20, %19 ]
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
%25 = getelementptr inbounds i8, i8* %22, i64 1
br i1 %24, label %26, label %21
26: ; preds = %21
%27 = tail call i32 @sal_strcpy(i8* %22, i8* %1)
ret i8* %0
}