#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);
double sin(float);
int create_pattern(int frequency, int count) {
  float coefficient = frequency * 3.1415926535897 / 500;
  for (int i = 0; i < count; i++) {
    printf("%10f\n", sin(coefficient * i));
  }
  return 0;
}


x86 assembly (clang, -O0):
<create_pattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xecd(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeb9(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1194 <create_pattern+0x74>
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
mulss  %xmm1,%xmm0
call   1040 <sin@plt>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115b <create_pattern+0x3b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_pattern>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %esi,%esi
jle    1181 <create_pattern+0x61>
mov    %esi,%ebx
cvtsi2sd %edi,%xmm0
mulsd  0xec6(%rip),%xmm0
divsd  0xec6(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
xor    %ebp,%ebp
lea    0xebb(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
mulss  0xc(%rsp),%xmm0
call   1040 <sin@plt>
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1160 <create_pattern+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%10f\0A\00"
define i32 @create_pattern(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = sitofp i32 %7 to double
%9 = fmul double %8, 0x400921FB54442C46
%10 = fdiv double %9, 5.000000e+02
%11 = fptrunc double %10 to float
store float %11, float* %5
store i32 0, i32* %6
br label %12
12: ; preds = %23, %2
%13 = load i32, i32* %6
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load float, float* %5
%18 = load i32, i32* %6
%19 = sitofp i32 %18 to float
%20 = fmul float %17, %19
%21 = call double @sin(float %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %21)
br label %23
23: ; preds = %16
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %12
26: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%10f\0A\00"
define i32 @create_pattern(i32 %0, i32 %1) {
%3 = sitofp i32 %0 to double
%4 = fmul double %3, 0x400921FB54442C46
%5 = fdiv double %4, 5.000000e+02
%6 = fptrunc double %5 to float
%7 = icmp sgt i32 %1, 0
br i1 %7, label %9, label %8
8: ; preds = %9, %2
ret i32 0
9: ; preds = %2, %9
%10 = phi i32 [ %15, %9 ], [ 0, %2 ]
%11 = sitofp i32 %10 to float
%12 = fmul float %6, %11
%13 = tail call double @sin(float %12)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %13)
%15 = add nuw nsw i32 %10, 1
%16 = icmp eq i32 %15, %1
br i1 %16, label %8, label %9
}