#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*/ memcpy(char *, char *, int);
char *htmlspecialchars_nmov(char *out, char *in, int len) {
  char *o = out;
  while (*in && --len >= 0) {
    switch (*in) {
    case '&':
      memcpy(o, "&amp;", 5);
      o += 5;
      break;
      ;
    case '<':
      memcpy(o, "&lt;", 4);
      o += 4;
      break;
      ;
    case '>':
      memcpy(o, "&gt;", 4);
      o += 4;
      break;
      ;
    case '"':
      memcpy(o, "&quot;", 6);
      o += 6;
      break;
      ;
    default:
      *o++ = *in;
      break;
    }
    in++;
  }
  *o = 0;
  return o;
}


x86 assembly (clang, -O0):
<htmlspecialchars_nmov>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     1152 <htmlspecialchars_nmov+0x42>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
setge  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1162 <htmlspecialchars_nmov+0x52>
jmp    124f <htmlspecialchars_nmov+0x13f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x1c,%eax
ja     1227 <htmlspecialchars_nmov+0x117>
mov    -0x30(%rbp),%rax
lea    0xe7a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rdi
lea    0xeda(%rip),%rsi
mov    $0x5,%edx
call   1030 <memcpy@plt>
mov    -0x20(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x20(%rbp)
jmp    123e <htmlspecialchars_nmov+0x12e>
mov    -0x20(%rbp),%rdi
lea    0xeba(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    123e <htmlspecialchars_nmov+0x12e>
mov    -0x20(%rbp),%rdi
lea    0xe99(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    123e <htmlspecialchars_nmov+0x12e>
mov    -0x20(%rbp),%rdi
lea    0xe78(%rip),%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
mov    -0x20(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x20(%rbp)
jmp    123e <htmlspecialchars_nmov+0x12e>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112b <htmlspecialchars_nmov+0x1b>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<htmlspecialchars_nmov>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rsi),%al
test   %al,%al
je     11c8 <htmlspecialchars_nmov+0xb8>
mov    %edx,%ebp
mov    %rsi,%rbx
add    $0x1,%rbx
lea    0xec8(%rip),%r12
lea    0xf3b(%rip),%r13
lea    0xf39(%rip),%r15
jmp    115e <htmlspecialchars_nmov+0x4e>
mov    %al,(%r14)
add    $0x1,%r14
nop
movzbl (%rbx),%eax
add    $0x1,%rbx
add    $0xffffffff,%ebp
test   %al,%al
je     11c8 <htmlspecialchars_nmov+0xb8>
test   %ebp,%ebp
jle    11c8 <htmlspecialchars_nmov+0xb8>
movsbl %al,%ecx
add    $0xffffffde,%ecx
cmp    $0x1c,%ecx
ja     1148 <htmlspecialchars_nmov+0x38>
movslq (%r12,%rcx,4),%rcx
add    %r12,%rcx
jmp    *%rcx
mov    %r14,%rdi
lea    0xf04(%rip),%rsi
mov    $0x6,%edx
call   1030 <memcpy@plt>
add    $0x6,%r14
jmp    1150 <htmlspecialchars_nmov+0x40>
mov    %r14,%rdi
lea    0xeda(%rip),%rsi
mov    $0x5,%edx
call   1030 <memcpy@plt>
add    $0x5,%r14
jmp    1150 <htmlspecialchars_nmov+0x40>
mov    %r14,%rdi
mov    %r13,%rsi
jmp    11b8 <htmlspecialchars_nmov+0xa8>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
add    $0x4,%r14
jmp    1150 <htmlspecialchars_nmov+0x40>
movb   $0x0,(%r14)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"&amp;\00"
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [5 x i8] c"&gt;\00"
@.str.3 = [7 x i8] c"&quot;\00"
define i8* @htmlspecialchars_nmov(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
store i8* %8, i8** %7
br label %9
9: ; preds = %49, %3
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i32, i32* %6
%16 = add nsw i32 %15, -1
store i32 %16, i32* %6
%17 = icmp sge i32 %16, 0
br label %18
18: ; preds = %14, %9
%19 = phi i1 [ false, %9 ], [ %17, %14 ]
br i1 %19, label %20, label %52
20: ; preds = %18
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
switch i32 %23, label %44 [
i32 38, label %24
i32 60, label %29
i32 62, label %34
i32 34, label %39
]
24: ; preds = %20
%25 = load i8*, i8** %7
%26 = call i32 @memcpy(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i64 5
store i8* %28, i8** %7
br label %49
29: ; preds = %20
%30 = load i8*, i8** %7
%31 = call i32 @memcpy(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i64 4
store i8* %33, i8** %7
br label %49
34: ; preds = %20
%35 = load i8*, i8** %7
%36 = call i32 @memcpy(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%37 = load i8*, i8** %7
%38 = getelementptr inbounds i8, i8* %37, i64 4
store i8* %38, i8** %7
br label %49
39: ; preds = %20
%40 = load i8*, i8** %7
%41 = call i32 @memcpy(i8* %40, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%42 = load i8*, i8** %7
%43 = getelementptr inbounds i8, i8* %42, i64 6
store i8* %43, i8** %7
br label %49
44: ; preds = %20
%45 = load i8*, i8** %5
%46 = load i8, i8* %45
%47 = load i8*, i8** %7
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %7
store i8 %46, i8* %47
br label %49
49: ; preds = %44, %39, %34, %29, %24
%50 = load i8*, i8** %5
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %5
br label %9
52: ; preds = %18
%53 = load i8*, i8** %7
store i8 0, i8* %53
%54 = load i8*, i8** %7
ret i8* %54
}

LLVM IR (-O2):
@.str = [6 x i8] c"&amp;\00"
@.str.1 = [5 x i8] c"&lt;\00"
@.str.2 = [5 x i8] c"&gt;\00"
@.str.3 = [7 x i8] c"&quot;\00"
define i8* @htmlspecialchars_nmov(i8* %0, i8* nocapture %1, i32 %2) {
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 0
br i1 %5, label %34, label %6
6: ; preds = %3, %29
%7 = phi i8 [ %32, %29 ], [ %4, %3 ]
%8 = phi i8* [ %30, %29 ], [ %0, %3 ]
%9 = phi i32 [ %11, %29 ], [ %2, %3 ]
%10 = phi i8* [ %31, %29 ], [ %1, %3 ]
%11 = add nsw i32 %9, -1
%12 = icmp sgt i32 %9, 0
br i1 %12, label %13, label %34
13: ; preds = %6
%14 = sext i8 %7 to i32
switch i32 %14, label %27 [
i32 38, label %15
i32 60, label %18
i32 62, label %21
i32 34, label %24
]
15: ; preds = %13
%16 = tail call i32 @memcpy(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%17 = getelementptr inbounds i8, i8* %8, i64 5
br label %29
18: ; preds = %13
%19 = tail call i32 @memcpy(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%20 = getelementptr inbounds i8, i8* %8, i64 4
br label %29
21: ; preds = %13
%22 = tail call i32 @memcpy(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%23 = getelementptr inbounds i8, i8* %8, i64 4
br label %29
24: ; preds = %13
%25 = tail call i32 @memcpy(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%26 = getelementptr inbounds i8, i8* %8, i64 6
br label %29
27: ; preds = %13
%28 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %7, i8* %8
br label %29
29: ; preds = %27, %24, %21, %18, %15
%30 = phi i8* [ %28, %27 ], [ %26, %24 ], [ %23, %21 ], [ %20, %18 ], [ %17, %15 ]
%31 = getelementptr inbounds i8, i8* %10, i64 1
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 0
br i1 %33, label %34, label %6
34: ; preds = %6, %29, %3
%35 = phi i8* [ %0, %3 ], [ %30, %29 ], [ %8, %6 ]
store i8 0, i8* %35
ret i8* %35
}