#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 */
scalar_t__ islower(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int scanf(char *, unsigned char *, unsigned int *);
int toupper(char);
int main(int argc, char *argv[]) {
  unsigned int weights[0x100];
  unsigned int i, j;
  unsigned char c;
  for (i = 0; i < 0x100; i++)
    weights[i] = 0;
  while (scanf("%c %u\n", &c, &j) == 2)
    weights[c] = j;
  puts("/* THIS IS A GENERATED TABLE, see data/basetoc.c. */");
  printf("static const unsigned short int RAW_");
  for (i = 0; argv[1][i]; i++)
    printf("%c", (islower(argv[1][i]) ? toupper(argv[1][i]) : (argv[1][i])));
  puts("[] = {");
  for (i = 0; i < 0x100; i++) {
    if (i % 8 == 0)
      printf("  ");
    printf("%4u", weights[i]);
    if (i % 8 == 7)
      printf(",  /* 0x%02x */\n", i - 7);
    else
      printf(", ");
  }
  puts("};\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x414(%rbp)
cmpl   $0x100,-0x414(%rbp)
jae    11a8 <main+0x58>
mov    -0x414(%rbp),%eax
movl   $0x0,-0x410(%rbp,%rax,4)
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    1173 <main+0x23>
jmp    11ad <main+0x5d>
lea    0xe4c(%rip),%rdi
lea    -0x419(%rbp),%rsi
lea    -0x418(%rbp),%rdx
call   1070 <scanf@plt>
cmp    $0x2,%eax
jne    11e9 <main+0x99>
mov    -0x418(%rbp),%ecx
movzbl -0x419(%rbp),%eax
mov    %ecx,-0x410(%rbp,%rax,4)
jmp    11ad <main+0x5d>
lea    0xe17(%rip),%rdi
call   1050 <puts@plt>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x414(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x414(%rbp),%ecx
cmpb   $0x0,(%rax,%rcx,1)
je     12a8 <main+0x158>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x414(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <islower@plt>
cmp    $0x0,%rax
je     1268 <main+0x118>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x414(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1040 <toupper@plt>
mov    %eax,-0x420(%rbp)
jmp    1280 <main+0x130>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x414(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x420(%rbp)
mov    -0x420(%rbp),%esi
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    120d <main+0xbd>
lea    0xdb5(%rip),%rdi
call   1050 <puts@plt>
movl   $0x0,-0x414(%rbp)
cmpl   $0x100,-0x414(%rbp)
jae    135e <main+0x20e>
mov    -0x414(%rbp),%eax
and    $0x7,%eax
cmp    $0x0,%eax
jne    12ee <main+0x19e>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x414(%rbp),%eax
mov    -0x410(%rbp,%rax,4),%esi
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x414(%rbp),%eax
and    $0x7,%eax
cmp    $0x7,%eax
jne    1337 <main+0x1e7>
mov    -0x414(%rbp),%esi
sub    $0x7,%esi
lea    0xd47(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1345 <main+0x1f5>
lea    0xd45(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    134a <main+0x1fa>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    12be <main+0x16e>
lea    0xd21(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%r13
lea    0x10(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1080 <memset@plt>
lea    0xe64(%rip),%rdi
lea    0xb(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1090 <scanf@plt>
cmp    $0x2,%eax
jne    11f0 <main+0x80>
lea    0xe49(%rip),%r14
lea    0xb(%rsp),%r15
lea    0xc(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%eax
movzbl 0xb(%rsp),%ecx
mov    %eax,0x10(%rsp,%rcx,4)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1090 <scanf@plt>
cmp    $0x2,%eax
je     11d0 <main+0x60>
lea    0xe10(%rip),%rdi
call   1060 <puts@plt>
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%r13),%rax
mov    (%rax),%al
test   %al,%al
je     1254 <main+0xe4>
mov    $0x1,%ebp
xor    %ebx,%ebx
jmp    1236 <main+0xc6>
nopl   (%rax)
call   1030 <putchar@plt>
mov    0x8(%r13),%rax
mov    %ebp,%ebx
movzbl (%rax,%rbx,1),%eax
add    $0x1,%ebp
test   %al,%al
je     1254 <main+0xe4>
movsbl %al,%edi
call   1040 <islower@plt>
mov    0x8(%r13),%rcx
movsbl (%rcx,%rbx,1),%edi
test   %rax,%rax
je     1220 <main+0xb0>
call   1050 <toupper@plt>
mov    %eax,%edi
jmp    1220 <main+0xb0>
lea    0xe06(%rip),%rdi
call   1060 <puts@plt>
lea    0xe01(%rip),%r14
lea    0xdfd(%rip),%r13
lea    0xe0b(%rip),%r15
lea    0xdf3(%rip),%r12
xor    %ebx,%ebx
jmp    12af <main+0x13f>
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp,%rbx,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
je     12d8 <main+0x168>
mov    %ebx,%ebp
and    $0x7,%ebp
je     1280 <main+0x110>
mov    0x10(%rsp,%rbx,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
cmp    $0x7,%ebp
jne    1298 <main+0x128>
lea    -0x7(%rbx),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    12a2 <main+0x132>
lea    0xda4(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%c %u\0A\00"
@.str.1 = [53 x i8] c"/* THIS IS A GENERATED TABLE, see data/basetoc.c. */\00"
@.str.2 = [37 x i8] c"static const unsigned short int RAW_\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [7 x i8] c"[] = {\00"
@.str.5 = [3 x i8] c" \00"
@.str.6 = [4 x i8] c"%4u\00"
@.str.7 = [17 x i8] c", /* 0x%02x */\0A\00"
@.str.8 = [3 x i8] c", \00"
@.str.9 = [4 x i8] c"};\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %10
10: ; preds = %17, %2
%11 = load i32, i32* %7
%12 = icmp ult i32 %11, 256
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %7
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %15
store i32 0, i32* %16
br label %17
17: ; preds = %13
%18 = load i32, i32* %7
%19 = add i32 %18, 1
store i32 %19, i32* %7
br label %10
20: ; preds = %10
br label %21
21: ; preds = %24, %20
%22 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %9, i32* %8)
%23 = icmp eq i32 %22, 2
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i32, i32* %8
%26 = load i8, i8* %9
%27 = zext i8 %26 to i64
%28 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %27
store i32 %25, i32* %28
br label %21
29: ; preds = %21
%30 = call i32 @puts(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %32
32: ; preds = %72, %29
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = load i32, i32* %7
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = icmp ne i8 %39, 0
br i1 %40, label %41, label %75
41: ; preds = %32
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = load i32, i32* %7
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = load i8, i8* %47
%49 = call i64 @islower(i8 signext %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %60
51: ; preds = %41
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = load i32, i32* %7
%56 = zext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = load i8, i8* %57
%59 = call i32 @toupper(i8 signext %58)
br label %69
60: ; preds = %41
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 1
%63 = load i8*, i8** %62
%64 = load i32, i32* %7
%65 = zext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
br label %69
69: ; preds = %60, %51
%70 = phi i32 [ %59, %51 ], [ %68, %60 ]
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %69
%73 = load i32, i32* %7
%74 = add i32 %73, 1
store i32 %74, i32* %7
br label %32
75: ; preds = %32
%76 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %7
br label %77
77: ; preds = %102, %75
%78 = load i32, i32* %7
%79 = icmp ult i32 %78, 256
br i1 %79, label %80, label %105
80: ; preds = %77
%81 = load i32, i32* %7
%82 = urem i32 %81, 8
%83 = icmp eq i32 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %80
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %86
86: ; preds = %84, %80
%87 = load i32, i32* %7
%88 = zext i32 %87 to i64
%89 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %88
%90 = load i32, i32* %89
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %90)
%92 = load i32, i32* %7
%93 = urem i32 %92, 8
%94 = icmp eq i32 %93, 7
br i1 %94, label %95, label %99
95: ; preds = %86
%96 = load i32, i32* %7
%97 = sub i32 %96, 7
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %97)
br label %101
99: ; preds = %86
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %101
101: ; preds = %99, %95
br label %102
102: ; preds = %101
%103 = load i32, i32* %7
%104 = add i32 %103, 1
store i32 %104, i32* %7
br label %77
105: ; preds = %77
%106 = call i32 @puts(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%c %u\0A\00"
@.str.1 = [53 x i8] c"/* THIS IS A GENERATED TABLE, see data/basetoc.c. */\00"
@.str.2 = [37 x i8] c"static const unsigned short int RAW_\00"
@.str.4 = [7 x i8] c"[] = {\00"
@.str.5 = [3 x i8] c" \00"
@.str.6 = [4 x i8] c"%4u\00"
@.str.7 = [17 x i8] c", /* 0x%02x */\0A\00"
@.str.8 = [3 x i8] c", \00"
@.str.9 = [4 x i8] c"};\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i32]
%4 = bitcast [256 x i32]* %3 to i8*
%5 = alloca i32
%6 = alloca i8
%7 = bitcast i32* %5 to i8*
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %6, i32* %5)
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %17
10: ; preds = %2, %10
%11 = load i32, i32* %5
%12 = load i8, i8* %6
%13 = zext i8 %12 to i64
%14 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %13
store i32 %11, i32* %14
%15 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %6, i32* %5)
%16 = icmp eq i32 %15, 2
br i1 %16, label %10, label %17
17: ; preds = %10, %2
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %46, label %24
24: ; preds = %17, %37
%25 = phi i8 [ %44, %37 ], [ %22, %17 ]
%26 = phi i64 [ %42, %37 ], [ 0, %17 ]
%27 = phi i32 [ %40, %37 ], [ 0, %17 ]
%28 = call i64 @islower(i8 signext %25)
%29 = icmp eq i64 %28, 0
%30 = load i8*, i8** %20
%31 = getelementptr inbounds i8, i8* %30, i64 %26
%32 = load i8, i8* %31
br i1 %29, label %35, label %33
33: ; preds = %24
%34 = call i32 @toupper(i8 signext %32)
br label %37
35: ; preds = %24
%36 = sext i8 %32 to i32
br label %37
37: ; preds = %35, %33
%38 = phi i32 [ %34, %33 ], [ %36, %35 ]
%39 = call i32 @putchar(i32 %38)
%40 = add i32 %27, 1
%41 = load i8*, i8** %20
%42 = zext i32 %40 to i64
%43 = getelementptr inbounds i8, i8* %41, i64 %42
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 0
br i1 %45, label %46, label %24
46: ; preds = %37, %17
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %48
48: ; preds = %46, %69
%49 = phi i64 [ 0, %46 ], [ %70, %69 ]
%50 = trunc i64 %49 to i32
%51 = and i32 %50, 7
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %58
53: ; preds = %48
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%55 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %49
%56 = load i32, i32* %55
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %56)
br label %67
58: ; preds = %48
%59 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %49
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %60)
%62 = icmp eq i32 %51, 7
br i1 %62, label %63, label %67
63: ; preds = %58
%64 = trunc i64 %49 to i32
%65 = add i32 %64, -7
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32 %65)
br label %69
67: ; preds = %53, %58
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %69
69: ; preds = %63, %67
%70 = add nuw nsw i64 %49, 1
%71 = icmp eq i64 %70, 256
br i1 %71, label %72, label %48
72: ; preds = %69
%73 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
ret i32 0
}