#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int);
int rateWrite(FILE *fp, int start, double rate) {
  int iRate = rate * 5;
  for (int i = 0; i < 5; i++) {
    fprintf(fp, "%d:%d ", start + i, iRate == i ? 1 : 0);
  }
  return 1;
}


x86 assembly (clang, -O0):
<rateWrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  0xed4(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x5,-0x20(%rbp)
jge    1181 <rateWrite+0x71>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
add    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%r8d
xor    %ecx,%ecx
mov    $0x1,%eax
cmp    %r8d,%esi
cmove  %eax,%ecx
lea    0xe9a(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113f <rateWrite+0x2f>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rateWrite>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mulsd  0xee1(%rip),%xmm0
cvttsd2si %xmm0,%ebp
mov    %esi,%ebx
mov    %rdi,%r14
xor    %ecx,%ecx
test   %ebp,%ebp
sete   %cl
lea    0xed2(%rip),%r15
mov    %r15,%rsi
mov    %ebx,%edx
call   1030 <fprintf@plt>
lea    0x1(%rbx),%edx
xor    %ecx,%ecx
cmp    $0x1,%ebp
sete   %cl
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <fprintf@plt>
lea    0x2(%rbx),%edx
xor    %ecx,%ecx
cmp    $0x2,%ebp
sete   %cl
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <fprintf@plt>
lea    0x3(%rbx),%edx
xor    %ecx,%ecx
cmp    $0x3,%ebp
sete   %cl
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <fprintf@plt>
add    $0x4,%ebx
xor    %ecx,%ecx
cmp    $0x4,%ebp
sete   %cl
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1030 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%d:%d \00"
define i32 @rateWrite(i32* %0, i32 %1, double %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store double %2, double* %6
%9 = load double, double* %6
%10 = fmul double %9, 5.000000e+00
%11 = fptosi double %10 to i32
store i32 %11, i32* %7
store i32 0, i32* %8
br label %12
12: ; preds = %26, %3
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 5
br i1 %14, label %15, label %29
15: ; preds = %12
%16 = load i32*, i32** %4
%17 = load i32, i32* %5
%18 = load i32, i32* %8
%19 = add nsw i32 %17, %18
%20 = load i32, i32* %7
%21 = load i32, i32* %8
%22 = icmp eq i32 %20, %21
%23 = zext i1 %22 to i64
%24 = select i1 %22, i32 1, i32 0
%25 = call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %24)
br label %26
26: ; preds = %15
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %12
29: ; preds = %12
ret i32 1
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d:%d \00"
define i32 @rateWrite(i32* nocapture %0, i32 %1, double %2) {
%4 = fmul double %2, 5.000000e+00
%5 = fptosi double %4 to i32
%6 = icmp eq i32 %5, 0
%7 = zext i1 %6 to i32
%8 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %7)
%9 = add nsw i32 %1, 1
%10 = icmp eq i32 %5, 1
%11 = zext i1 %10 to i32
%12 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %11)
%13 = add nsw i32 %1, 2
%14 = icmp eq i32 %5, 2
%15 = zext i1 %14 to i32
%16 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %15)
%17 = add nsw i32 %1, 3
%18 = icmp eq i32 %5, 3
%19 = zext i1 %18 to i32
%20 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %19)
%21 = add nsw i32 %1, 4
%22 = icmp eq i32 %5, 4
%23 = zext i1 %22 to i32
%24 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %23)
ret i32 1
}