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

/* Variables and functions */
int /*<<< orphan*/ emit_alias(int /*<<< orphan*/ *, char const *const,
                              char const *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ putc(unsigned char, int /*<<< orphan*/ *);
void emit_encoding(FILE *out1, FILE *out2, const char *const *names, size_t n,
                   const char *c_name) {
  fprintf(out2, "grep 'sizeof(\"");
  {
    const char *s = *names;
    for (; *s; s++) {
      unsigned char c = *(unsigned char *)s;
      if (c >= 0x80)
        exit(1);
      if (c >= 'a' && c <= 'z')
        c -= 'a' - 'A';
      putc(c, out2);
    }
  }
  fprintf(out2, "\")' tmp.h | sed -e 's|^.*\\(stringpool_str[0-9]*\\).*$|  "
                "(int)(long)\\&((struct stringpool_t *)0)->\\1,|'\n");
  for (; n > 0; names++, n--)
    emit_alias(out1, *names, c_name);
}


x86 assembly (clang, -O0):
<emit_encoding>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ea <emit_encoding+0xaa>
mov    -0x30(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x31(%rbp)
movzbl -0x31(%rbp),%eax
cmp    $0x80,%eax
jl     11a6 <emit_encoding+0x66>
mov    $0x1,%edi
call   1060 <exit@plt>
movzbl -0x31(%rbp),%eax
cmp    $0x61,%eax
jl     11ca <emit_encoding+0x8a>
movzbl -0x31(%rbp),%eax
cmp    $0x7a,%eax
jg     11ca <emit_encoding+0x8a>
movzbl -0x31(%rbp),%eax
sub    $0x20,%eax
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
mov    -0x10(%rbp),%rsi
movzbl %al,%edi
call   1030 <putc@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1177 <emit_encoding+0x37>
mov    -0x10(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   1040 <fprintf@plt>
cmpq   $0x0,-0x20(%rbp)
jbe    1236 <emit_encoding+0xf6>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <emit_alias@plt>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    11fa <emit_encoding+0xba>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emit_encoding>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%r12
lea    0xe9f(%rip),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
mov    0x0(%r13),%rbp
mov    0x0(%rbp),%al
test   %al,%al
je     11bd <emit_encoding+0x7d>
add    $0x1,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %al,%al
js     1208 <emit_encoding+0xc8>
lea    -0x61(%rax),%ecx
lea    -0x20(%rax),%edx
cmp    $0x1a,%cl
movzbl %al,%eax
movzbl %dl,%ecx
cmovae %eax,%ecx
movzbl %cl,%edi
mov    %rbx,%rsi
call   1030 <putc@plt>
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
jne    1190 <emit_encoding+0x50>
lea    0xe4b(%rip),%rdi
mov    $0x66,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
test   %r15,%r15
je     11f9 <emit_encoding+0xb9>
xor    %ebx,%ebx
nopl   (%rax)
mov    0x0(%r13,%rbx,8),%rsi
mov    %r12,%rdi
mov    %r14,%rdx
call   1040 <emit_alias@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11e0 <emit_encoding+0xa0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"grep 'sizeof(\22\00"
@.str.1 = [103 x i8] c"\22)' tmp.h | sed -e 's|^.*\\(stringpool_str[0-9]*\\).*$| (int)(long)\\&((struct stringpool_t *)0)->\\1,|'\0A\00"
define void @emit_encoding(i32* %0, i32* %1, i8** %2, i64 %3, i8* %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8**
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8
store i32* %0, i32** %6
store i32* %1, i32** %7
store i8** %2, i8*** %8
store i64 %3, i64* %9
store i8* %4, i8** %10
%13 = load i32*, i32** %7
%14 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%15 = load i8**, i8*** %8
%16 = load i8*, i8** %15
store i8* %16, i8** %11
br label %17
17: ; preds = %46, %5
%18 = load i8*, i8** %11
%19 = load i8, i8* %18
%20 = icmp ne i8 %19, 0
br i1 %20, label %21, label %49
21: ; preds = %17
%22 = load i8*, i8** %11
%23 = load i8, i8* %22
store i8 %23, i8* %12
%24 = load i8, i8* %12
%25 = zext i8 %24 to i32
%26 = icmp sge i32 %25, 128
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %21
%30 = load i8, i8* %12
%31 = zext i8 %30 to i32
%32 = icmp sge i32 %31, 97
br i1 %32, label %33, label %42
33: ; preds = %29
%34 = load i8, i8* %12
%35 = zext i8 %34 to i32
%36 = icmp sle i32 %35, 122
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load i8, i8* %12
%39 = zext i8 %38 to i32
%40 = sub nsw i32 %39, 32
%41 = trunc i32 %40 to i8
store i8 %41, i8* %12
br label %42
42: ; preds = %37, %33, %29
%43 = load i8, i8* %12
%44 = load i32*, i32** %7
%45 = call i32 @putc(i8 zeroext %43, i32* %44)
br label %46
46: ; preds = %42
%47 = load i8*, i8** %11
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %11
br label %17
49: ; preds = %17
%50 = load i32*, i32** %7
%51 = call i32 @fprintf(i32* %50, i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.1, i64 0, i64 0))
br label %52
52: ; preds = %61, %49
%53 = load i64, i64* %9
%54 = icmp ugt i64 %53, 0
br i1 %54, label %55, label %66
55: ; preds = %52
%56 = load i32*, i32** %6
%57 = load i8**, i8*** %8
%58 = load i8*, i8** %57
%59 = load i8*, i8** %10
%60 = call i32 @emit_alias(i32* %56, i8* %58, i8* %59)
br label %61
61: ; preds = %55
%62 = load i8**, i8*** %8
%63 = getelementptr inbounds i8*, i8** %62, i32 1
store i8** %63, i8*** %8
%64 = load i64, i64* %9
%65 = add i64 %64, -1
store i64 %65, i64* %9
br label %52
66: ; preds = %52
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"grep 'sizeof(\22\00"
@.str.1 = [103 x i8] c"\22)' tmp.h | sed -e 's|^.*\\(stringpool_str[0-9]*\\).*$| (int)(long)\\&((struct stringpool_t *)0)->\\1,|'\0A\00"
define void @emit_encoding(i32* %0, i32* nocapture %1, i8** nocapture %2, i64 %3, i8* %4) {
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i64 14, i64 1, i32* %1)
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %25, label %10
10: ; preds = %5, %16
%11 = phi i8 [ %23, %16 ], [ %8, %5 ]
%12 = phi i8* [ %22, %16 ], [ %7, %5 ]
%13 = icmp slt i8 %11, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %10
%17 = add nsw i8 %11, -97
%18 = icmp ult i8 %17, 26
%19 = add nsw i8 %11, -32
%20 = select i1 %18, i8 %19, i8 %11
%21 = tail call i32 @putc(i8 zeroext %20, i32* %1)
%22 = getelementptr inbounds i8, i8* %12, i64 1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %10
25: ; preds = %16, %5
%26 = tail call i64 @fwrite(i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.1, i64 0, i64 0), i64 102, i64 1, i32* %1)
%27 = icmp eq i64 %3, 0
br i1 %27, label %36, label %28
28: ; preds = %25, %28
%29 = phi i8** [ %33, %28 ], [ %2, %25 ]
%30 = phi i64 [ %34, %28 ], [ %3, %25 ]
%31 = load i8*, i8** %29
%32 = tail call i32 @emit_alias(i32* %0, i8* %31, i8* %4)
%33 = getelementptr inbounds i8*, i8** %29, i64 1
%34 = add i64 %30, -1
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %28
36: ; preds = %28, %25
ret void
}