#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 */
unsigned long ctoi(char const);
unsigned long potencia(unsigned char const, char);
int /*<<< orphan*/ sprintf(char *, char *, unsigned long);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char const *);
void paraDec(const char *num, char *res, const unsigned char base) {
  register char pos, exp;
  register unsigned long int n = 0;
  strcpy(res, "\0");
  for (pos = strlen(num) - 1, exp = 0; pos >= 0; pos--, exp++)
    n += potencia(base, exp) * ctoi(*(num + pos));
  sprintf(res, "%d", n);
}


x86 assembly (clang, -O0):
<paraDec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
mov    %al,-0x12(%rbp)
movb   $0x0,-0x13(%rbp)
movsbl -0x12(%rbp),%eax
cmp    $0x0,%eax
jl     11ec <paraDec+0x9c>
mov    -0x11(%rbp),%al
movzbl %al,%edi
movsbl -0x13(%rbp),%esi
call   1070 <potencia@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsbl -0x12(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <ctoi@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
imul   %rcx,%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x12(%rbp),%al
add    $0xff,%al
mov    %al,-0x12(%rbp)
mov    -0x13(%rbp),%al
add    $0x1,%al
mov    %al,-0x13(%rbp)
jmp    1190 <paraDec+0x40>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe07(%rip),%rsi
call   1060 <sprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<paraDec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rax
mov    %rdi,%r15
lea    0xe96(%rip),%rsi
mov    %rax,(%rsp)
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
xor    %r12d,%r12d
add    $0xff,%bl
js     11be <paraDec+0x6e>
movzbl %bpl,%r13d
xor    %ebp,%ebp
xchg   %ax,%ax
movsbl %bpl,%ebp
mov    %r13d,%edi
mov    %ebp,%esi
call   1070 <potencia@plt>
mov    %rax,%r14
movzbl %bl,%ebx
movsbl (%r15,%rbx,1),%edi
call   1040 <ctoi@plt>
imul   %r14,%rax
add    %rax,%r12
add    $0x1,%bpl
add    $0xff,%bl
jb     1190 <paraDec+0x40>
lea    0xe3d(%rip),%rsi
mov    (%rsp),%rdi
mov    %r12,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <sprintf@plt>

LLVM IR (-O0):
@.str = [2 x i8] zeroinitializer
@.str.1 = [3 x i8] c"%d\00"
define void @paraDec(i8* %0, i8* %1, i8 zeroext %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8 %2, i8* %6
store i64 0, i64* %9
%10 = load i8*, i8** %5
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
%14 = sub nsw i32 %13, 1
%15 = trunc i32 %14 to i8
store i8 %15, i8* %7
store i8 0, i8* %8
br label %16
16: ; preds = %34, %3
%17 = load i8, i8* %7
%18 = sext i8 %17 to i32
%19 = icmp sge i32 %18, 0
br i1 %19, label %20, label %39
20: ; preds = %16
%21 = load i8, i8* %6
%22 = load i8, i8* %8
%23 = call i64 @potencia(i8 zeroext %21, i8 signext %22)
%24 = load i8*, i8** %4
%25 = load i8, i8* %7
%26 = sext i8 %25 to i32
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
%29 = load i8, i8* %28
%30 = call i64 @ctoi(i8 signext %29)
%31 = mul i64 %23, %30
%32 = load i64, i64* %9
%33 = add i64 %32, %31
store i64 %33, i64* %9
br label %34
34: ; preds = %20
%35 = load i8, i8* %7
%36 = add i8 %35, -1
store i8 %36, i8* %7
%37 = load i8, i8* %8
%38 = add i8 %37, 1
store i8 %38, i8* %8
br label %16
39: ; preds = %16
%40 = load i8*, i8** %5
%41 = load i64, i64* %9
%42 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 %41)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] zeroinitializer
@.str.1 = [3 x i8] c"%d\00"
define void @paraDec(i8* %0, i8* %1, i8 zeroext %2) {
%4 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strlen(i8* %0)
%6 = trunc i32 %5 to i8
%7 = add i8 %6, -1
%8 = icmp sgt i8 %7, -1
br i1 %8, label %9, label %23
9: ; preds = %3, %9
%10 = phi i8 [ %21, %9 ], [ %7, %3 ]
%11 = phi i64 [ %19, %9 ], [ 0, %3 ]
%12 = phi i8 [ %20, %9 ], [ 0, %3 ]
%13 = tail call i64 @potencia(i8 zeroext %2, i8 signext %12)
%14 = zext i8 %10 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = tail call i64 @ctoi(i8 signext %16)
%18 = mul i64 %17, %13
%19 = add i64 %18, %11
%20 = add nuw i8 %12, 1
%21 = add i8 %10, -1
%22 = icmp eq i8 %20, %6
br i1 %22, label %23, label %9
23: ; preds = %9, %3
%24 = phi i64 [ 0, %3 ], [ %19, %9 ]
%25 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 %24)
ret void
}