#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 */
double log(int);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, double *, double *, double *);
int main() {
  double point, xpos, start, end, step, startxpos, startypos, endxpos, endypos,
      position, width;
  int ypos;
  width = 9.8;
  printf("Generate scale for spectrum chart.\n");
  printf("Enter three space separated frequencies Eg. 300e12 400e12 10e11\n");
  printf("  exa e18.\n");
  printf(" peta e15.\n");
  printf(" tera e12.\n");
  printf(" giga e9.\n");
  printf(" mega e6.\n");
  printf("  x step is 0.5 inches.\n");
  printf("  y divided into 12 steps.\n");
  printf("Ctl-c to exit.\n");
  while (scanf("%lf %lf %lf", &start, &end, &step) == 3) {
    for (point = start; point <= end; point = point + step) {
      position = log(point) / log(2);
      ypos = (int)position;
      startxpos = ((position - (double)ypos)) * width;
      startypos = (double)(ypos) / 2 + 3.05;
      endypos = (double)(ypos) / 2 + 3.075;
      printf("\\psline");
      printf("(%.3f,%.3f)", startxpos, startypos);
      printf("(%.3f,%.3f)", startxpos, endypos);
      printf("%s \tpoint=%.2f\n", "%", point);
    }
  }
  return 0;
  position = log(start) / log(2);
  ypos = (int)position;
  startxpos = ((position - (double)ypos)) * width;
  startypos = (double)(ypos) / 2 + 3.05;
  printf("\t(%.2f,%.2f)", startxpos, startypos);
  position = log(end) / log(2);
  ypos = (int)position;
  endxpos = ((position - (double)ypos)) * width;
  endypos = (double)(ypos) / 2 + 3.25;
  printf("(%.2f,%.2f)   ", endxpos, endypos);
  printf("(%.2f,", (endxpos - startxpos) / 2 + startxpos);
  printf("%.2f)\n", (endypos - startypos) / 2 + startypos);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xeb9(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf25(%rip),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1040 <scanf@plt>
cmp    $0x3,%eax
jne    1316 <main+0x1e6>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1311 <main+0x1e1>
cvttsd2si -0x10(%rbp),%edi
call   1050 <log@plt>
movsd  %xmm0,-0x70(%rbp)
mov    $0x2,%edi
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
cvttsd2si -0x58(%rbp),%eax
mov    %eax,-0x64(%rbp)
movsd  -0x58(%rbp),%xmm0
cvtsi2sdl -0x64(%rbp),%xmm1
subsd  %xmm1,%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x64(%rbp),%xmm0
movsd  0xda2(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd9e(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x64(%rbp),%xmm0
movsd  0xd80(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd6c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
lea    0xe54(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
lea    0xe3c(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
lea    0xe35(%rip),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1203 <main+0xd3>
jmp    11d8 <main+0xa8>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xefd(%rip),%rdi
call   1030 <puts@plt>
lea    0xf14(%rip),%rdi
call   1030 <puts@plt>
lea    0xf48(%rip),%rdi
call   1030 <puts@plt>
lea    0xf47(%rip),%rdi
call   1030 <puts@plt>
lea    0xf46(%rip),%rdi
call   1030 <puts@plt>
lea    0xf45(%rip),%rdi
call   1030 <puts@plt>
lea    0xf43(%rip),%rdi
call   1030 <puts@plt>
lea    0xf41(%rip),%rdi
call   1030 <puts@plt>
lea    0xf4d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf5c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe53(%rip),%rdi
lea    0x18(%rsp),%rsi
mov    %rsp,%rdx
lea    0x10(%rsp),%rcx
call   1050 <scanf@plt>
cmp    $0x3,%eax
jne    130d <main+0x1cd>
mov    %rsp,%r12
lea    0x10(%rsp),%r13
lea    0xe35(%rip),%rbx
lea    0xe36(%rip),%rbp
lea    0xe3b(%rip),%r14
lea    0xe44(%rip),%r15
jmp    1230 <main+0xf0>
xchg   %ax,%ax
lea    0xe09(%rip),%rdi
lea    0x18(%rsp),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1050 <scanf@plt>
cmp    $0x3,%eax
jne    130d <main+0x1cd>
movsd  0x18(%rsp),%xmm1
cs nopw 0x0(%rax,%rax,1)
movsd  (%rsp),%xmm0
ucomisd %xmm1,%xmm0
jb     1210 <main+0xd0>
movsd  %xmm1,0x8(%rsp)
cvttsd2si %xmm1,%edi
call   1060 <log@plt>
movapd %xmm0,0x20(%rsp)
mov    $0x2,%edi
call   1060 <log@plt>
movapd 0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
cvttpd2dq %xmm1,%xmm0
cvtdq2pd %xmm0,%xmm0
subsd  %xmm0,%xmm1
mulsd  0xd78(%rip),%xmm1
movapd %xmm1,0x20(%rsp)
mulsd  0xd72(%rip),%xmm0
movapd %xmm0,%xmm1
addsd  0xd6e(%rip),%xmm1
movsd  %xmm1,0x38(%rsp)
addsd  0xd68(%rip),%xmm0
movapd %xmm0,0x40(%rsp)
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
movaps 0x20(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
mov    %rbp,%rdi
movaps 0x20(%rsp),%xmm0
movaps 0x40(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm1
addsd  0x10(%rsp),%xmm1
jmp    1240 <main+0x100>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Generate scale for spectrum chart.\0A\00"
@.str.1 = [65 x i8] c"Enter three space separated frequencies Eg. 300e12 400e12 10e11\0A\00"
@.str.2 = [12 x i8] c" exa e18.\0A\00"
@.str.3 = [12 x i8] c" peta e15.\0A\00"
@.str.4 = [12 x i8] c" tera e12.\0A\00"
@.str.5 = [11 x i8] c" giga e9.\0A\00"
@.str.6 = [11 x i8] c" mega e6.\0A\00"
@.str.7 = [25 x i8] c" x step is 0.5 inches.\0A\00"
@.str.8 = [28 x i8] c" y divided into 12 steps.\0A\00"
@.str.9 = [16 x i8] c"Ctl-c to exit.\0A\00"
@.str.10 = [12 x i8] c"%lf %lf %lf\00"
@.str.11 = [8 x i8] c"\\psline\00"
@.str.12 = [12 x i8] c"(%.3f,%.3f)\00"
@.str.13 = [16 x i8] c"%s \09point=%.2f\0A\00"
@.str.14 = [2 x i8] c"%\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i32
store i32 0, i32* %1
store double 9.800000e+00, double* %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %24
24: ; preds = %68, %0
%25 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), double* %4, double* %5, double* %6)
%26 = icmp eq i32 %25, 3
br i1 %26, label %27, label %69
27: ; preds = %24
%28 = load double, double* %4
store double %28, double* %2
br label %29
29: ; preds = %64, %27
%30 = load double, double* %2
%31 = load double, double* %5
%32 = fcmp ole double %30, %31
br i1 %32, label %33, label %68
33: ; preds = %29
%34 = load double, double* %2
%35 = fptosi double %34 to i32
%36 = call double @log(i32 %35)
%37 = call double @log(i32 2)
%38 = fdiv double %36, %37
store double %38, double* %11
%39 = load double, double* %11
%40 = fptosi double %39 to i32
store i32 %40, i32* %13
%41 = load double, double* %11
%42 = load i32, i32* %13
%43 = sitofp i32 %42 to double
%44 = fsub double %41, %43
%45 = load double, double* %12
%46 = fmul double %44, %45
store double %46, double* %7
%47 = load i32, i32* %13
%48 = sitofp i32 %47 to double
%49 = fdiv double %48, 2.000000e+00
%50 = fadd double %49, 3.050000e+00
store double %50, double* %8
%51 = load i32, i32* %13
%52 = sitofp i32 %51 to double
%53 = fdiv double %52, 2.000000e+00
%54 = fadd double %53, 3.075000e+00
store double %54, double* %10
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
%56 = load double, double* %7
%57 = load double, double* %8
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), double %56, double %57)
%59 = load double, double* %7
%60 = load double, double* %10
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), double %59, double %60)
%62 = load double, double* %2
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0), double %62)
br label %64
64: ; preds = %33
%65 = load double, double* %2
%66 = load double, double* %6
%67 = fadd double %65, %66
store double %67, double* %2
br label %29
68: ; preds = %29
br label %24
69: ; preds = %24
ret i32 0
}

