#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 */
char *getenv(char *);
int /*<<< orphan*/ printf(char *, ...);
void main() {
  int x;
  printf("Content-type: text/html\n");
  printf("\n");
  printf(
      "<html><head><title>Codepage conversion testing page</title></head>"
      "<center><h1>Codepage %s</h1></center>"
      "<body><table><tr><td>&nbsp;<td>0<td>1<td>2<td>3<td>4<td>5<td>6<td>7<td>8"
      "<td>9<td>A<td>B<td>C<td>D<td>E<td>F",
      getenv("CLIENT_CODEPAGE"));
  for (x = 0; x < 0x100; x++) {
    if ((x % 0x10) == 0)
      printf("<tr><td>%X", x / 0x10);
    printf("<td>");
    switch (x) {
    case '\n':
      printf("&nbsp;");
      break;
    case ' ':
      printf("&nbsp;");
      break;
    case '<':
      printf("&lt;");
      break;
    case '>':
      printf("&gt;");
      break;
    default:
      printf("%c", x);
      break;
    }
  }
  printf("</table></body></html>");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xfa1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rsi
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x100,-0x4(%rbp)
jge    1269 <main+0x149>
mov    -0x4(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11a4 <main+0x84>
mov    -0x4(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xf5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf5c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0xa,%eax
je     11f9 <main+0xd9>
jmp    11c6 <main+0xa6>
mov    -0x8(%rbp),%eax
sub    $0x20,%eax
je     120c <main+0xec>
jmp    11d7 <main+0xb7>
mov    -0x8(%rbp),%eax
sub    $0x3c,%eax
je     121f <main+0xff>
jmp    11e8 <main+0xc8>
mov    -0x8(%rbp),%eax
sub    $0x3e,%eax
je     1232 <main+0x112>
jmp    1245 <main+0x125>
lea    0xf0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1256 <main+0x136>
lea    0xef9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1256 <main+0x136>
lea    0xeed(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1256 <main+0x136>
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1256 <main+0x136>
mov    -0x4(%rbp),%esi
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125b <main+0x13b>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1168 <main+0x48>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xfc9(%rip),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xf6b(%rip),%rdi
call   1030 <getenv@plt>
lea    0xe8c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf5e(%rip),%r14
lea    0xf62(%rip),%rbx
lea    0xf60(%rip),%r15
lea    0xf60(%rip),%r12
lea    0xf5e(%rip),%r13
xor    %ebp,%ebp
jmp    11c5 <main+0x85>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
je     1229 <main+0xe9>
test   $0xf,%bpl
jne    11da <main+0x9a>
mov    %ebp,%esi
shr    $0x4,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x3b,%ebp
jg     1200 <main+0xc0>
cmp    $0xa,%ebp
je     11b0 <main+0x70>
cmp    $0x20,%ebp
je     11b0 <main+0x70>
jmp    1220 <main+0xe0>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x3c,%ebp
je     1210 <main+0xd0>
cmp    $0x3e,%ebp
jne    1220 <main+0xe0>
mov    %r13,%rdi
jmp    11b3 <main+0x73>
nop
mov    %r12,%rdi
jmp    11b3 <main+0x73>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
call   1040 <putchar@plt>
jmp    11ba <main+0x7a>
lea    0xed4(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <printf@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"Content-type: text/html\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [211 x i8] c"<html><head><title>Codepage conversion testing page</title></head><center><h1>Codepage %s</h1></center><body><table><tr><td>&nbsp;<td>0<td>1<td>2<td>3<td>4<td>5<td>6<td>7<td>8<td>9<td>A<td>B<td>C<td>D<td>E<td>F\00"
@.str.3 = [16 x i8] c"CLIENT_CODEPAGE\00"
@.str.4 = [11 x i8] c"<tr><td>%X\00"
@.str.5 = [5 x i8] c"<td>\00"
@.str.6 = [7 x i8] c"&nbsp;\00"
@.str.7 = [5 x i8] c"&lt;\00"
@.str.8 = [5 x i8] c"&gt;\00"
@.str.9 = [3 x i8] c"%c\00"
@.str.10 = [23 x i8] c"</table></body></html>\00"
define void @main() {
%1 = alloca i32
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([211 x i8], [211 x i8]* @.str.2, i64 0, i64 0), i8* %4)
store i32 0, i32* %1
br label %6
6: ; preds = %32, %0
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 256
br i1 %8, label %9, label %35
9: ; preds = %6
%10 = load i32, i32* %1
%11 = srem i32 %10, 16
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i32, i32* %1
%15 = sdiv i32 %14, 16
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %13, %9
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%19 = load i32, i32* %1
switch i32 %19, label %28 [
i32 10, label %20
i32 32, label %22
i32 60, label %24
i32 62, label %26
]
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %31
22: ; preds = %17
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %31
24: ; preds = %17
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %31
26: ; preds = %17
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
br label %31
28: ; preds = %17
%29 = load i32, i32* %1
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %28, %26, %24, %22, %20
br label %32
32: ; preds = %31
%33 = load i32, i32* %1
%34 = add nsw i32 %33, 1
store i32 %34, i32* %1
br label %6
35: ; preds = %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.2 = [211 x i8] c"<html><head><title>Codepage conversion testing page</title></head><center><h1>Codepage %s</h1></center><body><table><tr><td>&nbsp;<td>0<td>1<td>2<td>3<td>4<td>5<td>6<td>7<td>8<td>9<td>A<td>B<td>C<td>D<td>E<td>F\00"
@.str.3 = [16 x i8] c"CLIENT_CODEPAGE\00"
@.str.4 = [11 x i8] c"<tr><td>%X\00"
@.str.5 = [5 x i8] c"<td>\00"
@.str.6 = [7 x i8] c"&nbsp;\00"
@.str.7 = [5 x i8] c"&lt;\00"
@.str.8 = [5 x i8] c"&gt;\00"
@.str.10 = [23 x i8] c"</table></body></html>\00"
@str = [24 x i8] c"Content-type: text/html\00"
define void @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @putchar(i32 10)
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([211 x i8], [211 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %5
5: ; preds = %0, %24
%6 = phi i32 [ 0, %0 ], [ %25, %24 ]
%7 = and i32 %6, 15
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = lshr i32 %6, 4
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %9, %5
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
switch i32 %6, label %22 [
i32 10, label %14
i32 32, label %16
i32 60, label %18
i32 62, label %20
]
14: ; preds = %12
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %24
16: ; preds = %12
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %24
18: ; preds = %12
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %24
20: ; preds = %12
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
br label %24
22: ; preds = %12
%23 = tail call i32 @putchar(i32 %6)
br label %24
24: ; preds = %14, %16, %18, %20, %22
%25 = add nuw nsw i32 %6, 1
%26 = icmp eq i32 %25, 256
br i1 %26, label %27, label %5
27: ; preds = %24
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0))
ret void
}