#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 size_t uint8_t;
typedef int ssize_t;

/* Variables and functions */
scalar_t__ EAGAIN;
scalar_t__ EINTR;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int /*<<< orphan*/ parse_args(int, char const **, size_t *);
int read(int /*<<< orphan*/, size_t *, int);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int write(int /*<<< orphan*/, size_t *, int);
int main(int argc, const char **argv) {
  uint8_t translate_table[256];
  parse_args(argc, argv, translate_table);
  for (;;) {
    uint8_t buf[1];
    ssize_t r = read(STDIN_FILENO, buf, sizeof buf);
    if (r == 0)
      break;
    else if (r == -1) {
      if (errno == EAGAIN || errno == EINTR)
        continue;
      else {
        fprintf(stderr, "%s: could not read stdin: %s\n", argv[0],
                strerror(errno));
        exit(1);
      }
    } else {
      for (int i = 0; i < r; i++)
        buf[i] = translate_table[buf[i]];
      ssize_t w = write(STDOUT_FILENO, buf, r);
      if (w != r) {
        fprintf(stderr, "%s: could not write stdout: %s\n", argv[0],
                strerror(errno));
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x850,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x810(%rbp),%rdx
call   1040 <parse_args@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
lea    -0x818(%rbp),%rsi
mov    $0x8,%edx
call   1050 <read@plt>
mov    %eax,-0x81c(%rbp)
cmpl   $0x0,-0x81c(%rbp)
jne    11be <main+0x5e>
jmp    1336 <main+0x1d6>
cmpl   $0xffffffff,-0x81c(%rbp)
jne    1256 <main+0xf6>
mov    0x2dfe(%rip),%rax
mov    (%rax),%rax
mov    0x2dd4(%rip),%rcx
cmp    (%rcx),%rax
je     11ff <main+0x9f>
mov    0x2de4(%rip),%rax
mov    (%rax),%rax
mov    0x2dd2(%rip),%rcx
cmp    (%rcx),%rax
jne    1204 <main+0xa4>
jmp    118c <main+0x2c>
mov    0x2dcd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x834(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x830(%rbp)
mov    0x2da8(%rip),%rax
mov    (%rax),%rdi
call   1080 <strerror@plt>
mov    -0x834(%rbp),%edi
mov    -0x830(%rbp),%rdx
mov    %rax,%rcx
lea    0xdb9(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x0,-0x820(%rbp)
mov    -0x820(%rbp),%eax
cmp    -0x81c(%rbp),%eax
jge    12ac <main+0x14c>
movslq -0x820(%rbp),%rax
mov    -0x818(%rbp,%rax,8),%rax
ff
mov    -0x810(%rbp,%rax,8),%rcx
ff
movslq -0x820(%rbp),%rax
mov    %rcx,-0x818(%rbp,%rax,8)
ff
mov    -0x820(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x820(%rbp)
jmp    1260 <main+0x100>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
lea    -0x818(%rbp),%rsi
mov    -0x81c(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x824(%rbp)
mov    -0x824(%rbp),%eax
cmp    -0x81c(%rbp),%eax
je     1327 <main+0x1c7>
mov    0x2cf2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x844(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x840(%rbp)
mov    0x2ccd(%rip),%rax
mov    (%rax),%rdi
call   1080 <strerror@plt>
mov    -0x844(%rbp),%edi
mov    -0x840(%rbp),%rdx
mov    %rax,%rcx
lea    0xcfc(%rip),%rsi
call   1060 <fprintf@plt>
jmp    132c <main+0x1cc>
jmp    1331 <main+0x1d1>
jmp    118c <main+0x2c>
xor    %eax,%eax
add    $0x850,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
lea    0x10(%rsp),%rdx
mov    %rsi,(%rsp)
call   1040 <parse_args@plt>
mov    0x2e3a(%rip),%r14
lea    0x8(%rsp),%r12
mov    0x2e1e(%rip),%rbp
mov    0x2e57(%rip),%r15
nopl   0x0(%rax)
mov    (%r14),%edi
mov    %r12,%rsi
mov    $0x8,%edx
call   1050 <read@plt>
cmp    $0xffffffff,%eax
je     1280 <main+0x120>
mov    %eax,%ebx
test   %eax,%eax
je     12d7 <main+0x177>
mov    0x8(%rsp),%rax
jle    122a <main+0xca>
lea    -0x1(%rbx),%edx
mov    %ebx,%ecx
and    $0x7,%ecx
cmp    $0x7,%edx
jb     120d <main+0xad>
mov    %ebx,%edx
and    $0xfffffff8,%edx
nopl   0x0(%rax)
mov    0x10(%rsp,%rax,8),%rax
mov    0x10(%rsp,%rax,8),%rax
mov    0x10(%rsp,%rax,8),%rax
mov    0x10(%rsp,%rax,8),%rax
mov    0x10(%rsp,%rax,8),%rax
mov    0x10(%rsp,%rax,8),%rax
mov    0x10(%rsp,%rax,8),%rax
mov    0x10(%rsp,%rax,8),%rax
add    $0xfffffff8,%edx
jne    11e0 <main+0x80>
test   %ecx,%ecx
je     122a <main+0xca>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rax,8),%rax
add    $0xffffffff,%ecx
jne    1220 <main+0xc0>
mov    %rax,0x8(%rsp)
mov    (%r15),%edi
mov    %r12,%rsi
mov    %ebx,%edx
call   1030 <write@plt>
cmp    %ebx,%eax
je     11a0 <main+0x40>
mov    0x2d8d(%rip),%rax
mov    (%rax),%ebx
mov    (%rsp),%rax
mov    (%rax),%r13
mov    0x2d75(%rip),%rax
mov    (%rax),%rdi
call   1080 <strerror@plt>
mov    %ebx,%edi
lea    0xdb2(%rip),%rsi
mov    %r13,%rdx
mov    %rax,%rcx
call   1060 <fprintf@plt>
jmp    11a0 <main+0x40>
nopl   0x0(%rax)
mov    0x2d49(%rip),%rax
mov    (%rax),%rdi
cmp    0x0(%rbp),%rdi
je     11a0 <main+0x40>
mov    0x2d2d(%rip),%rax
cmp    (%rax),%rdi
je     11a0 <main+0x40>
mov    0x2d2d(%rip),%rax
mov    (%rax),%ebx
mov    (%rsp),%rax
mov    (%rax),%r14
call   1080 <strerror@plt>
lea    0xd40(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
xor    %eax,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@errno = global i64 0
@EAGAIN = global i64 0
@EINTR = global i64 0
@stderr = global i32 0
@.str = [30 x i8] c"%s: could not read stdin: %s\0A\00"
@STDOUT_FILENO = global i32 0
@.str.1 = [32 x i8] c"%s: could not write stdout: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i64]
%7 = alloca [1 x i64]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds [256 x i64], [256 x i64]* %6, i64 0, i64 0
%14 = call i32 @parse_args(i32 %11, i8** %12, i64* %13)
br label %15
15: ; preds = %79, %33, %2
%16 = load i32, i32* @STDIN_FILENO
%17 = getelementptr inbounds [1 x i64], [1 x i64]* %7, i64 0, i64 0
%18 = call i32 @read(i32 %16, i64* %17, i32 8)
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %15
br label %80
22: ; preds = %15
%23 = load i32, i32* %8
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %43
25: ; preds = %22
%26 = load i64, i64* @errno
%27 = load i64, i64* @EAGAIN
%28 = icmp eq i64 %26, %27
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i64, i64* @errno
%31 = load i64, i64* @EINTR
%32 = icmp eq i64 %30, %31
br i1 %32, label %33, label %34
33: ; preds = %29, %25
br label %15
34: ; preds = %29
%35 = load i32, i32* @stderr
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 0
%38 = load i8*, i8** %37
%39 = load i64, i64* @errno
%40 = call i8* @strerror(i64 %39)
%41 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %38, i8* %40)
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %22
store i32 0, i32* %9
br label %44
44: ; preds = %58, %43
%45 = load i32, i32* %9
%46 = load i32, i32* %8
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %61
48: ; preds = %44
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [1 x i64], [1 x i64]* %7, i64 0, i64 %50
%52 = load i64, i64* %51
%53 = getelementptr inbounds [256 x i64], [256 x i64]* %6, i64 0, i64 %52
%54 = load i64, i64* %53
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [1 x i64], [1 x i64]* %7, i64 0, i64 %56
store i64 %54, i64* %57
br label %58
58: ; preds = %48
%59 = load i32, i32* %9
%60 = add nsw i32 %59, 1
store i32 %60, i32* %9
br label %44
61: ; preds = %44
%62 = load i32, i32* @STDOUT_FILENO
%63 = getelementptr inbounds [1 x i64], [1 x i64]* %7, i64 0, i64 0
%64 = load i32, i32* %8
%65 = call i32 @write(i32 %62, i64* %63, i32 %64)
store i32 %65, i32* %10
%66 = load i32, i32* %10
%67 = load i32, i32* %8
%68 = icmp ne i32 %66, %67
br i1 %68, label %69, label %77
69: ; preds = %61
%70 = load i32, i32* @stderr
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 0
%73 = load i8*, i8** %72
%74 = load i64, i64* @errno
%75 = call i8* @strerror(i64 %74)
%76 = call i32 @fprintf(i32 %70, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %73, i8* %75)
br label %77
77: ; preds = %69, %61
br label %78
78: ; preds = %77
br label %79
79: ; preds = %78
br label %15
80: ; preds = %21
ret i32 0
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@errno = global i64 0
@EAGAIN = global i64 0
@EINTR = global i64 0
@stderr = global i32 0
@.str = [30 x i8] c"%s: could not read stdin: %s\0A\00"
@STDOUT_FILENO = global i32 0
@.str.1 = [32 x i8] c"%s: could not write stdout: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [256 x i64]
%4 = alloca [1 x i64]
%5 = bitcast [256 x i64]* %3 to i8*
%6 = getelementptr inbounds [256 x i64], [256 x i64]* %3, i64 0, i64 0
%7 = call i32 @parse_args(i32 %0, i8** %1, i64* %6)
%8 = bitcast [1 x i64]* %4 to i8*
%9 = getelementptr inbounds [1 x i64], [1 x i64]* %4, i64 0, i64 0
br label %10
10: ; preds = %78, %2
%11 = load i32, i32* @STDIN_FILENO
%12 = call i32 @read(i32 %11, i64* %9, i32 8)
switch i32 %12, label %13 [
i32 0, label %79
i32 -1, label %22
]
13: ; preds = %10
%14 = load i64, i64* %9
%15 = icmp sgt i32 %12, 0
br i1 %15, label %16, label %46
16: ; preds = %13
%17 = add i32 %12, -1
%18 = and i32 %12, 7
%19 = icmp ult i32 %17, 7
br i1 %19, label %35, label %20
20: ; preds = %16
%21 = and i32 %12, -8
br label %51
22: ; preds = %10
%23 = load i64, i64* @errno
%24 = load i64, i64* @EAGAIN
%25 = icmp eq i64 %23, %24
%26 = load i64, i64* @EINTR
%27 = icmp eq i64 %23, %26
%28 = select i1 %25, i1 true, i1 %27
br i1 %28, label %78, label %29
29: ; preds = %22
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %1
%32 = call i8* @strerror(i64 %23)
%33 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %31, i8* %32)
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %51, %16
%36 = phi i64 [ undef, %16 ], [ %69, %51 ]
%37 = phi i64 [ %14, %16 ], [ %69, %51 ]
%38 = icmp eq i32 %18, 0
br i1 %38, label %46, label %39
39: ; preds = %35, %39
%40 = phi i64 [ %43, %39 ], [ %37, %35 ]
%41 = phi i32 [ %44, %39 ], [ 0, %35 ]
%42 = getelementptr inbounds [256 x i64], [256 x i64]* %3, i64 0, i64 %40
%43 = load i64, i64* %42
%44 = add i32 %41, 1
%45 = icmp eq i32 %44, %18
br i1 %45, label %46, label %39
46: ; preds = %35, %39, %13
%47 = phi i64 [ %14, %13 ], [ %36, %35 ], [ %43, %39 ]
store i64 %47, i64* %9
%48 = load i32, i32* @STDOUT_FILENO
%49 = call i32 @write(i32 %48, i64* %9, i32 %12)
%50 = icmp eq i32 %49, %12
br i1 %50, label %78, label %72
51: ; preds = %51, %20
%52 = phi i64 [ %14, %20 ], [ %69, %51 ]
%53 = phi i32 [ 0, %20 ], [ %70, %51 ]
%54 = getelementptr inbounds [256 x i64], [256 x i64]* %3, i64 0, i64 %52
%55 = load i64, i64* %54
%56 = getelementptr inbounds [256 x i64], [256 x i64]* %3, i64 0, i64 %55
%57 = load i64, i64* %56
%58 = getelementptr inbounds [256 x i64], [256 x i64]* %3, i64 0, i64 %57
%59 = load i64, i64* %58
%60 = getelementptr inbounds [256 x i64], [256 x i64]* %3, i64 0, i64 %59
%61 = load i64, i64* %60
%62 = getelementptr inbounds [256 x i64], [256 x i64]* %3, i64 0, i64 %61
%63 = load i64, i64* %62
%64 = getelementptr inbounds [256 x i64], [256 x i64]* %3, i64 0, i64 %63
%65 = load i64, i64* %64
%66 = getelementptr inbounds [256 x i64], [256 x i64]* %3, i64 0, i64 %65
%67 = load i64, i64* %66
%68 = getelementptr inbounds [256 x i64], [256 x i64]* %3, i64 0, i64 %67
%69 = load i64, i64* %68
%70 = add i32 %53, 8
%71 = icmp eq i32 %70, %21
br i1 %71, label %35, label %51
72: ; preds = %46
%73 = load i32, i32* @stderr
%74 = load i8*, i8** %1
%75 = load i64, i64* @errno
%76 = call i8* @strerror(i64 %75)
%77 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %74, i8* %76)
br label %78
78: ; preds = %46, %72, %22
br label %10
79: ; preds = %10
ret i32 0
}