#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 atol(char const *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned long, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void decPara(const char *num, char *res, const unsigned char base) {
  register unsigned long int n = atol(num);
  char aux[256];
  strcpy(res, "\0");
  while (n >= base) {
    strcpy(aux, res);
    sprintf(res,
            "%d"
            "%s",
            (n % base), aux);
    n /= base;
  }
  strcpy(aux, res);
  sprintf(res,
          "%d"
          "%s",
          n, aux);
}


x86 assembly (clang, -O0):
<decPara>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <atol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
movzbl -0x11(%rbp),%ecx
cmp    %rcx,%rax
jb     11c2 <decPara+0x92>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
movzbl -0x11(%rbp),%ecx
xor    %edx,%edx
div    %rcx
lea    -0x120(%rbp),%rcx
lea    0xe5d(%rip),%rsi
call   1050 <sprintf@plt>
movzbl -0x11(%rbp),%eax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
xor    %edx,%edx
div    %rcx
mov    %rax,-0x20(%rbp)
jmp    1165 <decPara+0x35>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    -0x120(%rbp),%rcx
lea    0xe1a(%rip),%rsi
call   1050 <sprintf@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decPara>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
call   1040 <atol@plt>
mov    %rax,%rbx
lea    0xead(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %ebp,%ebp
cmp    %rbp,%rbx
jae    1195 <decPara+0x65>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xe8b(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   1050 <sprintf@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%r15
lea    0xe63(%rip),%r12
jmp    11ce <decPara+0x9e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rax
xor    %edx,%edx
div    %rbp
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rcx
call   1050 <sprintf@plt>
cmp    %rbp,%rbx
jb     1162 <decPara+0x32>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
shr    $0x20,%rax
jne    11b0 <decPara+0x80>
mov    %ebx,%eax
xor    %edx,%edx
div    %ebp
mov    %eax,%ebx
jmp    11bb <decPara+0x8b>

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

LLVM IR (-O2):
@.str = [2 x i8] zeroinitializer
@.str.1 = [5 x i8] c"%d%s\00"
define void @decPara(i8* nocapture %0, i8* %1, i8 zeroext %2) {
%4 = alloca [256 x i8]
%5 = tail call i64 @atol(i8* %0)
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = zext i8 %2 to i64
%9 = icmp ult i64 %5, %8
br i1 %9, label %17, label %10
10: ; preds = %3, %10
%11 = phi i64 [ %15, %10 ], [ %5, %3 ]
%12 = call i32 @strcpy(i8* %6, i8* %1)
%13 = urem i64 %11, %8
%14 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %13, i8* %6)
%15 = udiv i64 %11, %8
%16 = icmp ult i64 %15, %8
br i1 %16, label %17, label %10
17: ; preds = %10, %3
%18 = phi i64 [ %5, %3 ], [ %15, %10 ]
%19 = call i32 @strcpy(i8* %6, i8* %1)
%20 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %18, i8* %6)
ret void
}