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


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    $0x6,%rax
ja     11ce <dsay+0xbe>
mov    -0x18(%rbp),%rax
lea    0xec4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x8(%rbp),%xmm0
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
jmp    11df <dsay+0xcf>
movsd  -0x8(%rbp),%xmm0
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
jmp    11df <dsay+0xcf>
movsd  -0x8(%rbp),%xmm0
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
jmp    11df <dsay+0xcf>
movsd  -0x8(%rbp),%xmm0
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
jmp    11df <dsay+0xcf>
movsd  -0x8(%rbp),%xmm0
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
jmp    11df <dsay+0xcf>
movsd  -0x8(%rbp),%xmm0
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
jmp    11df <dsay+0xcf>
jmp    11ce <dsay+0xbe>
movsd  -0x8(%rbp),%xmm0
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dsay>:
cmp    $0x6,%edi
ja     112b <dsay+0x1b>
movslq %edi,%rax
lea    0xf05(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1030 <printf@plt>
lea    0xeda(%rip),%rdi
jmp    1030 <printf@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"%.5f \00"
@.str.5 = [6 x i8] c"%.6f \00"
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 %25 [
i32 0, label %6
i32 1, label %9
i32 2, label %12
i32 3, label %15
i32 5, label %18
i32 6, label %21
i32 4, label %24
]
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 %28
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 %28
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 %28
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 %28
18: ; preds = %2
%19 = load double, double* %3
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %19)
br label %28
21: ; preds = %2
%22 = load double, double* %3
%23 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), double %22)
br label %28
24: ; preds = %2
br label %25
25: ; preds = %2, %24
%26 = load double, double* %3
%27 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %26)
br label %28
28: ; preds = %25, %21, %18, %15, %12, %9, %6
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"%.5f \00"
@.str.5 = [6 x i8] c"%.6f \00"
@reltable.dsay = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.dsay to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.dsay to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.dsay to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.dsay to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.dsay to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.dsay to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.dsay to i64)) to i32)]
define void @dsay(double %0, i32 %1) {
%3 = icmp ult i32 %1, 7
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 ([7 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.2, i64 0, i64 0), %2 ]
%10 = tail call i32 @printf(i8* %9, double %0)
ret void
}