#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
void print_fixed(uint32_t value, int divider) {
  int i = 0, f = 0;
  if (divider == 1000000) {
    i = value / 1000000;
    f = (value % 1000000) / 1000;
    printf("%d.%03d", i, f);
  } else if (divider == 1000) {
    i = value / 1000;
    f = value % 1000;
    printf("%d.%03d", i, f);
  } else if (divider == 64) {
    i = value / 64;
    f = ((value % 64) * 1000) / 64;
    printf("%d.%03d", i, f);
  } else {
  }
}


x86 assembly (clang, -O0):
<print_fixed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jne    1176 <print_fixed+0x66>
mov    -0x4(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
jmp    1210 <print_fixed+0x100>
cmpl   $0x3e8,-0x8(%rbp)
jne    11b6 <print_fixed+0xa6>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
jmp    120b <print_fixed+0xfb>
cmpl   $0x40,-0x8(%rbp)
jne    1201 <print_fixed+0xf1>
mov    -0x4(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
imul   $0x3e8,%edx,%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe09(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <print_fixed+0xf6>
jmp    1206 <print_fixed+0xf6>
jmp    120b <print_fixed+0xfb>
jmp    1210 <print_fixed+0x100>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_fixed>:
mov    %edi,%edx
cmp    $0x40,%esi
je     116d <print_fixed+0x5d>
cmp    $0x3e8,%esi
je     119c <print_fixed+0x8c>
cmp    $0xf4240,%esi
jne    11c7 <print_fixed+0xb7>
movslq %edx,%rax
imul   $0x431bde83,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x32,%rsi
add    %eax,%esi
imul   $0xf4240,%esi,%eax
sub    %eax,%edx
movslq %edx,%rax
imul   $0x10624dd3,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x26,%rdx
add    %eax,%edx
lea    0xe98(%rip),%rdi
jmp    1030 <printf@plt>
lea    0x3f(%rdx),%eax
test   %edx,%edx
cmovns %edx,%eax
mov    %eax,%esi
sar    $0x6,%esi
and    $0xffffffc0,%eax
sub    %eax,%edx
imul   $0x3e8,%edx,%eax
lea    0x3f(%rax),%edx
test   %eax,%eax
cmovns %eax,%edx
sar    $0x6,%edx
lea    0xe69(%rip),%rdi
jmp    1030 <printf@plt>
movslq %edx,%rax
imul   $0x10624dd3,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x26,%rsi
add    %eax,%esi
imul   $0x3e8,%esi,%eax
sub    %eax,%edx
lea    0xe3e(%rip),%rdi
jmp    1030 <printf@plt>
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%d.%03d\00"
define void @print_fixed(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1000000
br i1 %8, label %9, label %18
9: ; preds = %2
%10 = load i32, i32* %3
%11 = sdiv i32 %10, 1000000
store i32 %11, i32* %5
%12 = load i32, i32* %3
%13 = srem i32 %12, 1000000
%14 = sdiv i32 %13, 1000
store i32 %14, i32* %6
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
br label %45
18: ; preds = %2
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 1000
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = load i32, i32* %3
%23 = sdiv i32 %22, 1000
store i32 %23, i32* %5
%24 = load i32, i32* %3
%25 = srem i32 %24, 1000
store i32 %25, i32* %6
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %27)
br label %44
29: ; preds = %18
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, 64
br i1 %31, label %32, label %42
32: ; preds = %29
%33 = load i32, i32* %3
%34 = sdiv i32 %33, 64
store i32 %34, i32* %5
%35 = load i32, i32* %3
%36 = srem i32 %35, 64
%37 = mul nsw i32 %36, 1000
%38 = sdiv i32 %37, 64
store i32 %38, i32* %6
%39 = load i32, i32* %5
%40 = load i32, i32* %6
%41 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %39, i32 %40)
br label %43
42: ; preds = %29
br label %43
43: ; preds = %42, %32
br label %44
44: ; preds = %43, %21
br label %45
45: ; preds = %44, %9
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%d.%03d\00"
define void @print_fixed(i32 %0, i32 %1) {
switch i32 %1, label %18 [
i32 1000000, label %3
i32 1000, label %8
i32 64, label %12
]
3: ; preds = %2
%4 = sdiv i32 %0, 1000000
%5 = srem i32 %0, 1000000
%6 = sdiv i32 %5, 1000
%7 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6)
br label %18
8: ; preds = %2
%9 = sdiv i32 %0, 1000
%10 = srem i32 %0, 1000
%11 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
br label %18
12: ; preds = %2
%13 = sdiv i32 %0, 64
%14 = srem i32 %0, 64
%15 = mul nsw i32 %14, 1000
%16 = sdiv i32 %15, 64
%17 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %16)
br label %18
18: ; preds = %2, %8, %12, %3
ret void
}