#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 uint64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char);
uint64_t hash_seq(char *sequence, short sequence_length) {
  uint64_t hash;
  int i;
  hash = 0;
  for (i = 0; i < sequence_length - 1; ++i) {
    switch (*sequence) {
    case 'T':
      hash += 0;
      break;
    case 'C':
      hash += 1;
      break;
    case 'G':
      hash += 2;
      break;
    case 'A':
      hash += 3;
      break;
    default:
      printf("Invalid character \"%c\"", *sequence);
      return -1;
    }
    ++sequence;
    if (sequence_length == 1) {
      return hash;
    }
    hash = hash << 2;
  }
  switch (*sequence) {
  case 'T':
    break;
  case 'C':
    hash += 1;
    break;
  case 'G':
    hash += 2;
    break;
  case 'A':
    hash += 3;
    break;
  case 'N':
  default:
    printf("Invalid character \"%c\"", *sequence);
    return -1;
  }
  return hash;
}


x86 assembly (clang, -O0):
<hash_seq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %si,%ax
mov    %rdi,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
movswl -0x12(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1202 <hash_seq+0xf2>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x13,%eax
ja     11a8 <hash_seq+0x98>
mov    -0x28(%rbp),%rax
lea    0xee9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%eax
add    $0x0,%eax
mov    %eax,-0x18(%rbp)
jmp    11c7 <hash_seq+0xb7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c7 <hash_seq+0xb7>
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
jmp    11c7 <hash_seq+0xb7>
mov    -0x18(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x18(%rbp)
jmp    11c7 <hash_seq+0xb7>
mov    -0x10(%rbp),%rax
lea    0xeed(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1288 <hash_seq+0x178>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movswl -0x12(%rbp),%eax
cmp    $0x1,%eax
jne    11eb <hash_seq+0xdb>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1288 <hash_seq+0x178>
mov    -0x18(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1131 <hash_seq+0x21>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x13,%eax
ja     1263 <hash_seq+0x153>
mov    -0x30(%rbp),%rax
lea    0xdda(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1282 <hash_seq+0x172>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1282 <hash_seq+0x172>
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
jmp    1282 <hash_seq+0x172>
mov    -0x18(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x18(%rbp)
jmp    1282 <hash_seq+0x172>
jmp    1263 <hash_seq+0x153>
mov    -0x10(%rbp),%rax
lea    0xe32(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1288 <hash_seq+0x178>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_seq>:
push   %rax
xor    %eax,%eax
cmp    $0x2,%si
jl     1178 <hash_seq+0x68>
mov    %esi,%eax
add    $0xfffffffe,%eax
lea    (%rax,%rdi,1),%r8
add    $0x1,%r8
movswq %si,%r10
add    $0xffffffffffffffff,%r10
xor    %esi,%esi
lea    0xec9(%rip),%r9
xor    %eax,%eax
jmp    114f <hash_seq+0x3f>
nopl   0x0(%rax,%rax,1)
or     $0x1,%eax
shl    $0x2,%eax
add    $0x1,%rsi
cmp    %esi,%r10d
je     1175 <hash_seq+0x65>
movsbl (%rdi,%rsi,1),%ecx
lea    -0x41(%rcx),%edx
cmp    $0x13,%edx
ja     1198 <hash_seq+0x88>
movslq (%r9,%rdx,4),%rdx
add    %r9,%rdx
jmp    *%rdx
or     $0x3,%eax
jmp    1143 <hash_seq+0x33>
nopl   0x0(%rax)
or     $0x2,%eax
jmp    1143 <hash_seq+0x33>
mov    %r8,%rdi
movsbl (%rdi),%ecx
lea    -0x41(%rcx),%edx
cmp    $0x13,%edx
ja     1198 <hash_seq+0x88>
lea    0xec6(%rip),%rsi
movslq (%rsi,%rdx,4),%rdx
add    %rsi,%rdx
jmp    *%rdx
or     $0x3,%eax
pop    %rcx
ret
movsbl %cl,%esi
lea    0xefe(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
or     $0x1,%eax
pop    %rcx
ret
or     $0x2,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Invalid character \22%c\22\00"
define i32 @hash_seq(i8* %0, i16 signext %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i16
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i16 %1, i16* %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %45, %2
%9 = load i32, i32* %7
%10 = load i16, i16* %5
%11 = sext i16 %10 to i32
%12 = sub nsw i32 %11, 1
%13 = icmp slt i32 %9, %12
br i1 %13, label %14, label %48
14: ; preds = %8
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %30 [
i32 84, label %18
i32 67, label %21
i32 71, label %24
i32 65, label %27
]
18: ; preds = %14
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 0
store i32 %20, i32* %6
br label %34
21: ; preds = %14
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %34
24: ; preds = %14
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 2
store i32 %26, i32* %6
br label %34
27: ; preds = %14
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 3
store i32 %29, i32* %6
br label %34
30: ; preds = %14
%31 = load i8*, i8** %4
%32 = load i8, i8* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8 signext %32)
store i32 -1, i32* %3
br label %69
34: ; preds = %27, %24, %21, %18
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %4
%37 = load i16, i16* %5
%38 = sext i16 %37 to i32
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %42
40: ; preds = %34
%41 = load i32, i32* %6
store i32 %41, i32* %3
br label %69
42: ; preds = %34
%43 = load i32, i32* %6
%44 = shl i32 %43, 2
store i32 %44, i32* %6
br label %45
45: ; preds = %42
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %8
48: ; preds = %8
%49 = load i8*, i8** %4
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
switch i32 %51, label %63 [
i32 84, label %52
i32 67, label %53
i32 71, label %56
i32 65, label %59
i32 78, label %62
]
52: ; preds = %48
br label %67
53: ; preds = %48
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
store i32 %55, i32* %6
br label %67
56: ; preds = %48
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 2
store i32 %58, i32* %6
br label %67
59: ; preds = %48
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 3
store i32 %61, i32* %6
br label %67
62: ; preds = %48
br label %63
63: ; preds = %48, %62
%64 = load i8*, i8** %4
%65 = load i8, i8* %64
%66 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8 signext %65)
store i32 -1, i32* %3
br label %69
67: ; preds = %59, %56, %53, %52
%68 = load i32, i32* %6
store i32 %68, i32* %3
br label %69
69: ; preds = %67, %63, %40, %30
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
@.str = [23 x i8] c"Invalid character \22%c\22\00"
define i32 @hash_seq(i8* nocapture %0, i16 signext %1) {
%3 = sext i16 %1 to i32
%4 = add nsw i32 %3, -1
%5 = icmp sgt i16 %1, 1
br i1 %5, label %6, label %31
6: ; preds = %2
%7 = add nsw i32 %3, -2
%8 = zext i32 %7 to i64
%9 = add nuw nsw i64 %8, 1
%10 = getelementptr i8, i8* %0, i64 %9
br label %11
11: ; preds = %6, %25
%12 = phi i32 [ 0, %6 ], [ %29, %25 ]
%13 = phi i32 [ 0, %6 ], [ %28, %25 ]
%14 = phi i8* [ %0, %6 ], [ %27, %25 ]
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %23 [
i32 84, label %25
i32 67, label %17
i32 71, label %19
i32 65, label %21
]
17: ; preds = %11
%18 = or i32 %13, 1
br label %25
19: ; preds = %11
%20 = or i32 %13, 2
br label %25
21: ; preds = %11
%22 = or i32 %13, 3
br label %25
23: ; preds = %11
%24 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8 signext %15)
br label %44
25: ; preds = %17, %19, %21, %11
%26 = phi i32 [ %22, %21 ], [ %20, %19 ], [ %18, %17 ], [ %13, %11 ]
%27 = getelementptr inbounds i8, i8* %14, i64 1
%28 = shl i32 %26, 2
%29 = add nuw nsw i32 %12, 1
%30 = icmp eq i32 %29, %4
br i1 %30, label %31, label %11
31: ; preds = %25, %2
%32 = phi i8* [ %0, %2 ], [ %10, %25 ]
%33 = phi i32 [ 0, %2 ], [ %28, %25 ]
%34 = load i8, i8* %32
%35 = sext i8 %34 to i32
switch i32 %35, label %42 [
i32 84, label %44
i32 67, label %36
i32 71, label %38
i32 65, label %40
]
36: ; preds = %31
%37 = or i32 %33, 1
br label %44
38: ; preds = %31
%39 = or i32 %33, 2
br label %44
40: ; preds = %31
%41 = or i32 %33, 3
br label %44
42: ; preds = %31
%43 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8 signext %34)
br label %44
44: ; preds = %31, %36, %38, %40, %42, %23
%45 = phi i32 [ -1, %23 ], [ -1, %42 ], [ %41, %40 ], [ %39, %38 ], [ %37, %36 ], [ %33, %31 ]
ret i32 %45
}