#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 *);
int main() {
  double startvert, endvert, xpos, start, end, startxpos, startypos, endxpos,
      endypos, position, width;
  int ypos;
  width = 9.8;
  printf("Converts frequencie to X/Y positions.\n");
  printf("Enter two space separated frequencies Eg. 300e12 400e12\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", &start, &end) == 2) {
    position = log(start) / log(2);
    startvert = position / 2 + 3.0;
    ypos = (int)position;
    startxpos = ((position - (double)ypos)) * width;
    startypos = (double)(ypos) / 2 + 3.05;
    printf("\t(%.3f,%.2f)", startxpos, startypos);
    position = log(end) / log(2);
    endvert = position / 2 + 3.0;
    ypos = (int)position;
    endxpos = ((position - (double)ypos)) * width;
    endypos = (double)(ypos) / 2 + 3.25;
    printf("(%.3f,%.2f)   ", endxpos, endypos);
    printf("(%.2f,", (endxpos - startxpos) / 2 + startxpos);
    printf("%.2f)\n", (endypos - startypos) / 2 + startypos);
    printf("start_ypos= %.3f   end_ypos= %.3f\n", startvert, endvert);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeeb(%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    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <scanf@plt>
cmp    $0x2,%eax
jne    13b3 <main+0x283>
cvttsd2si -0x28(%rbp),%edi
call   1050 <log@plt>
movsd  %xmm0,-0x78(%rbp)
mov    $0x2,%edi
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  0xdd9(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xddd(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%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  0xd97(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xda3(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
lea    0xe78(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
cvttsd2si -0x30(%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)
movsd  -0x58(%rbp),%xmm0
movsd  0xd33(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd37(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%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,-0x48(%rbp)
cvtsi2sdl -0x64(%rbp),%xmm0
movsd  0xcf1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xced(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
lea    0xddf(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x48(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  0xcb2(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x38(%rbp),%xmm0
lea    0xdc5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x50(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  0xc89(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x40(%rbp),%xmm0
lea    0xda3(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xd92(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    11db <main+0xab>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xf28(%rip),%rdi
call   1030 <puts@plt>
lea    0xf42(%rip),%rdi
call   1030 <puts@plt>
lea    0xf6e(%rip),%rdi
call   1030 <puts@plt>
lea    0xf6d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf6c(%rip),%rdi
call   1030 <puts@plt>
lea    0xf6b(%rip),%rdi
call   1030 <puts@plt>
lea    0xf69(%rip),%rdi
call   1030 <puts@plt>
lea    0xf67(%rip),%rdi
call   1030 <puts@plt>
lea    0xf73(%rip),%rdi
call   1030 <puts@plt>
lea    0xf82(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5b(%rip),%rdi
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    139c <main+0x25c>
lea    0xe62(%rip),%r12
lea    0xe62(%rip),%r13
lea    0xe62(%rip),%rbx
lea    0xe29(%rip),%rbp
lea    0x8(%rsp),%r14
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
cvttsd2si 0x8(%rsp),%edi
call   1060 <log@plt>
movapd %xmm0,0x20(%rsp)
mov    $0x2,%edi
call   1060 <log@plt>
movapd 0x20(%rsp),%xmm2
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm1
movsd  0xdbf(%rip),%xmm0
mulsd  %xmm0,%xmm1
movapd %xmm0,%xmm3
movsd  0xdb7(%rip),%xmm0
addsd  %xmm0,%xmm1
movapd %xmm1,0x60(%rsp)
cvttpd2dq %xmm2,%xmm0
cvtdq2pd %xmm0,%xmm1
subsd  %xmm1,%xmm2
movsd  0xda1(%rip),%xmm0
mulsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
movapd %xmm2,0x20(%rsp)
mulsd  %xmm3,%xmm1
addsd  0xd8f(%rip),%xmm1
movapd %xmm1,0x50(%rsp)
lea    0xd9a(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
cvttsd2si (%rsp),%edi
call   1060 <log@plt>
movapd %xmm0,0x10(%rsp)
mov    $0x2,%edi
call   1060 <log@plt>
movapd 0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
movsd  0xd33(%rip),%xmm3
mulsd  %xmm3,%xmm0
addsd  0xd2f(%rip),%xmm0
movapd %xmm0,0x40(%rsp)
cvttpd2dq %xmm2,%xmm0
cvtdq2pd %xmm0,%xmm1
subsd  %xmm1,%xmm2
mulsd  0xd1d(%rip),%xmm2
movapd %xmm2,%xmm0
movapd %xmm2,0x10(%rsp)
mulsd  %xmm3,%xmm1
addsd  0xd17(%rip),%xmm1
movapd %xmm1,0x30(%rsp)
lea    0xd27(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movapd 0x20(%rsp),%xmm0
movapd 0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xccb(%rip),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movapd 0x50(%rsp),%xmm0
movapd 0x30(%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xca1(%rip),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbx,%rdi
movaps 0x60(%rsp),%xmm0
movaps 0x40(%rsp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <scanf@plt>
cmp    $0x2,%eax
je     1210 <main+0xd0>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Converts frequencie to X/Y positions.\0A\00"
@.str.1 = [57 x i8] c"Enter two space separated frequencies Eg. 300e12 400e12\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 = [8 x i8] c"%lf %lf\00"
@.str.11 = [13 x i8] c"\09(%.3f,%.2f)\00"
@.str.12 = [15 x i8] c"(%.3f,%.2f) \00"
@.str.13 = [7 x i8] c"(%.2f,\00"
@.str.14 = [7 x i8] c"%.2f)\0A\00"
@.str.15 = [35 x i8] c"start_ypos= %.3f end_ypos= %.3f\0A\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 ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 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 = %27, %0
%25 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), double* %5, double* %6)
%26 = icmp eq i32 %25, 2
br i1 %26, label %27, label %91
27: ; preds = %24
%28 = load double, double* %5
%29 = fptosi double %28 to i32
%30 = call double @log(i32 %29)
%31 = call double @log(i32 2)
%32 = fdiv double %30, %31
store double %32, double* %11
%33 = load double, double* %11
%34 = fdiv double %33, 2.000000e+00
%35 = fadd double %34, 3.000000e+00
store double %35, double* %2
%36 = load double, double* %11
%37 = fptosi double %36 to i32
store i32 %37, i32* %13
%38 = load double, double* %11
%39 = load i32, i32* %13
%40 = sitofp i32 %39 to double
%41 = fsub double %38, %40
%42 = load double, double* %12
%43 = fmul double %41, %42
store double %43, double* %7
%44 = load i32, i32* %13
%45 = sitofp i32 %44 to double
%46 = fdiv double %45, 2.000000e+00
%47 = fadd double %46, 3.050000e+00
store double %47, double* %8
%48 = load double, double* %7
%49 = load double, double* %8
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), double %48, double %49)
%51 = load double, double* %6
%52 = fptosi double %51 to i32
%53 = call double @log(i32 %52)
%54 = call double @log(i32 2)
%55 = fdiv double %53, %54
store double %55, double* %11
%56 = load double, double* %11
%57 = fdiv double %56, 2.000000e+00
%58 = fadd double %57, 3.000000e+00
store double %58, double* %3
%59 = load double, double* %11
%60 = fptosi double %59 to i32
store i32 %60, i32* %13
%61 = load double, double* %11
%62 = load i32, i32* %13
%63 = sitofp i32 %62 to double
%64 = fsub double %61, %63
%65 = load double, double* %12
%66 = fmul double %64, %65
store double %66, double* %9
%67 = load i32, i32* %13
%68 = sitofp i32 %67 to double
%69 = fdiv double %68, 2.000000e+00
%70 = fadd double %69, 3.250000e+00
store double %70, double* %10
%71 = load double, double* %9
%72 = load double, double* %10
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), double %71, double %72)
%74 = load double, double* %9
%75 = load double, double* %7
%76 = fsub double %74, %75
%77 = fdiv double %76, 2.000000e+00
%78 = load double, double* %7
%79 = fadd double %77, %78
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), double %79)
%81 = load double, double* %10
%82 = load double, double* %8
%83 = fsub double %81, %82
%84 = fdiv double %83, 2.000000e+00
%85 = load double, double* %8
%86 = fadd double %84, %85
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0), double %86)
%88 = load double, double* %2
%89 = load double, double* %3
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.15, i64 0, i64 0), double %88, double %89)
br label %24
91: ; preds = %24
ret i32 0
}

LLVM IR (-O2):
@.str.10 = [8 x i8] c"%lf %lf\00"
@.str.11 = [13 x i8] c"\09(%.3f,%.2f)\00"
@.str.12 = [15 x i8] c"(%.3f,%.2f) \00"
@.str.13 = [7 x i8] c"(%.2f,\00"
@.str.14 = [7 x i8] c"%.2f)\0A\00"
@.str.15 = [35 x i8] c"start_ypos= %.3f end_ypos= %.3f\0A\00"
@str = [38 x i8] c"Converts frequencie to X/Y positions.\00"
@str.16 = [56 x i8] c"Enter two space separated frequencies Eg. 300e12 400e12\00"
@str.17 = [11 x i8] c" exa e18.\00"
@str.18 = [11 x i8] c" peta e15.\00"
@str.19 = [11 x i8] c" tera e12.\00"
@str.20 = [10 x i8] c" giga e9.\00"
@str.21 = [10 x i8] c" mega e6.\00"
@str.22 = [24 x i8] c" x step is 0.5 inches.\00"
@str.23 = [27 x i8] c" y divided into 12 steps.\00"
@str.24 = [15 x i8] c"Ctl-c to exit.\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.16, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.18, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.19, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.20, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.21, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.22, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.23, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.24, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), double* %1, double* %2)
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %57
17: ; preds = %0, %17
%18 = load double, double* %1
%19 = fptosi double %18 to i32
%20 = call double @log(i32 %19)
%21 = call double @log(i32 2)
%22 = fdiv double %20, %21
%23 = fmul double %22, 5.000000e-01
%24 = fadd double %23, 3.000000e+00
%25 = fptosi double %22 to i32
%26 = sitofp i32 %25 to double
%27 = fsub double %22, %26
%28 = fmul double %27, 9.800000e+00
%29 = fmul double %26, 5.000000e-01
%30 = fadd double %29, 3.050000e+00
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), double %28, double %30)
%32 = load double, double* %2
%33 = fptosi double %32 to i32
%34 = call double @log(i32 %33)
%35 = call double @log(i32 2)
%36 = fdiv double %34, %35
%37 = fmul double %36, 5.000000e-01
%38 = fadd double %37, 3.000000e+00
%39 = fptosi double %36 to i32
%40 = sitofp i32 %39 to double
%41 = fsub double %36, %40
%42 = fmul double %41, 9.800000e+00
%43 = fmul double %40, 5.000000e-01
%44 = fadd double %43, 3.250000e+00
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), double %42, double %44)
%46 = fsub double %42, %28
%47 = fmul double %46, 5.000000e-01
%48 = fadd double %28, %47
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), double %48)
%50 = fsub double %44, %30
%51 = fmul double %50, 5.000000e-01
%52 = fadd double %30, %51
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0), double %52)
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.15, i64 0, i64 0), double %24, double %38)
%55 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), double* %1, double* %2)
%56 = icmp eq i32 %55, 2
br i1 %56, label %17, label %57
57: ; preds = %17, %0
ret i32 0
}