#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 char u_int32_t;
typedef char u_int16_t;

/* Variables and functions */
int /*<<< orphan*/ pow(int, int);
char round(int /*<<< orphan*/);
u_int32_t trixel2number(char *trixel) {
  int index;
  u_int32_t id = 0;
  for (index = 3 + 1; index >= 1; --index) {
    id += (trixel[index] - '0') * (u_int16_t)round(pow(4, (3 + 1 - index)));
  }
  id += ((trixel[0] == 'S') ? round(pow(4, 3 + 1)) + 1 : 0);
  return id;
}


x86 assembly (clang, -O0):
<trixel2number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0xd(%rbp)
movl   $0x4,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jl     118c <trixel2number+0x6c>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x14(%rbp)
mov    $0x4,%esi
sub    -0xc(%rbp),%esi
mov    $0x4,%edi
call   1030 <pow@plt>
mov    %eax,%edi
call   1040 <round@plt>
mov    -0x14(%rbp),%ecx
movsbl %al,%eax
imul   %eax,%ecx
movsbl -0xd(%rbp),%eax
add    %ecx,%eax
mov    %al,-0xd(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1137 <trixel2number+0x17>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x53,%eax
jne    11bd <trixel2number+0x9d>
mov    $0x4,%esi
mov    %esi,%edi
call   1030 <pow@plt>
mov    %eax,%edi
call   1040 <round@plt>
movsbl %al,%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c7 <trixel2number+0xa7>
xor    %eax,%eax
mov    %eax,-0x18(%rbp)
jmp    11c7 <trixel2number+0xa7>
mov    -0x18(%rbp),%ecx
movsbl -0xd(%rbp),%eax
add    %ecx,%eax
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trixel2number>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x4(%rdi),%r15b
mov    $0x4,%edi
xor    %esi,%esi
call   1030 <pow@plt>
mov    %eax,%edi
call   1040 <round@plt>
mov    %al,0x7(%rsp)
mov    0x3(%r14),%r13b
mov    $0x4,%edi
mov    $0x1,%esi
call   1030 <pow@plt>
mov    %eax,%edi
call   1040 <round@plt>
mov    %al,0x6(%rsp)
mov    0x2(%r14),%bl
mov    $0x4,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %eax,%edi
call   1040 <round@plt>
mov    %al,0x5(%rsp)
mov    0x1(%r14),%r12b
mov    $0x4,%edi
mov    $0x3,%esi
call   1030 <pow@plt>
mov    %eax,%edi
call   1040 <round@plt>
xor    %esi,%esi
mov    %eax,%ebp
cmpb   $0x53,(%r14)
jne    11c5 <trixel2number+0xa5>
mov    $0x4,%edi
mov    $0x4,%esi
call   1030 <pow@plt>
mov    %eax,%edi
call   1040 <round@plt>
mov    %eax,%esi
add    $0x1,%sil
add    $0xd0,%r12b
mov    %r12d,%eax
mul    %bpl
mov    %eax,%ecx
add    $0xd0,%bl
mov    %ebx,%eax
mulb   0x5(%rsp)
mov    %eax,%edx
add    $0xd0,%r13b
mov    %r13d,%eax
mulb   0x6(%rsp)
mov    %eax,%ebx
add    $0xd0,%r15b
mov    %r15d,%eax
mulb   0x7(%rsp)
add    %bl,%al
add    %dl,%al
add    %cl,%al
add    %sil,%al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define signext i8 @trixel2number(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8
store i8* %0, i8** %2
store i8 0, i8* %4
store i32 4, i32* %3
br label %5
5: ; preds = %26, %1
%6 = load i32, i32* %3
%7 = icmp sge i32 %6, 1
br i1 %7, label %8, label %29
8: ; preds = %5
%9 = load i8*, i8** %2
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = sub nsw i32 %14, 48
%16 = load i32, i32* %3
%17 = sub nsw i32 4, %16
%18 = call i32 @pow(i32 4, i32 %17)
%19 = call signext i8 @round(i32 %18)
%20 = sext i8 %19 to i32
%21 = mul nsw i32 %15, %20
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = add nsw i32 %23, %21
%25 = trunc i32 %24 to i8
store i8 %25, i8* %4
br label %26
26: ; preds = %8
%27 = load i32, i32* %3
%28 = add nsw i32 %27, -1
store i32 %28, i32* %3
br label %5
29: ; preds = %5
%30 = load i8*, i8** %2
%31 = getelementptr inbounds i8, i8* %30, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 83
br i1 %34, label %35, label %40
35: ; preds = %29
%36 = call i32 @pow(i32 4, i32 4)
%37 = call signext i8 @round(i32 %36)
%38 = sext i8 %37 to i32
%39 = add nsw i32 %38, 1
br label %41
40: ; preds = %29
br label %41
41: ; preds = %40, %35
%42 = phi i32 [ %39, %35 ], [ 0, %40 ]
%43 = load i8, i8* %4
%44 = sext i8 %43 to i32
%45 = add nsw i32 %44, %42
%46 = trunc i32 %45 to i8
store i8 %46, i8* %4
%47 = load i8, i8* %4
ret i8 %47
}

LLVM IR (-O2):
define signext i8 @trixel2number(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 4
%3 = load i8, i8* %2
%4 = tail call i32 @pow(i32 4, i32 0)
%5 = tail call signext i8 @round(i32 %4)
%6 = getelementptr inbounds i8, i8* %0, i64 3
%7 = load i8, i8* %6
%8 = tail call i32 @pow(i32 4, i32 1)
%9 = tail call signext i8 @round(i32 %8)
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = load i8, i8* %10
%12 = tail call i32 @pow(i32 4, i32 2)
%13 = tail call signext i8 @round(i32 %12)
%14 = getelementptr inbounds i8, i8* %0, i64 1
%15 = load i8, i8* %14
%16 = tail call i32 @pow(i32 4, i32 3)
%17 = tail call signext i8 @round(i32 %16)
%18 = load i8, i8* %0
%19 = icmp eq i8 %18, 83
br i1 %19, label %20, label %24
20: ; preds = %1
%21 = tail call i32 @pow(i32 4, i32 4)
%22 = tail call signext i8 @round(i32 %21)
%23 = add i8 %22, 1
br label %24
24: ; preds = %1, %20
%25 = phi i8 [ %23, %20 ], [ 0, %1 ]
%26 = add i8 %15, -48
%27 = mul i8 %26, %17
%28 = add i8 %11, -48
%29 = mul i8 %28, %13
%30 = add i8 %7, -48
%31 = mul i8 %30, %9
%32 = add i8 %3, -48
%33 = mul i8 %32, %5
%34 = add i8 %31, %33
%35 = add i8 %29, %34
%36 = add i8 %27, %35
%37 = add i8 %25, %36
ret i8 %37
}