#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 chuyendoi(char);
int luythua(int);
int strlen(char *);
int doicoso(char *s) {
  int i, j, tg;
  i = strlen(s);
  tg = 0;
  for (j = 0; j < i; j++)
    tg = tg + luythua(i - j - 1) * chuyendoi(s[j]);
  return tg;
}


x86 assembly (clang, -O0):
<doicoso>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a8 <doicoso+0x78>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
sub    -0x10(%rbp),%edi
sub    $0x1,%edi
call   1050 <luythua@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <chuyendoi@plt>
mov    -0x1c(%rbp),%ecx
mov    %eax,%edx
mov    -0x18(%rbp),%eax
imul   %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1156 <doicoso+0x26>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doicoso>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
test   %eax,%eax
jle    1189 <doicoso+0x59>
mov    %eax,%ebp
mov    %eax,%r12d
add    $0xffffffff,%ebp
xor    %ebx,%ebx
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
call   1050 <luythua@plt>
mov    %eax,%r15d
movsbl (%r14,%rbx,1),%edi
call   1030 <chuyendoi@plt>
imul   %r15d,%eax
add    %eax,%r13d
add    $0x1,%rbx
add    $0xffffffff,%ebp
cmp    %rbx,%r12
jne    1160 <doicoso+0x30>
jmp    118c <doicoso+0x5c>
xor    %r13d,%r13d
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @doicoso(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
store i32 %7, i32* %3
store i32 0, i32* %5
store i32 0, i32* %4
br label %8
8: ; preds = %27, %1
%9 = load i32, i32* %4
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %30
12: ; preds = %8
%13 = load i32, i32* %5
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = sub nsw i32 %14, %15
%17 = sub nsw i32 %16, 1
%18 = call i32 @luythua(i32 %17)
%19 = load i8*, i8** %2
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = call i32 @chuyendoi(i8 signext %23)
%25 = mul nsw i32 %18, %24
%26 = add nsw i32 %13, %25
store i32 %26, i32* %5
br label %27
27: ; preds = %12
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %8
30: ; preds = %8
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
define i32 @doicoso(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %20
4: ; preds = %1
%5 = zext i32 %2 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %18, %6 ]
%8 = phi i32 [ 0, %4 ], [ %17, %6 ]
%9 = trunc i64 %7 to i32
%10 = xor i32 %9, -1
%11 = add i32 %2, %10
%12 = tail call i32 @luythua(i32 %11)
%13 = getelementptr inbounds i8, i8* %0, i64 %7
%14 = load i8, i8* %13
%15 = tail call i32 @chuyendoi(i8 signext %14)
%16 = mul nsw i32 %15, %12
%17 = add nsw i32 %16, %8
%18 = add nuw nsw i64 %7, 1
%19 = icmp eq i64 %18, %5
br i1 %19, label %20, label %6
20: ; preds = %6, %1
%21 = phi i32 [ 0, %1 ], [ %17, %6 ]
ret i32 %21
}