void eq_div(char *num, int num_len, int div_len) {
  while (num[num_len - 1] == '0')
    num_len--;
  if (num_len == 1) {
    printf("%c\n", num[0]);
  } else {
    printf("%c.", num[0]);
    printf("%.*s\n", num_len - 1, num + 1);
  }
}


x86 assembly (clang, -O0):
<eq_div>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jne    114a <eq_div+0x3a>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1122 <eq_div+0x12>
cmpl   $0x1,-0xc(%rbp)
jne    116e <eq_div+0x5e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119f <eq_div+0x8f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
mov    -0x8(%rbp),%rdx
add    $0x1,%rdx
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eq_div>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
movslq %esi,%rax
add    %rdi,%rax
add    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0xffffffff,%ebp
cmpb   $0x30,(%rax)
lea    -0x1(%rax),%rax
je     1130 <eq_div+0x20>
test   %ebp,%ebp
je     116e <eq_div+0x5e>
movsbl (%rbx),%esi
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
lea    0xeac(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>
movsbl (%rbx),%esi
lea    0xe88(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [4 x i8] c"%c\0A\00"
@.str.1 = [4 x i8] c"%c.\00"
@.str.2 = [6 x i8] c"%.*s\0A\00"
define void @eq_div(i8* %0, i32 %1, i32 %2) {
%4 = sext i32 %1 to i64
br label %5
5: ; preds = %5, %3
%6 = phi i64 [ %7, %5 ], [ %4, %3 ]
%7 = add nsw i64 %6, -1
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 48
br i1 %10, label %5, label %11
11: ; preds = %5
%12 = trunc i64 %6 to i32
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load i8, i8* %0
%16 = sext i8 %15 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %25
18: ; preds = %11
%19 = trunc i64 %7 to i32
%20 = load i8, i8* %0
%21 = sext i8 %20 to i32
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds i8, i8* %0, i64 1
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %19, i8* %23)
br label %25
25: ; preds = %18, %14
ret void
}