void generate_signs(const int number, const int length, char *string) {
  for (int i = length, j = 0; i >= 0; i--, j++) {
    if ((number >> i) & 1) {
      string[j] = '+';
    } else {
      string[j] = '-';
    }
  }
}


x86 assembly (clang, -O0):
<generate_signs>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1172 <generate_signs+0x72>
mov    -0x4(%rbp),%eax
mov    -0x14(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     114a <generate_signs+0x4a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x2b,(%rax,%rcx,1)
jmp    1156 <generate_signs+0x56>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x2d,(%rax,%rcx,1)
jmp    115b <generate_signs+0x5b>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    111b <generate_signs+0x1b>
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_signs>:
test   %esi,%esi
js     1539 <generate_signs+0x439>
lea    0x1(%rsi),%r8d
cmp    $0xf,%esi
jae    1118 <generate_signs+0x18>
xor    %ecx,%ecx
jmp    1520 <generate_signs+0x420>
mov    %r8d,%ecx
and    $0xfffffff0,%ecx
movd   %esi,%xmm0
pshufd $0x0,%xmm0,%xmm4
movdqa 0xed0(%rip),%xmm15
paddd  %xmm4,%xmm15
movdqa 0xed2(%rip),%xmm9
paddd  %xmm4,%xmm9
movdqa 0xed4(%rip),%xmm10
paddd  %xmm4,%xmm10
paddd  0xed7(%rip),%xmm4
movd   %edi,%xmm0
pshufd $0x0,%xmm0,%xmm14
lea    -0x10(%rcx),%rax
mov    %rax,%r9
shr    $0x4,%r9
add    $0x1,%r9
test   %rax,%rax
je     153a <generate_signs+0x43a>
mov    %r9,%rax
and    $0xfffffffffffffffe,%rax
xor    %r10d,%r10d
movdqa 0xeb2(%rip),%xmm12
movdqa 0xeba(%rip),%xmm6
pxor   %xmm13,%xmm13
movdqa 0xecc(%rip),%xmm11
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movdqa %xmm4,%xmm0
pslld  $0x17,%xmm0
paddd  %xmm12,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm1
pmuludq %xmm6,%xmm0
pshufd $0xe8,%xmm0,%xmm5
pmuludq %xmm6,%xmm1
pshufd $0xe8,%xmm1,%xmm0
punpckldq %xmm0,%xmm5
movdqa %xmm10,%xmm0
pslld  $0x17,%xmm0
paddd  %xmm12,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm7
pmuludq %xmm6,%xmm0
pshufd $0xe8,%xmm0,%xmm1
pmuludq %xmm6,%xmm7
pshufd $0xe8,%xmm7,%xmm0
punpckldq %xmm0,%xmm1
movdqa %xmm9,%xmm0
pslld  $0x17,%xmm0
paddd  %xmm12,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm7
pmuludq %xmm6,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm6,%xmm7
pshufd $0xe8,%xmm7,%xmm7
punpckldq %xmm7,%xmm0
movdqa %xmm15,%xmm7
pslld  $0x17,%xmm7
paddd  %xmm12,%xmm7
cvttps2dq %xmm7,%xmm7
pshufd $0xf5,%xmm7,%xmm8
pmuludq %xmm6,%xmm7
pshufd $0xe8,%xmm7,%xmm7
pmuludq %xmm6,%xmm8
pshufd $0xe8,%xmm8,%xmm2
punpckldq %xmm2,%xmm7
pand   %xmm14,%xmm7
pand   %xmm14,%xmm0
pand   %xmm14,%xmm1
pand   %xmm14,%xmm5
pcmpeqd %xmm13,%xmm5
pcmpeqd %xmm13,%xmm1
packssdw %xmm1,%xmm5
pcmpeqd %xmm13,%xmm0
pcmpeqd %xmm13,%xmm7
packssdw %xmm7,%xmm0
packsswb %xmm0,%xmm5
movdqa %xmm5,%xmm0
movdqa 0xdb5(%rip),%xmm8
pandn  %xmm8,%xmm0
pand   %xmm11,%xmm5
por    %xmm0,%xmm5
movdqu %xmm5,(%rdx,%r10,1)
movdqa %xmm15,%xmm1
movdqa 0xdb4(%rip),%xmm3
paddd  %xmm3,%xmm1
movdqa %xmm9,%xmm7
paddd  %xmm3,%xmm7
movdqa %xmm10,%xmm0
paddd  %xmm3,%xmm0
movdqa %xmm4,%xmm2
paddd  %xmm3,%xmm2
pslld  $0x17,%xmm2
paddd  %xmm12,%xmm2
cvttps2dq %xmm2,%xmm2
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm5
pmuludq %xmm6,%xmm3
pshufd $0xe8,%xmm3,%xmm2
punpckldq %xmm2,%xmm5
pslld  $0x17,%xmm0
paddd  %xmm12,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm6,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm0
pslld  $0x17,%xmm7
paddd  %xmm12,%xmm7
cvttps2dq %xmm7,%xmm2
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm7
pmuludq %xmm6,%xmm3
pshufd $0xe8,%xmm3,%xmm2
punpckldq %xmm2,%xmm7
pslld  $0x17,%xmm1
paddd  %xmm12,%xmm1
cvttps2dq %xmm1,%xmm1
pshufd $0xf5,%xmm1,%xmm2
pmuludq %xmm6,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm6,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
pand   %xmm14,%xmm0
pand   %xmm14,%xmm5
pcmpeqd %xmm13,%xmm5
pcmpeqd %xmm13,%xmm0
packssdw %xmm0,%xmm5
pand   %xmm14,%xmm1
pand   %xmm14,%xmm7
pcmpeqd %xmm13,%xmm7
pcmpeqd %xmm13,%xmm1
packssdw %xmm1,%xmm7
packsswb %xmm7,%xmm5
movdqa %xmm5,%xmm0
pandn  %xmm8,%xmm0
pand   %xmm11,%xmm5
por    %xmm0,%xmm5
movdqu %xmm5,0x10(%rdx,%r10,1)
add    $0x20,%r10
movdqa 0xca9(%rip),%xmm0
paddd  %xmm0,%xmm4
paddd  %xmm0,%xmm10
paddd  %xmm0,%xmm9
paddd  %xmm0,%xmm15
add    $0xfffffffffffffffe,%rax
jne    11b0 <generate_signs+0xb0>
test   $0x1,%r9b
je     1519 <generate_signs+0x419>
pslld  $0x17,%xmm4
movdqa 0xc25(%rip),%xmm0
paddd  %xmm0,%xmm4
cvttps2dq %xmm4,%xmm2
movdqa 0xc25(%rip),%xmm1
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm1,%xmm2
pshufd $0xe8,%xmm2,%xmm4
pmuludq %xmm1,%xmm3
pshufd $0xe8,%xmm3,%xmm2
punpckldq %xmm2,%xmm4
pslld  $0x17,%xmm10
paddd  %xmm0,%xmm10
cvttps2dq %xmm10,%xmm2
pshufd $0xf5,%xmm2,%xmm5
pmuludq %xmm1,%xmm2
pshufd $0xe8,%xmm2,%xmm3
pmuludq %xmm1,%xmm5
pshufd $0xe8,%xmm5,%xmm2
punpckldq %xmm2,%xmm3
pslld  $0x17,%xmm9
paddd  %xmm0,%xmm9
cvttps2dq %xmm9,%xmm2
pshufd $0xf5,%xmm2,%xmm5
pmuludq %xmm1,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pmuludq %xmm1,%xmm5
pshufd $0xe8,%xmm5,%xmm5
punpckldq %xmm5,%xmm2
pslld  $0x17,%xmm15
paddd  %xmm0,%xmm15
cvttps2dq %xmm15,%xmm0
pshufd $0xf5,%xmm0,%xmm5
pmuludq %xmm1,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm1,%xmm5
pshufd $0xe8,%xmm5,%xmm1
punpckldq %xmm1,%xmm0
pand   %xmm14,%xmm0
pand   %xmm14,%xmm2
pand   %xmm14,%xmm3
pand   %xmm14,%xmm4
pxor   %xmm1,%xmm1
pcmpeqd %xmm1,%xmm4
pcmpeqd %xmm1,%xmm3
packssdw %xmm3,%xmm4
pcmpeqd %xmm1,%xmm2
pcmpeqd %xmm1,%xmm0
packssdw %xmm0,%xmm2
packsswb %xmm2,%xmm4
movdqa %xmm4,%xmm0
pandn  0xb59(%rip),%xmm0
pand   0xb61(%rip),%xmm4
por    %xmm0,%xmm4
movdqu %xmm4,(%rdx,%r10,1)
cmp    %r8,%rcx
je     1539 <generate_signs+0x439>
sub    %ecx,%esi
bt     %esi,%edi
setae  %al
add    %al,%al
add    $0x2b,%al
mov    %al,(%rdx,%rcx,1)
add    $0xffffffff,%esi
add    $0x1,%rcx
cmp    %rcx,%r8
jne    1520 <generate_signs+0x420>
ret
xor    %r10d,%r10d
test   $0x1,%r9b
jne    140e <generate_signs+0x30e>
jmp    1519 <generate_signs+0x419>

LLVM IR (-O0):
define void @generate_signs(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = load i32, i32* %5
store i32 %9, i32* %7
store i32 0, i32* %8
br label %10
10: ; preds = %30, %3
%11 = load i32, i32* %7
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %35
13: ; preds = %10
%14 = load i32, i32* %4
%15 = load i32, i32* %7
%16 = ashr i32 %14, %15
%17 = and i32 %16, 1
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %13
%20 = load i8*, i8** %6
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 43, i8* %23
br label %29
24: ; preds = %13
%25 = load i8*, i8** %6
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
store i8 45, i8* %28
br label %29
29: ; preds = %24, %19
br label %30
30: ; preds = %29
%31 = load i32, i32* %7
%32 = add nsw i32 %31, -1
store i32 %32, i32* %7
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
store i32 %34, i32* %8
br label %10
35: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @generate_signs(i32 %0, i32 %1, i8* nocapture writeonly %2) {
%4 = icmp sgt i32 %1, -1
br i1 %4, label %5, label %63
5: ; preds = %3
%6 = add nuw i32 %1, 1
%7 = zext i32 %6 to i64
%8 = icmp ult i32 %1, 15
br i1 %8, label %60, label %9
9: ; preds = %5
%10 = and i64 %7, 4294967280
%11 = trunc i64 %10 to i32
%12 = sub i32 %1, %11
%13 = insertelement <16 x i32> poison, i32 %1, i64 0
%14 = shufflevector <16 x i32> %13, <16 x i32> poison, <16 x i32> zeroinitializer
%15 = add <16 x i32> %14, <i32 0, i32 -1, i32 -2, i32 -3, i32 -4, i32 -5, i32 -6, i32 -7, i32 -8, i32 -9, i32 -10, i32 -11, i32 -12, i32 -13, i32 -14, i32 -15>
%16 = insertelement <16 x i32> poison, i32 %0, i64 0
%17 = shufflevector <16 x i32> %16, <16 x i32> poison, <16 x i32> zeroinitializer
%18 = add nsw i64 %10, -16
%19 = lshr exact i64 %18, 4
%20 = add nuw nsw i64 %19, 1
%21 = and i64 %20, 1
%22 = icmp eq i64 %18, 0
br i1 %22, label %47, label %23
23: ; preds = %9
%24 = and i64 %20, 2305843009213693950
br label %25
25: ; preds = %25, %23
%26 = phi i64 [ 0, %23 ], [ %43, %25 ]
%27 = phi <16 x i32> [ %15, %23 ], [ %44, %25 ]
%28 = phi i64 [ 0, %23 ], [ %45, %25 ]
%29 = shl nuw <16 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>, %27
%30 = and <16 x i32> %29, %17
%31 = icmp eq <16 x i32> %30, zeroinitializer
%32 = select <16 x i1> %31, <16 x i8> <i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45>, <16 x i8> <i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43>
%33 = getelementptr inbounds i8, i8* %2, i64 %26
%34 = bitcast i8* %33 to <16 x i8>*
store <16 x i8> %32, <16 x i8>* %34
%35 = or i64 %26, 16
%36 = add <16 x i32> %27, <i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16, i32 -16>
%37 = shl nuw <16 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>, %36
%38 = and <16 x i32> %37, %17
%39 = icmp eq <16 x i32> %38, zeroinitializer
%40 = select <16 x i1> %39, <16 x i8> <i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45>, <16 x i8> <i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43>
%41 = getelementptr inbounds i8, i8* %2, i64 %35
%42 = bitcast i8* %41 to <16 x i8>*
store <16 x i8> %40, <16 x i8>* %42
%43 = add nuw i64 %26, 32
%44 = add <16 x i32> %27, <i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32, i32 -32>
%45 = add i64 %28, 2
%46 = icmp eq i64 %45, %24
br i1 %46, label %47, label %25
47: ; preds = %25, %9
%48 = phi i64 [ 0, %9 ], [ %43, %25 ]
%49 = phi <16 x i32> [ %15, %9 ], [ %44, %25 ]
%50 = icmp eq i64 %21, 0
br i1 %50, label %58, label %51
51: ; preds = %47
%52 = shl nuw <16 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>, %49
%53 = and <16 x i32> %52, %17
%54 = icmp eq <16 x i32> %53, zeroinitializer
%55 = select <16 x i1> %54, <16 x i8> <i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45, i8 45>, <16 x i8> <i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43, i8 43>
%56 = getelementptr inbounds i8, i8* %2, i64 %48
%57 = bitcast i8* %56 to <16 x i8>*
store <16 x i8> %55, <16 x i8>* %57
br label %58
58: ; preds = %47, %51
%59 = icmp eq i64 %10, %7
br i1 %59, label %63, label %60
60: ; preds = %5, %58
%61 = phi i64 [ 0, %5 ], [ %10, %58 ]
%62 = phi i32 [ %1, %5 ], [ %12, %58 ]
br label %64
63: ; preds = %64, %58, %3
ret void
64: ; preds = %60, %64
%65 = phi i64 [ %73, %64 ], [ %61, %60 ]
%66 = phi i32 [ %72, %64 ], [ %62, %60 ]
%67 = shl nuw i32 1, %66
%68 = and i32 %67, %0
%69 = icmp eq i32 %68, 0
%70 = select i1 %69, i8 45, i8 43
%71 = getelementptr inbounds i8, i8* %2, i64 %65
store i8 %70, i8* %71
%72 = add nsw i32 %66, -1
%73 = add nuw nsw i64 %65, 1
%74 = icmp eq i64 %73, %7
br i1 %74, label %63, label %64
}