#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 */
scalar_t__ whichpos(char const *);
scalar_t__ whichrot(char const *);
int cube_120convert(const char *input, char *output) {
  int i;
  for (i = 0; i < 20; ++i) {
    ((char *)output + (i << 1))[0] = (char)whichpos(input + i * 6);
    ((char *)output + (i << 1))[1] = (char)whichrot(input + i * 6);
  }
  return 1;
}


x86 assembly (clang, -O0):
<cube_120convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jge    1198 <cube_120convert+0x78>
mov    -0x8(%rbp),%rdi
imul   $0x6,-0x14(%rbp),%eax
cltq
add    %rax,%rdi
call   1030 <whichpos@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
imul   $0x6,-0x14(%rbp),%eax
cltq
add    %rax,%rdi
call   1040 <whichrot@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,0x1(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <cube_120convert+0x17>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cube_120convert>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nopl   (%rax)
mov    %r15,%rdi
call   1030 <whichpos@plt>
mov    %al,(%r14,%rbx,2)
mov    %r15,%rdi
call   1040 <whichrot@plt>
mov    %al,0x1(%r14,%rbx,2)
add    $0x1,%rbx
add    $0x6,%r15
cmp    $0x14,%rbx
jne    1130 <cube_120convert+0x10>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @cube_120convert(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %36, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 20
br i1 %8, label %9, label %39
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = load i32, i32* %5
%12 = mul nsw i32 %11, 6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = call i64 @whichpos(i8* %14)
%16 = trunc i64 %15 to i8
%17 = load i8*, i8** %4
%18 = load i32, i32* %5
%19 = shl i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %17, i64 %20
%22 = getelementptr inbounds i8, i8* %21, i64 0
store i8 %16, i8* %22
%23 = load i8*, i8** %3
%24 = load i32, i32* %5
%25 = mul nsw i32 %24, 6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
%28 = call i64 @whichrot(i8* %27)
%29 = trunc i64 %28 to i8
%30 = load i8*, i8** %4
%31 = load i32, i32* %5
%32 = shl i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %30, i64 %33
%35 = getelementptr inbounds i8, i8* %34, i64 1
store i8 %29, i8* %35
br label %36
36: ; preds = %9
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %6
39: ; preds = %6
ret i32 1
}

LLVM IR (-O2):
define i32 @cube_120convert(i8* %0, i8* nocapture writeonly %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i64 [ 0, %2 ], [ %14, %3 ]
%5 = mul nuw nsw i64 %4, 6
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = tail call i64 @whichpos(i8* %6)
%8 = trunc i64 %7 to i8
%9 = shl nuw nsw i64 %4, 1
%10 = getelementptr inbounds i8, i8* %1, i64 %9
store i8 %8, i8* %10
%11 = tail call i64 @whichrot(i8* %6)
%12 = trunc i64 %11 to i8
%13 = getelementptr inbounds i8, i8* %10, i64 1
store i8 %12, i8* %13
%14 = add nuw nsw i64 %4, 1
%15 = icmp eq i64 %14, 20
br i1 %15, label %16, label %3
16: ; preds = %3
ret i32 1
}