#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*/ getchar();
int log10(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *, float *);
int /*<<< orphan*/ sin(float);
void ten() {
  int i;
  float angle, accuracy, term, sum;
  printf("enter angle (float), accuracy (float): ");
  scanf("%f%f", &angle, &accuracy);
  angle *= 3.1415926 / 180;
  sum = term = angle;
  for (i = 2; (term >= accuracy) || (term <= -accuracy); ++i) {
    term = -angle * angle * term / ((2 * i - 1) * (2 * i - 2));
    sum += term;
  }
  printf("\ncomputed sine\t\t= %+*.*f\ncomputer generated sine\t= %+*.*f\n",
         (log10(accuracy) > 0 ? (int)(1 + log10(accuracy))
                              : (int)(1 - log10(accuracy)) + 3),
         log10(accuracy) > 0 ? (int)(1 + log10(accuracy))
                             : (int)(1 - log10(accuracy)),
         sum,
         (log10(accuracy) > 0 ? (int)(1 + log10(accuracy))
                              : (int)(1 - log10(accuracy)) + 3),
         log10(accuracy) > 0 ? (int)(1 + log10(accuracy))
                             : (int)(1 - log10(accuracy)),
         sin(angle));
  getchar();
  printf("\nreturning to menu. press Enter...");
  getchar();
}


