#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 EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
scalar_t__ isdigit(char);
scalar_t__ islower(char);
scalar_t__ isupper(char);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
char toupper(char);
void apply_maps(char *alpha_map, char *numer_map, char *file_name) {
  FILE *fp;
  int ci;
  char c;
  char p;
  int i;
  if (strcmp(file_name, "-") == 0)
    fp = stdin;
  else {
    fp = fopen(file_name, "r");
    if (fp == NULL) {
      fprintf(stderr, "Couldn't open \"%s\" for read.\n", file_name);
      exit(1);
    }
  }
  while ((ci = fgetc(fp)) != EOF) {
    c = ci;
    if (isdigit(c)) {
      c = numer_map[c - '0'];
    } else if (islower(c)) {
      c = alpha_map[c - 'a'];
    } else if (isupper(c)) {
      c = toupper(alpha_map[c - 'A']);
    }
    fputc(c, stdout);
  }
  if (fp != stdin)
    fclose(fp);
}


x86 assembly (clang, -O0):
<apply_maps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    11f1 <apply_maps+0x41>
mov    0x2e03(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1238 <apply_maps+0x88>
mov    -0x18(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1233 <apply_maps+0x83>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xde0(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    1238 <apply_maps+0x88>
jmp    123d <apply_maps+0x8d>
mov    -0x20(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %eax,-0x24(%rbp)
mov    0x2d90(%rip),%rcx
cmp    (%rcx),%eax
je     1306 <apply_maps+0x156>
mov    -0x24(%rbp),%eax
mov    %al,-0x25(%rbp)
movsbl -0x25(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     128a <apply_maps+0xda>
mov    -0x10(%rbp),%rax
movsbl -0x25(%rbp),%ecx
sub    $0x30,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x25(%rbp)
jmp    12ed <apply_maps+0x13d>
movsbl -0x25(%rbp),%edi
call   1040 <islower@plt>
cmp    $0x0,%rax
je     12b6 <apply_maps+0x106>
mov    -0x8(%rbp),%rax
movsbl -0x25(%rbp),%ecx
sub    $0x61,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x25(%rbp)
jmp    12e8 <apply_maps+0x138>
movsbl -0x25(%rbp),%edi
call   10b0 <isupper@plt>
cmp    $0x0,%rax
je     12e3 <apply_maps+0x133>
mov    -0x8(%rbp),%rax
movsbl -0x25(%rbp),%ecx
sub    $0x41,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <toupper@plt>
mov    %al,-0x25(%rbp)
jmp    12e8 <apply_maps+0x138>
jmp    12ed <apply_maps+0x13d>
mov    -0x25(%rbp),%al
mov    0x2cd1(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1080 <fputc@plt>
jmp    123d <apply_maps+0x8d>
mov    -0x20(%rbp),%rax
mov    0x2cd7(%rip),%rcx
cmp    (%rcx),%rax
je     1323 <apply_maps+0x173>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apply_maps>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %rdi,(%rsp)
lea    0xe34(%rip),%rsi
mov    %rdx,%rdi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1212 <apply_maps+0x62>
lea    0xe22(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    121c <apply_maps+0x6c>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
lea    0xe04(%rip),%rsi
mov    %rbp,%rdx
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%r12
mov    %r12,%rdi
call   1070 <fgetc@plt>
mov    0x2db5(%rip),%r13
cmp    0x0(%r13),%eax
jne    1257 <apply_maps+0xa7>
mov    0x2db0(%rip),%rax
cmp    (%rax),%r12
je     12e9 <apply_maps+0x139>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fclose@plt>
mov    %eax,%ebp
mov    0x2d68(%rip),%r14
jmp    1298 <apply_maps+0xe8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %bpl,%eax
cltq
movzbl -0x30(%rax,%r15,1),%ebp
mov    (%r14),%esi
movsbl %bpl,%edi
call   1080 <fputc@plt>
mov    %r12,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebp
cmp    0x0(%r13),%eax
je     1231 <apply_maps+0x81>
movsbl %bpl,%ebx
mov    %ebx,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1270 <apply_maps+0xc0>
mov    %ebx,%edi
call   1040 <islower@plt>
test   %rax,%rax
je     12c5 <apply_maps+0x115>
movsbl %bpl,%eax
cltq
mov    (%rsp),%rcx
movzbl -0x61(%rax,%rcx,1),%ebp
jmp    127c <apply_maps+0xcc>
mov    %ebx,%edi
call   10b0 <isupper@plt>
test   %rax,%rax
je     127c <apply_maps+0xcc>
movsbl %bpl,%eax
cltq
mov    (%rsp),%rcx
movsbl -0x41(%rax,%rcx,1),%edi
call   1050 <toupper@plt>
mov    %eax,%ebp
jmp    127c <apply_maps+0xcc>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [30 x i8] c"Couldn't open \22%s\22 for read.\0A\00"
@EOF = global i32 0
@stdout = global i32 0
define void @apply_maps(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8
%10 = alloca i8
%11 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%12 = load i8*, i8** %6
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = load i32*, i32** @stdin
store i32* %16, i32** %7
br label %28
17: ; preds = %3
%18 = load i8*, i8** %6
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %7
%20 = load i32*, i32** %7
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %6
%25 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %17
br label %28
28: ; preds = %27, %15
br label %29
29: ; preds = %75, %28
%30 = load i32*, i32** %7
%31 = call i32 @fgetc(i32* %30)
store i32 %31, i32* %8
%32 = load i32, i32* @EOF
%33 = icmp ne i32 %31, %32
br i1 %33, label %34, label %79
34: ; preds = %29
%35 = load i32, i32* %8
%36 = trunc i32 %35 to i8
store i8 %36, i8* %9
%37 = load i8, i8* %9
%38 = call i64 @isdigit(i8 signext %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %48
40: ; preds = %34
%41 = load i8*, i8** %5
%42 = load i8, i8* %9
%43 = sext i8 %42 to i32
%44 = sub nsw i32 %43, 48
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %41, i64 %45
%47 = load i8, i8* %46
store i8 %47, i8* %9
br label %75
48: ; preds = %34
%49 = load i8, i8* %9
%50 = call i64 @islower(i8 signext %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %60
52: ; preds = %48
%53 = load i8*, i8** %4
%54 = load i8, i8* %9
%55 = sext i8 %54 to i32
%56 = sub nsw i32 %55, 97
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %53, i64 %57
%59 = load i8, i8* %58
store i8 %59, i8* %9
br label %74
60: ; preds = %48
%61 = load i8, i8* %9
%62 = call i64 @isupper(i8 signext %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %73
64: ; preds = %60
%65 = load i8*, i8** %4
%66 = load i8, i8* %9
%67 = sext i8 %66 to i32
%68 = sub nsw i32 %67, 65
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %65, i64 %69
%71 = load i8, i8* %70
%72 = call signext i8 @toupper(i8 signext %71)
store i8 %72, i8* %9
br label %73
73: ; preds = %64, %60
br label %74
74: ; preds = %73, %52
br label %75
75: ; preds = %74, %40
%76 = load i8, i8* %9
%77 = load i32, i32* @stdout
%78 = call i32 @fputc(i8 signext %76, i32 %77)
br label %29
79: ; preds = %29
%80 = load i32*, i32** %7
%81 = load i32*, i32** @stdin
%82 = icmp ne i32* %80, %81
br i1 %82, label %83, label %86
83: ; preds = %79
%84 = load i32*, i32** %7
%85 = call i32 @fclose(i32* %84)
br label %86
86: ; preds = %83, %79
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [30 x i8] c"Couldn't open \22%s\22 for read.\0A\00"
@EOF = global i32 0
@stdout = global i32 0
define void @apply_maps(i8* nocapture %0, i8* nocapture %1, i8* %2) {
%4 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = load i32*, i32** @stdin
br label %15
8: ; preds = %3
%9 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %8, %6
%16 = phi i32* [ %7, %6 ], [ %9, %8 ]
%17 = tail call i32 @fgetc(i32* %16)
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %60, label %20
20: ; preds = %15, %53
%21 = phi i32 [ %57, %53 ], [ %17, %15 ]
%22 = trunc i32 %21 to i8
%23 = tail call i64 @isdigit(i8 signext %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %32, label %25
25: ; preds = %20
%26 = shl i32 %21, 24
%27 = ashr exact i32 %26, 24
%28 = add nsw i32 %27, -48
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %1, i64 %29
%31 = load i8, i8* %30
br label %53
32: ; preds = %20
%33 = tail call i64 @islower(i8 signext %22)
%34 = icmp eq i64 %33, 0
br i1 %34, label %42, label %35
35: ; preds = %32
%36 = shl i32 %21, 24
%37 = ashr exact i32 %36, 24
%38 = add nsw i32 %37, -97
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %0, i64 %39
%41 = load i8, i8* %40
br label %53
42: ; preds = %32
%43 = tail call i64 @isupper(i8 signext %22)
%44 = icmp eq i64 %43, 0
br i1 %44, label %53, label %45
45: ; preds = %42
%46 = shl i32 %21, 24
%47 = ashr exact i32 %46, 24
%48 = add nsw i32 %47, -65
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %0, i64 %49
%51 = load i8, i8* %50
%52 = tail call signext i8 @toupper(i8 signext %51)
br label %53
53: ; preds = %35, %45, %42, %25
%54 = phi i8 [ %31, %25 ], [ %41, %35 ], [ %52, %45 ], [ %22, %42 ]
%55 = load i32, i32* @stdout
%56 = tail call i32 @fputc(i8 signext %54, i32 %55)
%57 = tail call i32 @fgetc(i32* %16)
%58 = load i32, i32* @EOF
%59 = icmp eq i32 %57, %58
br i1 %59, label %60, label %20
60: ; preds = %53, %15
%61 = load i32*, i32** @stdin
%62 = icmp eq i32* %16, %61
br i1 %62, label %65, label %63
63: ; preds = %60
%64 = tail call i32 @fclose(i32* %16)
br label %65
65: ; preds = %63, %60
ret void
}