#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*/ STDIN_FILENO;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int /*<<< orphan*/ putchar(char);
scalar_t__ read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
int strlen(char *);
int main() {
  char buffer[1000];
  char *c;
  while (read(STDIN_FILENO, buffer, 1000) > 0) {
    c = buffer + strlen(buffer) - 1;
    while (*c == '\n' || *c == '\r')
      c--;
    while (*c && *c != '\n') {
      switch (*c) {
      case 'A':
        putchar('T');
        break;
      case 'C':
        putchar('G');
        break;
      case 'G':
        putchar('C');
        break;
      case 'T':
        putchar('A');
        break;
      default:
        fprintf(stderr, "invalid char %c\n", *c);
        return 1;
      }
      c--;
    }
  }
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
lea    -0x3f0(%rbp),%rsi
mov    $0x3e8,%edx
call   1050 <read@plt>
cmp    $0x0,%rax
jle    1307 <main+0x1c7>
lea    -0x3f0(%rbp),%rax
mov    %rax,-0x400(%rbp)
lea    -0x3f0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x400(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x3f8(%rbp)
mov    -0x3f8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x401(%rbp)
je     11db <main+0x9b>
mov    -0x3f8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
sete   %al
mov    %al,-0x401(%rbp)
mov    -0x401(%rbp),%al
test   $0x1,%al
jne    11ee <main+0xae>
jmp    1205 <main+0xc5>
mov    -0x3f8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x3f8(%rbp)
jmp    11aa <main+0x6a>
jmp    120a <main+0xca>
mov    -0x3f8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x402(%rbp)
je     123b <main+0xfb>
mov    -0x3f8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x402(%rbp)
mov    -0x402(%rbp),%al
test   $0x1,%al
jne    124e <main+0x10e>
jmp    1302 <main+0x1c2>
mov    -0x3f8(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x410(%rbp)
sub    $0x13,%eax
ja     12c0 <main+0x180>
mov    -0x410(%rbp),%rax
lea    0xd85(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x54,%edi
call   1030 <putchar@plt>
jmp    12eb <main+0x1ab>
mov    $0x47,%edi
call   1030 <putchar@plt>
jmp    12eb <main+0x1ab>
mov    $0x43,%edi
call   1030 <putchar@plt>
jmp    12eb <main+0x1ab>
mov    $0x41,%edi
call   1030 <putchar@plt>
jmp    12eb <main+0x1ab>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
mov    -0x3f8(%rbp),%rax
lea    0xd79(%rip),%rsi
movsbl (%rax),%edx
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1318 <main+0x1d8>
mov    -0x3f8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x3f8(%rbp)
jmp    120a <main+0xca>
jmp    1152 <main+0x12>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3e8,%rsp
mov    0x2e80(%rip),%r14
mov    (%r14),%edi
mov    %rsp,%rsi
mov    $0x3e8,%edx
call   1050 <read@plt>
test   %rax,%rax
jle    1224 <main+0xe4>
lea    -0x1(%rsp),%r15
lea    -0x2(%rsp),%r12
mov    %rsp,%r13
lea    0xe7b(%rip),%rbx
jmp    11a5 <main+0x65>
nopw   0x0(%rax,%rax,1)
mov    (%r14),%edi
mov    %r13,%rsi
mov    $0x3e8,%edx
call   1050 <read@plt>
test   %rax,%rax
jle    1224 <main+0xe4>
mov    %r13,%rdi
call   1040 <strlen@plt>
movslq %eax,%rbp
lea    (%r15,%rbp,1),%rcx
add    %r12,%rbp
jmp    11c8 <main+0x88>
nopl   0x0(%rax)
add    $0xffffffffffffffff,%rcx
add    $0xffffffffffffffff,%rbp
movzbl (%rcx),%eax
cmp    $0xa,%al
je     11c0 <main+0x80>
cmp    $0xd,%al
je     11c0 <main+0x80>
jmp    11f2 <main+0xb2>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x47,%al
movzbl %al,%edi
call   1030 <putchar@plt>
movzbl 0x0(%rbp),%eax
add    $0xffffffffffffffff,%rbp
test   %al,%al
je     1190 <main+0x50>
cmp    $0xa,%al
je     1190 <main+0x50>
movsbl %al,%edx
lea    -0x41(%rdx),%ecx
cmp    $0x13,%ecx
ja     1232 <main+0xf2>
mov    $0x54,%al
movslq (%rbx,%rcx,4),%rcx
add    %rbx,%rcx
jmp    *%rcx
mov    $0x43,%al
jmp    11e2 <main+0xa2>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x41,%al
jmp    11e2 <main+0xa2>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
jmp    124c <main+0x10c>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
lea    0xe0e(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@stderr = global i32 0
@.str = [17 x i8] c"invalid char %c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca i8*
store i32 0, i32* %1
br label %4
4: ; preds = %64, %0
%5 = load i32, i32* @STDIN_FILENO
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%7 = call i64 @read(i32 %5, i8* %6, i32 1000)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %65
9: ; preds = %4
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = getelementptr inbounds i8, i8* %14, i64 -1
store i8* %15, i8** %3
br label %16
16: ; preds = %28, %9
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 10
br i1 %20, label %26, label %21
21: ; preds = %16
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 13
br label %26
26: ; preds = %21, %16
%27 = phi i1 [ true, %16 ], [ %25, %21 ]
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i32 -1
store i8* %30, i8** %3
br label %16
31: ; preds = %26
br label %32
32: ; preds = %61, %31
%33 = load i8*, i8** %3
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %32
%38 = load i8*, i8** %3
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 10
br label %42
42: ; preds = %37, %32
%43 = phi i1 [ false, %32 ], [ %41, %37 ]
br i1 %43, label %44, label %64
44: ; preds = %42
%45 = load i8*, i8** %3
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
switch i32 %47, label %56 [
i32 65, label %48
i32 67, label %50
i32 71, label %52
i32 84, label %54
]
48: ; preds = %44
%49 = call i32 @putchar(i8 signext 84)
br label %61
50: ; preds = %44
%51 = call i32 @putchar(i8 signext 71)
br label %61
52: ; preds = %44
%53 = call i32 @putchar(i8 signext 67)
br label %61
54: ; preds = %44
%55 = call i32 @putchar(i8 signext 65)
br label %61
56: ; preds = %44
%57 = load i32, i32* @stderr
%58 = load i8*, i8** %3
%59 = load i8, i8* %58
%60 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8 signext %59)
store i32 1, i32* %1
br label %67
61: ; preds = %54, %52, %50, %48
%62 = load i8*, i8** %3
%63 = getelementptr inbounds i8, i8* %62, i32 -1
store i8* %63, i8** %3
br label %32
64: ; preds = %42
br label %4
65: ; preds = %4
%66 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %1
br label %67
67: ; preds = %65, %56
%68 = load i32, i32* %1
ret i32 %68
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@stderr = global i32 0
@.str = [17 x i8] c"invalid char %c\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @STDIN_FILENO
%4 = call i64 @read(i32 %3, i8* %2, i32 1000)
%5 = icmp sgt i64 %4, 0
br i1 %5, label %6, label %35
6: ; preds = %0, %31
%7 = call i32 @strlen(i8* %2)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %8
br label %10
10: ; preds = %14, %6
%11 = phi i8* [ %9, %6 ], [ %12, %14 ]
%12 = getelementptr inbounds i8, i8* %11, i64 -1
%13 = load i8, i8* %12
switch i8 %13, label %15 [
i8 10, label %14
i8 13, label %14
]
14: ; preds = %10, %10
br label %10
15: ; preds = %10, %26
%16 = phi i8 [ %30, %26 ], [ %13, %10 ]
%17 = phi i8* [ %29, %26 ], [ %12, %10 ]
switch i8 %16, label %18 [
i8 0, label %31
i8 10, label %31
]
18: ; preds = %15
%19 = sext i8 %16 to i32
switch i32 %19, label %23 [
i32 65, label %26
i32 67, label %20
i32 71, label %21
i32 84, label %22
]
20: ; preds = %18
br label %26
21: ; preds = %18
br label %26
22: ; preds = %18
br label %26
23: ; preds = %18
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8 signext %16)
br label %37
26: ; preds = %18, %22, %21, %20
%27 = phi i8 [ 65, %22 ], [ 67, %21 ], [ 71, %20 ], [ 84, %18 ]
%28 = call i32 @putchar(i8 signext %27)
%29 = getelementptr inbounds i8, i8* %17, i64 -1
%30 = load i8, i8* %29
br label %15
31: ; preds = %15, %15
%32 = load i32, i32* @STDIN_FILENO
%33 = call i64 @read(i32 %32, i8* %2, i32 1000)
%34 = icmp sgt i64 %33, 0
br i1 %34, label %6, label %35
35: ; preds = %31, %0
%36 = call i32 @putchar(i8 signext 10)
br label %37
37: ; preds = %35, %23
%38 = phi i32 [ 1, %23 ], [ 0, %35 ]
ret i32 %38
}