#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 int /*<<< orphan*/ tmp;

/* Variables and functions */
int /*<<< orphan*/ local_itoa(int, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void qcs_dec2base_d(int n, int nbits, int base, char *t) {
  int i;
  char tmp[512];
  memset(&tmp[0], 0, sizeof(tmp));
  local_itoa(n, &tmp[0], base);
  memset(t, '0', nbits);
  strcpy(t + nbits - strlen(tmp), &tmp[0]);
}


x86 assembly (clang, -O0):
<qcs_dec2base_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0x220(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1060 <local_itoa@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0x30,%esi
call   1050 <memset@plt>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x228(%rbp)
lea    -0x220(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x228(%rbp),%rdi
movslq %eax,%rcx
xor    %eax,%eax
sub    %rcx,%rax
add    %rax,%rdi
lea    -0x220(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qcs_dec2base_d>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %rcx,%rbx
mov    %edx,%r15d
mov    %esi,%ebp
mov    %edi,%r12d
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
mov    %r12d,%edi
mov    %r14,%rsi
mov    %r15d,%edx
call   1060 <local_itoa@plt>
mov    %rbx,%rdi
mov    $0x30,%esi
mov    %ebp,%edx
call   1050 <memset@plt>
movslq %ebp,%rbp
add    %rbx,%rbp
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
sub    %rax,%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @qcs_dec2base_d(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca [512 x i8]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%12 = call i32 @memset(i8* %11, i32 0, i32 512)
%13 = load i32, i32* %5
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%15 = load i32, i32* %7
%16 = call i32 @local_itoa(i32 %13, i8* %14, i32 %15)
%17 = load i8*, i8** %8
%18 = load i32, i32* %6
%19 = call i32 @memset(i8* %17, i32 48, i32 %18)
%20 = load i8*, i8** %8
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
%26 = sext i32 %25 to i64
%27 = sub i64 0, %26
%28 = getelementptr inbounds i8, i8* %23, i64 %27
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%30 = call i32 @strcpy(i8* %28, i8* %29)
ret void
}

LLVM IR (-O2):
define void @qcs_dec2base_d(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca [512 x i8]
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 512)
%8 = call i32 @local_itoa(i32 %0, i8* %6, i32 %2)
%9 = call i32 @memset(i8* %3, i32 48, i32 %1)
%10 = sext i32 %1 to i64
%11 = getelementptr inbounds i8, i8* %3, i64 %10
%12 = call i32 @strlen(i8* %6)
%13 = sext i32 %12 to i64
%14 = sub nsw i64 0, %13
%15 = getelementptr inbounds i8, i8* %11, i64 %14
%16 = call i32 @strcpy(i8* %15, i8* %6)
ret void
}