#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*/ sprintf(char *, char *, double);
int strlen(char *);
void print_sf(char *line, double round, double data) {
  if (round == 0) {
    sprintf(line + strlen(line), "%.0f", data);
  } else if (round == 4) {
    sprintf(line + strlen(line), "%.4f", data);
  } else if (round == 5) {
    sprintf(line + strlen(line), "%.5f", data);
  } else if (round == 8) {
    sprintf(line + strlen(line), "%.8f", data);
  }
}


x86 assembly (clang, -O0):
<print_sf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    117e <print_sf+0x5e>
jp     117e <print_sf+0x5e>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
cltq
add    %rax,%rdi
movsd  -0x18(%rbp),%xmm0
lea    0xea4(%rip),%rsi
call   1040 <sprintf@plt>
jmp    126f <print_sf+0x14f>
movsd  -0x10(%rbp),%xmm0
movsd  0xe75(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11cb <print_sf+0xab>
jp     11cb <print_sf+0xab>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
cltq
add    %rax,%rdi
movsd  -0x18(%rbp),%xmm0
lea    0xe5c(%rip),%rsi
call   1040 <sprintf@plt>
jmp    126a <print_sf+0x14a>
movsd  -0x10(%rbp),%xmm0
movsd  0xe30(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1218 <print_sf+0xf8>
jp     1218 <print_sf+0xf8>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
cltq
add    %rax,%rdi
movsd  -0x18(%rbp),%xmm0
lea    0xe14(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1265 <print_sf+0x145>
movsd  -0x10(%rbp),%xmm0
movsd  0xdeb(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1260 <print_sf+0x140>
jp     1260 <print_sf+0x140>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
cltq
add    %rax,%rdi
movsd  -0x18(%rbp),%xmm0
lea    0xdcc(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1265 <print_sf+0x145>
jmp    126a <print_sf+0x14a>
jmp    126f <print_sf+0x14f>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_sf>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
movsd  %xmm1,(%rsp)
jne    1141 <print_sf+0x21>
jp     1141 <print_sf+0x21>
lea    0xed9(%rip),%r14
jmp    117e <print_sf+0x5e>
ucomisd 0xeb7(%rip),%xmm0
jne    1156 <print_sf+0x36>
jp     1156 <print_sf+0x36>
lea    0xec9(%rip),%r14
jmp    117e <print_sf+0x5e>
ucomisd 0xeaa(%rip),%xmm0
jne    116b <print_sf+0x4b>
jp     116b <print_sf+0x4b>
lea    0xeb9(%rip),%r14
jmp    117e <print_sf+0x5e>
ucomisd 0xe9d(%rip),%xmm0
jne    11a0 <print_sf+0x80>
jp     11a0 <print_sf+0x80>
lea    0xea9(%rip),%r14
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rdi
add    %rbx,%rdi
mov    %r14,%rsi
movsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <sprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%.0f\00"
@.str.1 = [5 x i8] c"%.4f\00"
@.str.2 = [5 x i8] c"%.5f\00"
@.str.3 = [5 x i8] c"%.8f\00"
define void @print_sf(i8* %0, double %1, double %2) {
%4 = alloca i8*
%5 = alloca double
%6 = alloca double
store i8* %0, i8** %4
store double %1, double* %5
store double %2, double* %6
%7 = load double, double* %5
%8 = fcmp oeq double %7, 0.000000e+00
br i1 %8, label %9, label %17
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* %11)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = load double, double* %6
%16 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %15)
br label %53
17: ; preds = %3
%18 = load double, double* %5
%19 = fcmp oeq double %18, 4.000000e+00
br i1 %19, label %20, label %28
20: ; preds = %17
%21 = load i8*, i8** %4
%22 = load i8*, i8** %4
%23 = call i32 @strlen(i8* %22)
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %21, i64 %24
%26 = load double, double* %6
%27 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %26)
br label %52
28: ; preds = %17
%29 = load double, double* %5
%30 = fcmp oeq double %29, 5.000000e+00
br i1 %30, label %31, label %39
31: ; preds = %28
%32 = load i8*, i8** %4
%33 = load i8*, i8** %4
%34 = call i32 @strlen(i8* %33)
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %35
%37 = load double, double* %6
%38 = call i32 @sprintf(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %37)
br label %51
39: ; preds = %28
%40 = load double, double* %5
%41 = fcmp oeq double %40, 8.000000e+00
br i1 %41, label %42, label %50
42: ; preds = %39
%43 = load i8*, i8** %4
%44 = load i8*, i8** %4
%45 = call i32 @strlen(i8* %44)
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %43, i64 %46
%48 = load double, double* %6
%49 = call i32 @sprintf(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double %48)
br label %50
50: ; preds = %42, %39
br label %51
51: ; preds = %50, %31
br label %52
52: ; preds = %51, %20
br label %53
53: ; preds = %52, %9
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%.0f\00"
@.str.1 = [5 x i8] c"%.4f\00"
@.str.2 = [5 x i8] c"%.5f\00"
@.str.3 = [5 x i8] c"%.8f\00"
define void @print_sf(i8* %0, double %1, double %2) {
%4 = fcmp oeq double %1, 0.000000e+00
br i1 %4, label %11, label %5
5: ; preds = %3
%6 = fcmp oeq double %1, 4.000000e+00
br i1 %6, label %11, label %7
7: ; preds = %5
%8 = fcmp oeq double %1, 5.000000e+00
br i1 %8, label %11, label %9
9: ; preds = %7
%10 = fcmp oeq double %1, 8.000000e+00
br i1 %10, label %11, label %17
11: ; preds = %9, %7, %5, %3
%12 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %7 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %9 ]
%13 = tail call i32 @strlen(i8* %0)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = tail call i32 @sprintf(i8* dereferenceable(1) %15, i8* dereferenceable(1) %12, double %2)
br label %17
17: ; preds = %11, %9
ret void
}