#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 /*<<< orphan*/ memset(char *, char, unsigned int);
int /*<<< orphan*/ my_itoa(unsigned int, unsigned char, char *);
unsigned int my_itoa_char_char_size(unsigned int, unsigned char, unsigned char);
char *my_itoa_char(unsigned int number, unsigned char nbc, unsigned char base,
                   char c, char *buff) {
  unsigned int len;
  if ((len = my_itoa_char_char_size(number, nbc, base)))
    memset(buff, c, len);
  my_itoa(number, base, (buff + len));
  return buff;
}


x86 assembly (clang, -O0):
<my_itoa_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %sil,%dl
mov    %edi,-0x4(%rbp)
mov    %dl,-0x5(%rbp)
mov    %cl,-0x6(%rbp)
mov    %al,-0x7(%rbp)
mov    %r8,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x5(%rbp),%al
movzbl %al,%esi
movzbl -0x6(%rbp),%edx
call   1050 <my_itoa_char_char_size@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     117f <my_itoa_char+0x4f>
mov    -0x10(%rbp),%rdi
mov    -0x7(%rbp),%al
mov    -0x14(%rbp),%edx
movsbl %al,%esi
call   1040 <memset@plt>
mov    -0x4(%rbp),%edi
mov    -0x6(%rbp),%al
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
add    %rcx,%rdx
movzbl %al,%esi
call   1030 <my_itoa@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_itoa_char>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%rbx
mov    %ecx,%r15d
mov    %edx,%r14d
mov    %edi,%r12d
call   1050 <my_itoa_char_char_size@plt>
mov    %eax,%ebp
test   %eax,%eax
je     115d <my_itoa_char+0x2d>
movsbl %r15b,%esi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1040 <memset@plt>
mov    %ebp,%edx
add    %rbx,%rdx
movzbl %r14b,%esi
mov    %r12d,%edi
call   1030 <my_itoa@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @my_itoa_char(i32 %0, i8 zeroext %1, i8 zeroext %2, i8 signext %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8*
%11 = alloca i32
store i32 %0, i32* %6
store i8 %1, i8* %7
store i8 %2, i8* %8
store i8 %3, i8* %9
store i8* %4, i8** %10
%12 = load i32, i32* %6
%13 = load i8, i8* %7
%14 = load i8, i8* %8
%15 = call i32 @my_itoa_char_char_size(i32 %12, i8 zeroext %13, i8 zeroext %14)
store i32 %15, i32* %11
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %5
%18 = load i8*, i8** %10
%19 = load i8, i8* %9
%20 = load i32, i32* %11
%21 = call i32 @memset(i8* %18, i8 signext %19, i32 %20)
br label %22
22: ; preds = %17, %5
%23 = load i32, i32* %6
%24 = load i8, i8* %8
%25 = load i8*, i8** %10
%26 = load i32, i32* %11
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = call i32 @my_itoa(i32 %23, i8 zeroext %24, i8* %28)
%30 = load i8*, i8** %10
ret i8* %30
}

LLVM IR (-O2):
define i8* @my_itoa_char(i32 %0, i8 zeroext %1, i8 zeroext %2, i8 signext %3, i8* returned %4) {
%6 = tail call i32 @my_itoa_char_char_size(i32 %0, i8 zeroext %1, i8 zeroext %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @memset(i8* %4, i8 signext %3, i32 %6)
br label %10
10: ; preds = %8, %5
%11 = zext i32 %6 to i64
%12 = getelementptr inbounds i8, i8* %4, i64 %11
%13 = tail call i32 @my_itoa(i32 %0, i8 zeroext %2, i8* %12)
ret i8* %4
}