x86 assembly (clang, -O0):
<ten>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1060 <scanf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe75(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movl   $0x2,-0x4(%rbp)
movss  -0x10(%rbp),%xmm0
mov    $0x1,%al
ucomiss -0xc(%rbp),%xmm0
mov    %al,-0x15(%rbp)
jae    11e2 <ten+0x92>
movss  -0x10(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
ucomiss %xmm1,%xmm0
setae  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11f2 <ten+0xa2>
jmp    124d <ten+0xfd>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  -0x8(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x2,%ecx
imul   %ecx,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11ae <ten+0x5e>
movss  -0xc(%rbp),%xmm0
call   1070 <log10@plt>
cmp    $0x0,%eax
jle    1275 <ten+0x125>
movss  -0xc(%rbp),%xmm0
call   1070 <log10@plt>
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    128e <ten+0x13e>
movss  -0xc(%rbp),%xmm0
call   1070 <log10@plt>
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
add    $0x3,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
call   1070 <log10@plt>
cmp    $0x0,%eax
jle    12bc <ten+0x16c>
movss  -0xc(%rbp),%xmm0
call   1070 <log10@plt>
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12d2 <ten+0x182>
movss  -0xc(%rbp),%xmm0
call   1070 <log10@plt>
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movss  -0xc(%rbp),%xmm0
call   1070 <log10@plt>
cmp    $0x0,%eax
jle    130e <ten+0x1be>
movss  -0xc(%rbp),%xmm0
call   1070 <log10@plt>
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1327 <ten+0x1d7>
movss  -0xc(%rbp),%xmm0
call   1070 <log10@plt>
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
add    $0x3,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movss  -0xc(%rbp),%xmm0
call   1070 <log10@plt>
cmp    $0x0,%eax
jle    1355 <ten+0x205>
movss  -0xc(%rbp),%xmm0
call   1070 <log10@plt>
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    136b <ten+0x21b>
movss  -0xc(%rbp),%xmm0
call   1070 <log10@plt>
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
movss  -0x8(%rbp),%xmm0
call   1050 <sin@plt>
mov    -0x20(%rbp),%esi
mov    -0x34(%rbp),%edx
movsd  -0x30(%rbp),%xmm0
mov    -0x3c(%rbp),%ecx
mov    -0x44(%rbp),%r8d
mov    %eax,%r9d
lea    0xc9e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xcc4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ten>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <scanf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe6c(%rip),%xmm0
cvtsd2ss %xmm0,%xmm5
movss  %xmm5,0xc(%rsp)
movss  0x8(%rsp),%xmm0
movaps 0xe65(%rip),%xmm1
xorps  %xmm0,%xmm1
ucomiss %xmm0,%xmm5
jae    11b8 <ten+0x68>
ucomiss %xmm5,%xmm1
jb     11f6 <ten+0xa6>
movaps 0xe51(%rip),%xmm2
xorps  %xmm5,%xmm2
mulss  %xmm5,%xmm2
mov    $0x2,%eax
movaps %xmm5,%xmm3
xchg   %ax,%ax
mulss  %xmm2,%xmm3
lea    0x1(%rax),%ecx
imul   %eax,%ecx
xorps  %xmm4,%xmm4
cvtsi2ss %ecx,%xmm4
divss  %xmm4,%xmm3
addss  %xmm3,%xmm5
add    $0x2,%eax
ucomiss %xmm0,%xmm3
jae    11d0 <ten+0x80>
ucomiss %xmm3,%xmm1
jae    11d0 <ten+0x80>
movaps %xmm5,0x10(%rsp)
call   1070 <log10@plt>
mov    %eax,%ebx
movss  0x8(%rsp),%xmm0
call   1070 <log10@plt>
mov    $0x4,%r13d
mov    $0x4,%ecx
sub    %eax,%ecx
lea    0x1(%rax),%r14d
test   %ebx,%ebx
cmovle %ecx,%r14d
movss  0x8(%rsp),%xmm0
call   1070 <log10@plt>
mov    %eax,%ebx
movss  0x8(%rsp),%xmm0
call   1070 <log10@plt>
mov    %eax,%ebp
neg    %ebp
test   %ebx,%ebx
cmovg  %eax,%ebp
add    $0x1,%ebp
movss  0x8(%rsp),%xmm0
call   1070 <log10@plt>
mov    %eax,%r15d
movss  0x8(%rsp),%xmm0
call   1070 <log10@plt>
sub    %eax,%r13d
lea    0x1(%rax),%r12d
test   %r15d,%r15d
cmovle %r13d,%r12d
movss  0x8(%rsp),%xmm0
call   1070 <log10@plt>
mov    %eax,%r15d
movss  0x8(%rsp),%xmm0
call   1070 <log10@plt>
mov    %eax,%ebx
neg    %ebx
test   %r15d,%r15d
cmovg  %eax,%ebx
add    $0x1,%ebx
movaps 0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1050 <sin@plt>
lea    0xd97(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
movsd  0x10(%rsp),%xmm0
mov    %r12d,%ecx
mov    %ebx,%r8d
mov    %eax,%r9d
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
lea    0xda9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"enter angle (float), accuracy (float): \00"
@.str.1 = [5 x i8] c"%f%f\00"
@.str.2 = [59 x i8] c"\0Acomputed sine\09\09= %+*.*f\0Acomputer generated sine\09= %+*.*f\0A\00"
@.str.3 = [35 x i8] c"\0Areturning to menu. press Enter...\00"
define void @ten() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %3)
%8 = load float, float* %2
%9 = fpext float %8 to double
%10 = fmul double %9, 0x3F91DF469D353918
%11 = fptrunc double %10 to float
store float %11, float* %2
%12 = load float, float* %2
store float %12, float* %4
store float %12, float* %5
store i32 2, i32* %1
br label %13
13: ; preds = %43, %0
%14 = load float, float* %4
%15 = load float, float* %3
%16 = fcmp oge float %14, %15
br i1 %16, label %22, label %17
17: ; preds = %13
%18 = load float, float* %4
%19 = load float, float* %3
%20 = fneg float %19
%21 = fcmp ole float %18, %20
br label %22
22: ; preds = %17, %13
%23 = phi i1 [ true, %13 ], [ %21, %17 ]
br i1 %23, label %24, label %46
24: ; preds = %22
%25 = load float, float* %2
%26 = fneg float %25
%27 = load float, float* %2
%28 = fmul float %26, %27
%29 = load float, float* %4
%30 = fmul float %28, %29
%31 = load i32, i32* %1
%32 = mul nsw i32 2, %31
%33 = sub nsw i32 %32, 1
%34 = load i32, i32* %1
%35 = mul nsw i32 2, %34
%36 = sub nsw i32 %35, 2
%37 = mul nsw i32 %33, %36
%38 = sitofp i32 %37 to float
%39 = fdiv float %30, %38
store float %39, float* %4
%40 = load float, float* %4
%41 = load float, float* %5
%42 = fadd float %41, %40
store float %42, float* %5
br label %43
43: ; preds = %24
%44 = load i32, i32* %1
%45 = add nsw i32 %44, 1
store i32 %45, i32* %1
br label %13
46: ; preds = %22
%47 = load float, float* %3
%48 = call i32 @log10(float %47)
%49 = icmp sgt i32 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %46
%51 = load float, float* %3
%52 = call i32 @log10(float %51)
%53 = add nsw i32 1, %52
br label %59
54: ; preds = %46
%55 = load float, float* %3
%56 = call i32 @log10(float %55)
%57 = sub nsw i32 1, %56
%58 = add nsw i32 %57, 3
br label %59
59: ; preds = %54, %50
%60 = phi i32 [ %53, %50 ], [ %58, %54 ]
%61 = load float, float* %3
%62 = call i32 @log10(float %61)
%63 = icmp sgt i32 %62, 0
br i1 %63, label %64, label %68
64: ; preds = %59
%65 = load float, float* %3
%66 = call i32 @log10(float %65)
%67 = add nsw i32 1, %66
br label %72
68: ; preds = %59
%69 = load float, float* %3
%70 = call i32 @log10(float %69)
%71 = sub nsw i32 1, %70
br label %72
72: ; preds = %68, %64
%73 = phi i32 [ %67, %64 ], [ %71, %68 ]
%74 = load float, float* %5
%75 = fpext float %74 to double
%76 = load float, float* %3
%77 = call i32 @log10(float %76)
%78 = icmp sgt i32 %77, 0
br i1 %78, label %79, label %83
79: ; preds = %72
%80 = load float, float* %3
%81 = call i32 @log10(float %80)
%82 = add nsw i32 1, %81
br label %88
83: ; preds = %72
%84 = load float, float* %3
%85 = call i32 @log10(float %84)
%86 = sub nsw i32 1, %85
%87 = add nsw i32 %86, 3
br label %88
88: ; preds = %83, %79
%89 = phi i32 [ %82, %79 ], [ %87, %83 ]
%90 = load float, float* %3
%91 = call i32 @log10(float %90)
%92 = icmp sgt i32 %91, 0
br i1 %92, label %93, label %97
93: ; preds = %88
%94 = load float, float* %3
%95 = call i32 @log10(float %94)
%96 = add nsw i32 1, %95
br label %101
97: ; preds = %88
%98 = load float, float* %3
%99 = call i32 @log10(float %98)
%100 = sub nsw i32 1, %99
br label %101
101: ; preds = %97, %93
%102 = phi i32 [ %96, %93 ], [ %100, %97 ]
%103 = load float, float* %2
%104 = call i32 @sin(float %103)
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), i32 %60, i32 %73, double %75, i32 %89, i32 %102, i32 %104)
%106 = call i32 (...) @getchar()
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%108 = call i32 (...) @getchar()
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"enter angle (float), accuracy (float): \00"
@.str.1 = [5 x i8] c"%f%f\00"
@.str.2 = [59 x i8] c"\0Acomputed sine\09\09= %+*.*f\0Acomputer generated sine\09= %+*.*f\0A\00"
@.str.3 = [35 x i8] c"\0Areturning to menu. press Enter...\00"
define void @ten() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float* %1, float* %2)
%7 = load float, float* %1
%8 = fpext float %7 to double
%9 = fmul double %8, 0x3F91DF469D353918
%10 = fptrunc double %9 to float
store float %10, float* %1
%11 = load float, float* %2
%12 = fneg float %11
%13 = fcmp ole float %11, %10
%14 = fcmp ole float %10, %12
%15 = or i1 %13, %14
br i1 %15, label %16, label %35
16: ; preds = %0
%17 = fneg float %10
%18 = fmul float %10, %17
br label %19
19: ; preds = %16, %19
%20 = phi float [ %10, %16 ], [ %30, %19 ]
%21 = phi float [ %10, %16 ], [ %29, %19 ]
%22 = phi i32 [ 2, %16 ], [ %31, %19 ]
%23 = fmul float %18, %21
%24 = shl nuw nsw i32 %22, 1
%25 = add nsw i32 %24, -1
%26 = add nsw i32 %24, -2
%27 = mul nsw i32 %25, %26
%28 = sitofp i32 %27 to float
%29 = fdiv float %23, %28
%30 = fadd float %20, %29
%31 = add nuw nsw i32 %22, 1
%32 = fcmp oge float %29, %11
%33 = fcmp ole float %29, %12
%34 = or i1 %32, %33
br i1 %34, label %19, label %35
35: ; preds = %19, %0
%36 = phi float [ %10, %0 ], [ %30, %19 ]
%37 = call i32 @log10(float %11)
%38 = icmp sgt i32 %37, 0
%39 = load float, float* %2
%40 = call i32 @log10(float %39)
%41 = add nsw i32 %40, 1
%42 = sub i32 4, %40
%43 = select i1 %38, i32 %41, i32 %42
%44 = load float, float* %2
%45 = call i32 @log10(float %44)
%46 = icmp sgt i32 %45, 0
%47 = load float, float* %2
%48 = call i32 @log10(float %47)
%49 = sub i32 0, %48
%50 = select i1 %46, i32 %48, i32 %49
%51 = add i32 %50, 1
%52 = load float, float* %2
%53 = call i32 @log10(float %52)
%54 = icmp sgt i32 %53, 0
%55 = load float, float* %2
%56 = call i32 @log10(float %55)
%57 = add nsw i32 %56, 1
%58 = sub i32 4, %56
%59 = select i1 %54, i32 %57, i32 %58
%60 = load float, float* %2
%61 = call i32 @log10(float %60)
%62 = icmp sgt i32 %61, 0
%63 = load float, float* %2
%64 = call i32 @log10(float %63)
%65 = sub i32 0, %64
%66 = select i1 %62, i32 %64, i32 %65
%67 = add i32 %66, 1
%68 = fpext float %36 to double
%69 = load float, float* %1
%70 = call i32 @sin(float %69)
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), i32 %43, i32 %51, double %68, i32 %59, i32 %67, i32 %70)
%72 = call i32 (...) @getchar()
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%74 = call i32 (...) @getchar()
ret void
}