#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 /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *, int *, float *);
int sin(double);
void four() {
  int i, j, height, width;
  float accuracy;
  printf("enter height (int), skipwidth (int), accuracy (float): ");
  scanf("%d%d%f", &height, &width, &accuracy);
  printf("\ngenerated sine curve with specified parameters:\n");
  for (i = height; i >= -height; --i) {
    for (j = 0; j <= 360; j += width)
      if ((height * sin(3.1415926 * j / 180) < i + height * accuracy) &&
          (height * sin(3.1415926 * j / 180) + height * accuracy > i))
        printf("*");
      else
        printf(" ");
    printf("\n");
  }
  getchar();
  printf("\nreturning to menu. press Enter...");
  getchar();
}


x86 assembly (clang, -O0):
<four>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
call   1060 <scanf@plt>
lea    0xedc(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
xor    %ecx,%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jl     1294 <four+0x154>
movl   $0x0,-0x8(%rbp)
cmpl   $0x168,-0x8(%rbp)
jg     127a <four+0x13a>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe53(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe3f(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <sin@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
imul   %ecx,%eax
cvtsi2ss %eax,%xmm1
cvtsi2ssl -0x4(%rbp),%xmm2
cvtsi2ssl -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm3
mulss  %xmm3,%xmm0
addss  %xmm2,%xmm0
ucomiss %xmm1,%xmm0
jbe    125b <four+0x11b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xdff(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdeb(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <sin@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
imul   %ecx,%eax
cvtsi2ss %eax,%xmm1
cvtsi2ssl -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtsi2ssl -0x4(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jbe    125b <four+0x11b>
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
jmp    1267 <four+0x127>
lea    0xde4(%rip),%rdi
call   1030 <printf@plt>
jmp    126c <four+0x12c>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1195 <four+0x55>
lea    0xdfe(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    117e <four+0x3e>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xde1(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<four>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
call   1050 <printf@plt>
lea    0xecd(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1080 <scanf@plt>
lea    0xedc(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%ebx
test   %ebx,%ebx
js     128f <four+0x12f>
mov    %ebx,%r14d
jmp    11d2 <four+0x72>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    -0x1(%r14),%eax
mov    0x8(%rsp),%ebx
mov    %ebx,%ecx
neg    %ecx
cmp    %ecx,%r14d
mov    %eax,%r14d
jle    128f <four+0x12f>
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
movss  %xmm0,0xc(%rsp)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xe01(%rip),%xmm0
divsd  0xe01(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1070 <sin@plt>
imul   %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mov    0x8(%rsp),%ebx
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
mulss  0x10(%rsp),%xmm1
addss  0xc(%rsp),%xmm1
ucomiss %xmm0,%xmm1
jbe    126c <four+0x10c>
movsd  0x18(%rsp),%xmm0
call   1070 <sin@plt>
imul   %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0x8(%rsp),%xmm1
mulss  0x10(%rsp),%xmm1
addss  %xmm0,%xmm1
mov    $0x2a,%edi
ucomiss 0xc(%rsp),%xmm1
ja     1271 <four+0x111>
mov    $0x20,%edi
call   1030 <putchar@plt>
add    0x14(%rsp),%ebp
cmp    $0x168,%ebp
jg     11b0 <four+0x50>
mov    0x8(%rsp),%ebx
jmp    11f0 <four+0x90>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    0xdb2(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"enter height (int), skipwidth (int), accuracy (float): \00"
@.str.1 = [7 x i8] c"%d%d%f\00"
@.str.2 = [50 x i8] c"\0Agenerated sine curve with specified parameters:\0A\00"
@.str.3 = [2 x i8] c"*\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [35 x i8] c"\0Areturning to menu. press Enter...\00"
define void @four() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4, float* %5)
%8 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32, i32* %3
store i32 %9, i32* %1
br label %10
10: ; preds = %62, %0
%11 = load i32, i32* %1
%12 = load i32, i32* %3
%13 = sub nsw i32 0, %12
%14 = icmp sge i32 %11, %13
br i1 %14, label %15, label %65
15: ; preds = %10
store i32 0, i32* %2
br label %16
16: ; preds = %56, %15
%17 = load i32, i32* %2
%18 = icmp sle i32 %17, 360
br i1 %18, label %19, label %60
19: ; preds = %16
%20 = load i32, i32* %3
%21 = load i32, i32* %2
%22 = sitofp i32 %21 to double
%23 = fmul double 0x400921FB4D12D84A, %22
%24 = fdiv double %23, 1.800000e+02
%25 = call i32 @sin(double %24)
%26 = mul nsw i32 %20, %25
%27 = sitofp i32 %26 to float
%28 = load i32, i32* %1
%29 = sitofp i32 %28 to float
%30 = load i32, i32* %3
%31 = sitofp i32 %30 to float
%32 = load float, float* %5
%33 = call float @llvm.fmuladd.f32(float %31, float %32, float %29)
%34 = fcmp olt float %27, %33
br i1 %34, label %35, label %53
35: ; preds = %19
%36 = load i32, i32* %3
%37 = load i32, i32* %2
%38 = sitofp i32 %37 to double
%39 = fmul double 0x400921FB4D12D84A, %38
%40 = fdiv double %39, 1.800000e+02
%41 = call i32 @sin(double %40)
%42 = mul nsw i32 %36, %41
%43 = sitofp i32 %42 to float
%44 = load i32, i32* %3
%45 = sitofp i32 %44 to float
%46 = load float, float* %5
%47 = call float @llvm.fmuladd.f32(float %45, float %46, float %43)
%48 = load i32, i32* %1
%49 = sitofp i32 %48 to float
%50 = fcmp ogt float %47, %49
br i1 %50, label %51, label %53
51: ; preds = %35
%52 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %55
53: ; preds = %35, %19
%54 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %55
55: ; preds = %53, %51
br label %56
56: ; preds = %55
%57 = load i32, i32* %4
%58 = load i32, i32* %2
%59 = add nsw i32 %58, %57
store i32 %59, i32* %2
br label %16
60: ; preds = %16
%61 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %62
62: ; preds = %60
%63 = load i32, i32* %1
%64 = add nsw i32 %63, -1
store i32 %64, i32* %1
br label %10
65: ; preds = %10
%66 = call i32 (...) @getchar()
%67 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%68 = call i32 (...) @getchar()
ret void
}

LLVM IR (-O2):
@.str = [56 x i8] c"enter height (int), skipwidth (int), accuracy (float): \00"
@.str.1 = [7 x i8] c"%d%d%f\00"
@.str.6 = [35 x i8] c"\0Areturning to menu. press Enter...\00"
@str = [49 x i8] c"\0Agenerated sine curve with specified parameters:\00"
define void @four() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, float* %3)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 0
br i1 %11, label %54, label %12
12: ; preds = %0, %48
%13 = phi i32 [ %51, %48 ], [ %10, %0 ]
%14 = phi i32 [ %50, %48 ], [ %10, %0 ]
%15 = sitofp i32 %14 to float
br label %16
16: ; preds = %46, %12
%17 = phi i32 [ %13, %12 ], [ %47, %46 ]
%18 = phi i32 [ 0, %12 ], [ %44, %46 ]
%19 = sitofp i32 %18 to double
%20 = fmul double %19, 0x400921FB4D12D84A
%21 = fdiv double %20, 1.800000e+02
%22 = call i32 @sin(double %21)
%23 = mul nsw i32 %22, %17
%24 = sitofp i32 %23 to float
%25 = load i32, i32* %1
%26 = sitofp i32 %25 to float
%27 = load float, float* %3
%28 = call float @llvm.fmuladd.f32(float %26, float %27, float %15)
%29 = fcmp ogt float %28, %24
br i1 %29, label %30, label %39
30: ; preds = %16
%31 = call i32 @sin(double %21)
%32 = mul nsw i32 %31, %25
%33 = sitofp i32 %32 to float
%34 = load i32, i32* %1
%35 = sitofp i32 %34 to float
%36 = load float, float* %3
%37 = call float @llvm.fmuladd.f32(float %35, float %36, float %33)
%38 = fcmp ogt float %37, %15
br i1 %38, label %40, label %39
39: ; preds = %30, %16
br label %40
40: ; preds = %30, %39
%41 = phi i32 [ 32, %39 ], [ 42, %30 ]
%42 = call i32 @putchar(i32 %41)
%43 = load i32, i32* %2
%44 = add nsw i32 %43, %18
%45 = icmp slt i32 %44, 361
br i1 %45, label %46, label %48
46: ; preds = %40
%47 = load i32, i32* %1
br label %16
48: ; preds = %40
%49 = call i32 @putchar(i32 10)
%50 = add nsw i32 %14, -1
%51 = load i32, i32* %1
%52 = sub nsw i32 0, %51
%53 = icmp sgt i32 %14, %52
br i1 %53, label %12, label %54
54: ; preds = %48, %0
%55 = call i32 (...) @getchar()
%56 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%57 = call i32 (...) @getchar()
ret void
}