#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 /*<<< orphan*/ Output;

/* Variables and functions */
int /*<<< orphan*/ strcpy(char *, char *);
char *NormalizeStringN(char *Input, int PadTo) {
  static char Output[2000], *EndPoint = &Output[sizeof(Output) - 1 - 6];
  char *s;
  int Pos = 0;
  for (s = Output, *s = 0; *Input != 0 && s < EndPoint; Input++) {
    if (*Input == '<') {
      strcpy(s, "&lt;");
      s += 4;
      Pos++;
    } else if (*Input == '&') {
      strcpy(s, "&amp;");
      s += 5;
      Pos++;
    } else if (*Input == '\t') {
      int i;
      i = ((Pos + 8) & ~7) - Pos;
      Pos += i;
      for (; i > 0; i--) {
        strcpy(s, " ");
        s += 1;
      }
    } else {
      *s++ = *Input;
      Pos++;
    }
  }
  for (; Pos < PadTo; Pos++) {
    strcpy(s, " ");
    s += 1;
  }
  *s = 0;
  return (Output);
}


x86 assembly (clang, -O0):
<NormalizeStringN>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0x2f13(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     115e <NormalizeStringN+0x4e>
mov    -0x18(%rbp),%rax
cmp    0x2ed0(%rip),%rax
setb   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    116e <NormalizeStringN+0x5e>
jmp    1283 <NormalizeStringN+0x173>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3c,%eax
jne    11a8 <NormalizeStringN+0x98>
mov    -0x18(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    126d <NormalizeStringN+0x15d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x26,%eax
jne    11e2 <NormalizeStringN+0xd2>
mov    -0x18(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1268 <NormalizeStringN+0x158>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
jne    1243 <NormalizeStringN+0x133>
mov    -0x1c(%rbp),%eax
add    $0x8,%eax
and    $0xfffffff8,%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    123e <NormalizeStringN+0x12e>
mov    -0x18(%rbp),%rdi
lea    0xdec(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    120a <NormalizeStringN+0xfa>
jmp    1263 <NormalizeStringN+0x153>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1268 <NormalizeStringN+0x158>
jmp    126d <NormalizeStringN+0x15d>
jmp    1272 <NormalizeStringN+0x162>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1138 <NormalizeStringN+0x28>
jmp    1288 <NormalizeStringN+0x178>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12be <NormalizeStringN+0x1ae>
mov    -0x18(%rbp),%rdi
lea    0xd6c(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1288 <NormalizeStringN+0x178>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2d74(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NormalizeStringN>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
movb   $0x0,0x2f1b(%rip)
mov    (%rdi),%al
test   %al,%al
je     1205 <NormalizeStringN+0xf5>
mov    %rdi,%rbp
lea    0x2f07(%rip),%rbx
xor    %r12d,%r12d
lea    0xec8(%rip),%r15
lea    0x36bf(%rip),%r13
nopw   0x0(%rax,%rax,1)
cmp    $0x9,%al
je     1180 <NormalizeStringN+0x70>
cmp    $0x26,%al
je     11c0 <NormalizeStringN+0xb0>
cmp    $0x3c,%al
jne    11e0 <NormalizeStringN+0xd0>
mov    %rbx,%rdi
lea    0xe96(%rip),%rsi
call   1030 <strcpy@plt>
add    $0x4,%rbx
jmp    11e6 <NormalizeStringN+0xd6>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x8(%r12),%r13d
and    $0xfffffff8,%r13d
cmp    %r12d,%r13d
jle    11b4 <NormalizeStringN+0xa4>
not    %r12d
add    %r13d,%r12d
not    %r12
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
add    $0x1,%rbx
inc    %r12
jne    11a0 <NormalizeStringN+0x90>
mov    %r13d,%r12d
lea    0x364b(%rip),%r13
jmp    11ea <NormalizeStringN+0xda>
mov    %rbx,%rdi
lea    0xe3b(%rip),%rsi
call   1030 <strcpy@plt>
add    $0x5,%rbx
jmp    11e6 <NormalizeStringN+0xd6>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %al,(%rbx)
add    $0x1,%rbx
add    $0x1,%r12d
mov    0x1(%rbp),%al
test   %al,%al
je     11fe <NormalizeStringN+0xee>
add    $0x1,%rbp
cmp    %r13,%rbx
jb     1150 <NormalizeStringN+0x40>
cmp    %r14d,%r12d
jl     1214 <NormalizeStringN+0x104>
jmp    1235 <NormalizeStringN+0x125>
lea    0x2e34(%rip),%rbx
xor    %r12d,%r12d
cmp    %r14d,%r12d
jge    1235 <NormalizeStringN+0x125>
sub    %r12d,%r14d
lea    0xded(%rip),%rbp
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
add    $0x1,%rbx
add    $0xffffffff,%r14d
jne    1220 <NormalizeStringN+0x110>
movb   $0x0,(%rbx)
lea    0x2e01(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@NormalizeStringN.Output = internal global [2000 x i8] zeroinitializer
@NormalizeStringN.EndPoint = internal global i8* getelementptr inbounds ([2000 x i8], [2000 x i8]* @NormalizeStringN.Output, i32 0, i64 1993)
@.str = [5 x i8] c"&lt;\00"
@.str.1 = [6 x i8] c"&amp;\00"
@.str.2 = [2 x i8] c" \00"
define i8* @NormalizeStringN(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %6
store i8* getelementptr inbounds ([2000 x i8], [2000 x i8]* @NormalizeStringN.Output, i64 0, i64 0), i8** %5
%8 = load i8*, i8** %5
store i8 0, i8* %8
br label %9
9: ; preds = %80, %2
%10 = load i8*, i8** %3
%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 i8*, i8** %5
%16 = load i8*, i8** @NormalizeStringN.EndPoint
%17 = icmp ult i8* %15, %16
br label %18
18: ; preds = %14, %9
%19 = phi i1 [ false, %9 ], [ %17, %14 ]
br i1 %19, label %20, label %83
20: ; preds = %18
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 60
br i1 %24, label %25, label %32
25: ; preds = %20
%26 = load i8*, i8** %5
%27 = call i32 @strcpy(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i64 4
store i8* %29, i8** %5
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %79
32: ; preds = %20
%33 = load i8*, i8** %3
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 38
br i1 %36, label %37, label %44
37: ; preds = %32
%38 = load i8*, i8** %5
%39 = call i32 @strcpy(i8* %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 5
store i8* %41, i8** %5
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %78
44: ; preds = %32
%45 = load i8*, i8** %3
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 9
br i1 %48, label %49, label %70
49: ; preds = %44
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 8
%52 = and i32 %51, -8
%53 = load i32, i32* %6
%54 = sub nsw i32 %52, %53
store i32 %54, i32* %7
%55 = load i32, i32* %7
%56 = load i32, i32* %6
%57 = add nsw i32 %56, %55
store i32 %57, i32* %6
br label %58
58: ; preds = %66, %49
%59 = load i32, i32* %7
%60 = icmp sgt i32 %59, 0
br i1 %60, label %61, label %69
61: ; preds = %58
%62 = load i8*, i8** %5
%63 = call i32 @strcpy(i8* %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%64 = load i8*, i8** %5
%65 = getelementptr inbounds i8, i8* %64, i64 1
store i8* %65, i8** %5
br label %66
66: ; preds = %61
%67 = load i32, i32* %7
%68 = add nsw i32 %67, -1
store i32 %68, i32* %7
br label %58
69: ; preds = %58
br label %77
70: ; preds = %44
%71 = load i8*, i8** %3
%72 = load i8, i8* %71
%73 = load i8*, i8** %5
%74 = getelementptr inbounds i8, i8* %73, i32 1
store i8* %74, i8** %5
store i8 %72, i8* %73
%75 = load i32, i32* %6
%76 = add nsw i32 %75, 1
store i32 %76, i32* %6
br label %77
77: ; preds = %70, %69
br label %78
78: ; preds = %77, %37
br label %79
79: ; preds = %78, %25
br label %80
80: ; preds = %79
%81 = load i8*, i8** %3
%82 = getelementptr inbounds i8, i8* %81, i32 1
store i8* %82, i8** %3
br label %9
83: ; preds = %18
br label %84
84: ; preds = %93, %83
%85 = load i32, i32* %6
%86 = load i32, i32* %4
%87 = icmp slt i32 %85, %86
br i1 %87, label %88, label %96
88: ; preds = %84
%89 = load i8*, i8** %5
%90 = call i32 @strcpy(i8* %89, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%91 = load i8*, i8** %5
%92 = getelementptr inbounds i8, i8* %91, i64 1
store i8* %92, i8** %5
br label %93
93: ; preds = %88
%94 = load i32, i32* %6
%95 = add nsw i32 %94, 1
store i32 %95, i32* %6
br label %84
96: ; preds = %84
%97 = load i8*, i8** %5
store i8 0, i8* %97
ret i8* getelementptr inbounds ([2000 x i8], [2000 x i8]* @NormalizeStringN.Output, i64 0, i64 0)
}

LLVM IR (-O2):
@NormalizeStringN.Output = internal global [2000 x i8] zeroinitializer
@.str = [5 x i8] c"&lt;\00"
@.str.1 = [6 x i8] c"&amp;\00"
@.str.2 = [2 x i8] c" \00"
define i8* @NormalizeStringN(i8* nocapture %0, i32 %1) {
store i8 0, i8* getelementptr inbounds ([2000 x i8], [2000 x i8]* @NormalizeStringN.Output, i64 0, i64 0)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %39, %2
%6 = phi i8* [ getelementptr inbounds ([2000 x i8], [2000 x i8]* @NormalizeStringN.Output, i64 0, i64 0), %2 ], [ %40, %39 ]
%7 = phi i32 [ 0, %2 ], [ %41, %39 ]
%8 = icmp slt i32 %7, %1
br i1 %8, label %47, label %54
9: ; preds = %2, %39
%10 = phi i8 [ %43, %39 ], [ %3, %2 ]
%11 = phi i32 [ %41, %39 ], [ 0, %2 ]
%12 = phi i8* [ %40, %39 ], [ getelementptr inbounds ([2000 x i8], [2000 x i8]* @NormalizeStringN.Output, i64 0, i64 0), %2 ]
%13 = phi i8* [ %42, %39 ], [ %0, %2 ]
switch i8 %10, label %36 [
i8 60, label %14
i8 38, label %18
i8 9, label %22
]
14: ; preds = %9
%15 = tail call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds i8, i8* %12, i64 4
%17 = add nsw i32 %11, 1
br label %39
18: ; preds = %9
%19 = tail call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%20 = getelementptr inbounds i8, i8* %12, i64 5
%21 = add nsw i32 %11, 1
br label %39
22: ; preds = %9
%23 = add nsw i32 %11, 8
%24 = and i32 %23, -8
%25 = icmp sgt i32 %24, %11
br i1 %25, label %26, label %39
26: ; preds = %22
%27 = xor i32 %11, -1
%28 = add i32 %24, %27
%29 = zext i32 %28 to i64
%30 = getelementptr i8, i8* %12, i64 %29
br label %31
31: ; preds = %26, %31
%32 = phi i8* [ %34, %31 ], [ %12, %26 ]
%33 = tail call i32 @strcpy(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%34 = getelementptr inbounds i8, i8* %32, i64 1
%35 = icmp eq i8* %32, %30
br i1 %35, label %39, label %31
36: ; preds = %9
%37 = getelementptr inbounds i8, i8* %12, i64 1
store i8 %10, i8* %12
%38 = add nsw i32 %11, 1
br label %39
39: ; preds = %31, %22, %14, %36, %18
%40 = phi i8* [ %16, %14 ], [ %20, %18 ], [ %37, %36 ], [ %12, %22 ], [ %34, %31 ]
%41 = phi i32 [ %17, %14 ], [ %21, %18 ], [ %38, %36 ], [ %24, %22 ], [ %24, %31 ]
%42 = getelementptr inbounds i8, i8* %13, i64 1
%43 = load i8, i8* %42
%44 = icmp ne i8 %43, 0
%45 = icmp ult i8* %40, getelementptr inbounds ([2000 x i8], [2000 x i8]* @NormalizeStringN.Output, i64 0, i64 1993)
%46 = select i1 %44, i1 %45, i1 false
br i1 %46, label %9, label %5
47: ; preds = %5, %47
%48 = phi i32 [ %52, %47 ], [ %7, %5 ]
%49 = phi i8* [ %51, %47 ], [ %6, %5 ]
%50 = tail call i32 @strcpy(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%51 = getelementptr inbounds i8, i8* %49, i64 1
%52 = add i32 %48, 1
%53 = icmp eq i32 %52, %1
br i1 %53, label %54, label %47
54: ; preds = %47, %5
%55 = phi i8* [ %6, %5 ], [ %51, %47 ]
store i8 0, i8* %55
ret i8* getelementptr inbounds ([2000 x i8], [2000 x i8]* @NormalizeStringN.Output, i64 0, i64 0)
}