LLVM IR (-O2):
@.str.10 = [12 x i8] c"%lf %lf %lf\00"
@.str.11 = [8 x i8] c"\\psline\00"
@.str.12 = [12 x i8] c"(%.3f,%.3f)\00"
@.str.13 = [16 x i8] c"%s \09point=%.2f\0A\00"
@.str.14 = [2 x i8] c"%\00"
@str = [35 x i8] c"Generate scale for spectrum chart.\00"
@str.15 = [64 x i8] c"Enter three space separated frequencies Eg. 300e12 400e12 10e11\00"
@str.16 = [11 x i8] c" exa e18.\00"
@str.17 = [11 x i8] c" peta e15.\00"
@str.18 = [11 x i8] c" tera e12.\00"
@str.19 = [10 x i8] c" giga e9.\00"
@str.20 = [10 x i8] c" mega e6.\00"
@str.21 = [24 x i8] c" x step is 0.5 inches.\00"
@str.22 = [27 x i8] c" y divided into 12 steps.\00"
@str.23 = [15 x i8] c"Ctl-c to exit.\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.15, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.16, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.18, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.19, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.20, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.21, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.22, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.23, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), double* %1, double* %2, double* %3)
%18 = icmp eq i32 %17, 3
br i1 %18, label %22, label %47
19: ; preds = %26, %22
%20 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), double* %1, double* %2, double* %3)
%21 = icmp eq i32 %20, 3
br i1 %21, label %22, label %47
22: ; preds = %0, %19
%23 = load double, double* %1
%24 = load double, double* %2
%25 = fcmp ugt double %23, %24
br i1 %25, label %19, label %26
26: ; preds = %22, %26
%27 = phi double [ %44, %26 ], [ %23, %22 ]
%28 = fptosi double %27 to i32
%29 = call double @log(i32 %28)
%30 = call double @log(i32 2)
%31 = fdiv double %29, %30
%32 = fptosi double %31 to i32
%33 = sitofp i32 %32 to double
%34 = fsub double %31, %33
%35 = fmul double %34, 9.800000e+00
%36 = fmul double %33, 5.000000e-01
%37 = fadd double %36, 3.050000e+00
%38 = fadd double %36, 3.075000e+00
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), double %35, double %37)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), double %35, double %38)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0), double %27)
%43 = load double, double* %3
%44 = fadd double %27, %43
%45 = load double, double* %2
%46 = fcmp ugt double %44, %45
br i1 %46, label %19, label %26
47: ; preds = %19, %0
ret i32 0
}