#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stdout;
void dsay(double dv, int n) {
  switch (n) {
  case 0:
    printf("%.0f ", dv);
    break;
  case 1:
    printf("%.1f ", dv);
    break;
  case 2:
    printf("%.2f ", dv);
    break;
  case 3:
    printf("%.3f ", dv);
    break;
  case 4:
  default:
    printf("%.4f ", dv);
    break;
  }
  fflush(stdout);
}


x86 assembly (clang, -O0):
<dsay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x4,%rax
ja     11b2 <dsay+0x92>
mov    -0x18(%rbp),%rax
lea    0xeb4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x8(%rbp),%xmm0
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
jmp    11c3 <dsay+0xa3>
movsd  -0x8(%rbp),%xmm0
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
jmp    11c3 <dsay+0xa3>
movsd  -0x8(%rbp),%xmm0
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
jmp    11c3 <dsay+0xa3>
movsd  -0x8(%rbp),%xmm0
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
jmp    11c3 <dsay+0xa3>
jmp    11b2 <dsay+0x92>
movsd  -0x8(%rbp),%xmm0
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dsay>:
push   %rax
cmp    $0x3,%edi
ja     1139 <dsay+0x19>
movslq %edi,%rax
lea    0xef0(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1140 <dsay+0x20>
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    1040 <fflush@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%.0f \00"
@.str.1 = [6 x i8] c"%.1f \00"
@.str.2 = [6 x i8] c"%.2f \00"
@.str.3 = [6 x i8] c"%.3f \00"
@.str.4 = [6 x i8] c"%.4f \00"
@stdout = global i32 0
define void @dsay(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
store double %0, double* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
switch i32 %5, label %19 [
i32 0, label %6
i32 1, label %9
i32 2, label %12
i32 3, label %15
i32 4, label %18
]
6: ; preds = %2
%7 = load double, double* %3
%8 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %7)
br label %22
9: ; preds = %2
%10 = load double, double* %3
%11 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %10)
br label %22
12: ; preds = %2
%13 = load double, double* %3
%14 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %13)
br label %22
15: ; preds = %2
%16 = load double, double* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), double %16)
br label %22
18: ; preds = %2
br label %19
19: ; preds = %2, %18
%20 = load double, double* %3
%21 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %20)
br label %22
22: ; preds = %19, %15, %12, %9, %6
%23 = load i32, i32* @stdout
%24 = call i32 @fflush(i32 %23)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%.0f \00"
@.str.1 = [6 x i8] c"%.1f \00"
@.str.2 = [6 x i8] c"%.2f \00"
@.str.3 = [6 x i8] c"%.3f \00"
@.str.4 = [6 x i8] c"%.4f \00"
@stdout = global i32 0
@reltable.dsay = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.dsay to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.dsay to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.dsay to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.dsay to i64)) to i32)]
define void @dsay(double %0, i32 %1) {
%3 = icmp ult i32 %1, 4
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = sext i32 %1 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.dsay to i8*), i64 %6)
br label %8
8: ; preds = %2, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %2 ]
%10 = tail call i32 @printf(i8* %9, double %0)
%11 = load i32, i32* @stdout
%12 = tail call i32 @fflush(i32 %11)
ret void
}