#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*/ sprintf(char *, char *, char, unsigned int);
void set_digits(unsigned int len, unsigned int *digits,
                const unsigned int *mods, char sep, char *buf) {
  unsigned int i;
  for (i = 0; i < len; ++i)
    buf += sprintf(buf, "%c%d", sep, digits[i] % mods[i]);
}


x86 assembly (clang, -O0):
<set_digits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %cl,%al
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %al,-0x19(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1193 <set_digits+0x83>
mov    -0x28(%rbp),%rdi
mov    -0x19(%rbp),%al
mov    %al,-0x2d(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    -0x18(%rbp),%rcx
mov    -0x2c(%rbp),%edx
mov    %edx,%esi
xor    %edx,%edx
divl   (%rcx,%rsi,4)
mov    -0x2d(%rbp),%al
mov    %edx,%ecx
lea    0xe93(%rip),%rsi
movsbl %al,%edx
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1133 <set_digits+0x23>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_digits>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
je     116b <set_digits+0x5b>
mov    %r8,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r13d
xor    %r12d,%r12d
movsbl %cl,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15,%r12,4),%eax
xor    %edx,%edx
divl   (%r14,%r12,4)
mov    %edx,%ecx
mov    %rbx,%rdi
lea    0xeaa(%rip),%rsi
mov    %ebp,%edx
call   1030 <sprintf@plt>
cltq
add    %rax,%rbx
add    $0x1,%r12
cmp    %r12,%r13
jne    1140 <set_digits+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%c%d\00"
define void @set_digits(i32 %0, i32* nocapture %1, i32* nocapture %2, i8 signext %3, i8* nocapture writeonly %4) {
%6 = icmp eq i32 %0, 0
br i1 %6, label %22, label %7
7: ; preds = %5
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %20, %9 ]
%11 = phi i8* [ %4, %7 ], [ %19, %9 ]
%12 = getelementptr inbounds i32, i32* %1, i64 %10
%13 = load i32, i32* %12
%14 = getelementptr inbounds i32, i32* %2, i64 %10
%15 = load i32, i32* %14
%16 = urem i32 %13, %15
%17 = tail call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %3, i32 %16)
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %11, i64 %18
%20 = add nuw nsw i64 %10, 1
%21 = icmp eq i64 %20, %8
br i1 %21, label %22, label %9
22: ; preds = %9, %5
ret void
}