#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*/ sprintf(char *, char *, char *);
char *pattern(char *word) {
  static char result[128];
  char mapsto[256];
  char mapping[128];
  char line[128];
  char *s, *mapp;
  int nextmapch;
  int i;
  for (i = 0; i < 256; i++)
    mapsto[i] = 0;
  nextmapch = 'A';
  mapp = mapping;
  s = word;
  for (;;) {
    if (mapsto[*s] != 0) {
      *mapp++ = mapsto[*s];
    } else {
      *mapp++ = nextmapch;
      mapsto[*s] = nextmapch++;
    }
    s += 1;
    if (*s == '\0')
      break;
  }
  *mapp = '\0';
  sprintf(result, "%s=", mapping);
  return (result);
}


x86 assembly (clang, -O0):
<pattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x228(%rbp)
cmpl   $0x100,-0x228(%rbp)
jge    115c <pattern+0x4c>
movslq -0x228(%rbp),%rax
movb   $0x0,-0x110(%rbp,%rax,1)
mov    -0x228(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x228(%rbp)
jmp    1129 <pattern+0x19>
movl   $0x41,-0x224(%rbp)
lea    -0x190(%rbp),%rax
mov    %rax,-0x220(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x218(%rbp)
mov    -0x218(%rbp),%rax
movsbq (%rax),%rax
movsbl -0x110(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     11c9 <pattern+0xb9>
mov    -0x218(%rbp),%rax
movsbq (%rax),%rax
mov    -0x110(%rbp,%rax,1),%cl
mov    -0x220(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x220(%rbp)
mov    %cl,(%rax)
jmp    120d <pattern+0xfd>
mov    -0x224(%rbp),%eax
mov    %al,%cl
mov    -0x220(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x220(%rbp)
mov    %cl,(%rax)
mov    -0x224(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x224(%rbp)
mov    %al,%cl
mov    -0x218(%rbp),%rax
movsbq (%rax),%rax
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x218(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x218(%rbp)
mov    -0x218(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1237 <pattern+0x127>
jmp    123c <pattern+0x12c>
jmp    117f <pattern+0x6f>
mov    -0x220(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x190(%rbp),%rdx
lea    0x2dec(%rip),%rdi
lea    0xda5(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2dd9(%rip),%rax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pattern>:
push   %rbx
sub    $0x180,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xf0(%rsp)
mov    (%rdi),%dl
mov    $0x41,%ecx
xor    %eax,%eax
jmp    11aa <pattern+0x9a>
nopl   (%rax)
mov    %cl,0x100(%rsp,%rax,1)
mov    %cl,(%rsp,%rdx,1)
add    $0x1,%ecx
movzbl 0x1(%rdi,%rax,1),%edx
add    $0x1,%rax
test   %dl,%dl
je     11bf <pattern+0xaf>
movsbq %dl,%rdx
movzbl (%rsp,%rdx,1),%ebx
test   %bl,%bl
je     1190 <pattern+0x80>
mov    %bl,0x100(%rsp,%rax,1)
jmp    119d <pattern+0x8d>
movb   $0x0,0x100(%rsp,%rax,1)
lea    0x2e72(%rip),%rbx
lea    0xe2b(%rip),%rsi
lea    0x100(%rsp),%rdx
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
add    $0x180,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@pattern.result = internal global [128 x i8] zeroinitializer
@.str = [4 x i8] c"%s=\00"
define i8* @pattern(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca [128 x i8]
%5 = alloca [128 x i8]
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %9
br label %10
10: ; preds = %17, %1
%11 = load i32, i32* %9
%12 = icmp slt i32 %11, 256
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %9
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %15
store i8 0, i8* %16
br label %17
17: ; preds = %13
%18 = load i32, i32* %9
%19 = add nsw i32 %18, 1
store i32 %19, i32* %9
br label %10
20: ; preds = %10
store i32 65, i32* %8
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
store i8* %21, i8** %7
%22 = load i8*, i8** %2
store i8* %22, i8** %6
br label %23
23: ; preds = %59, %20
%24 = load i8*, i8** %6
%25 = load i8, i8* %24
%26 = sext i8 %25 to i64
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %39
31: ; preds = %23
%32 = load i8*, i8** %6
%33 = load i8, i8* %32
%34 = sext i8 %33 to i64
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = load i8*, i8** %7
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %7
store i8 %36, i8* %37
br label %51
39: ; preds = %23
%40 = load i32, i32* %8
%41 = trunc i32 %40 to i8
%42 = load i8*, i8** %7
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %7
store i8 %41, i8* %42
%44 = load i32, i32* %8
%45 = add nsw i32 %44, 1
store i32 %45, i32* %8
%46 = trunc i32 %44 to i8
%47 = load i8*, i8** %6
%48 = load i8, i8* %47
%49 = sext i8 %48 to i64
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %49
store i8 %46, i8* %50
br label %51
51: ; preds = %39, %31
%52 = load i8*, i8** %6
%53 = getelementptr inbounds i8, i8* %52, i64 1
store i8* %53, i8** %6
%54 = load i8*, i8** %6
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %51
br label %60
59: ; preds = %51
br label %23
60: ; preds = %58
%61 = load i8*, i8** %7
store i8 0, i8* %61
%62 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%63 = call i32 @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @pattern.result, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %62)
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @pattern.result, i64 0, i64 0)
}

LLVM IR (-O2):
@pattern.result = internal global [128 x i8] zeroinitializer
@.str = [4 x i8] c"%s=\00"
define i8* @pattern(i8* nocapture %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = load i8, i8* %0
br label %8
8: ; preds = %1, %21
%9 = phi i8 [ %25, %21 ], [ %7, %1 ]
%10 = phi i8* [ %24, %21 ], [ %0, %1 ]
%11 = phi i8* [ %23, %21 ], [ %6, %1 ]
%12 = phi i32 [ %22, %21 ], [ 65, %1 ]
%13 = sext i8 %9 to i64
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %8
store i8 %15, i8* %11
br label %21
18: ; preds = %8
%19 = trunc i32 %12 to i8
store i8 %19, i8* %11
%20 = add nsw i32 %12, 1
store i8 %19, i8* %14
br label %21
21: ; preds = %18, %17
%22 = phi i32 [ %12, %17 ], [ %20, %18 ]
%23 = getelementptr inbounds i8, i8* %11, i64 1
%24 = getelementptr inbounds i8, i8* %10, i64 1
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %8
27: ; preds = %21
store i8 0, i8* %23
%28 = call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @pattern.result, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @pattern.result, i64 0, i64 0)
}