#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 EINVAL;
double INFINITY;
int M_PI;
int /*<<< orphan*/ abort();
int errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ handle_bad_opts();
char *optarg;
scalar_t__ opterr;
int /*<<< orphan*/ perror(char *);
unsigned int pow(float, int);
int /*<<< orphan*/ print_help(char *);
int serial_open(char *);
scalar_t__ serial_read_line(int, char *, int);
int sscanf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  bool pierce = false;
  double capacitance = 22e-9;
  double offset = 0.00f;
  char *device = "/dev/ttyACM0";
  int c;
  opterr = 0;
  while ((c = getopt(argc, argv, "c:d:ho:p")) != -1) {
    switch (c) {
    case 'c': {
      unsigned param = 0;
      int cnt, exp;
      cnt = sscanf(optarg, "%u", &param);
      if ((cnt != 1) || (param < 10)) {
        print_help(argv[0]);
        return -EINVAL;
      }
      exp = param % 10;
      param /= 10;
      capacitance = param * pow(10.0f, exp);
      capacitance /= 1e12;
      break;
    }
    case 'd': {
      device = optarg;
      break;
    }
    case 'h': {
      print_help(argv[0]);
      return 0;
      break;
    }
    case 'o': {
      unsigned param = 0;
      int cnt, exp;
      cnt = sscanf(optarg, "%u", &param);
      if ((cnt != 1) || (param < 10)) {
        print_help(argv[0]);
        return -EINVAL;
      }
      exp = param % 10;
      param /= 10;
      offset = param * pow(10.0f, exp);
      offset /= 1e9;
      break;
    }
    case 'p': {
      pierce = true;
      break;
    }
    case '?': {
      handle_bad_opts();
      print_help(argv[0]);
      return -EINVAL;
    }
    default: {
      fprintf(stderr, "BUG: switch fall-through on `%c'!\n", c);
      abort();
    }
    }
  }
  fprintf(stdout,
          "Device: %s\nCapacitance: %.3lf nF\nPierce/Colpitts: %s\nOffset: "
          "%.3lf uH\n\n",
          device, capacitance * 1e9, pierce ? "yes" : "no", offset * 1e6);
  if (pierce) {
    capacitance /= 2;
  }
  int serial_fd = -1;
  serial_fd = serial_open(device);
  if (serial_fd < 0) {
    perror("ERROR: cannot open serial port");
    return errno;
  }
  char buf[512];
  double freq, ind;
  char dot;
  while (true) {
    if (0 != serial_read_line(serial_fd, buf, 512)) {
      fprintf(stderr, "ERROR: cannot read from serial port!\n");
      return -1;
    }
    if (2 != sscanf(buf, "%lf MHz %c", &freq, &dot)) {
      fprintf(stderr, "ERROR: cannot parse frequency from line `%s'!\n", buf);
      return -1;
    }
    if (freq < 0.0f) {
      fprintf(stderr, "ERROR: invalid frequency `%lf'!\n", freq);
      return -1;
    }
    if ('.' != dot) {
      dot = ' ';
    }
    freq *= 1e6;
    if (0.0f == freq) {
      fprintf(stdout, "%15.3lf uH %c (%9.0lf Hz)\r", 0.0f, dot, freq);
    } else {
      ind = (1.0f / (4 * M_PI * M_PI)) / (freq * freq) / capacitance;
      if (ind > 10) {
        ind = INFINITY;
      }
      ind -= offset;
      fprintf(stdout, "%15.3lf uH %c (%9.0lf Hz)\r", ind * 1e6, dot, freq);
    }
    fflush(stdout);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x280,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movsd  0xe28(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
lea    0xf14(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2dc1(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf01(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     1473 <main+0x2c3>
mov    -0x34(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x270(%rbp)
sub    $0x31,%eax
ja     144d <main+0x29d>
mov    -0x270(%rbp),%rax
lea    0xdf5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x38(%rbp)
mov    0x2d9e(%rip),%rax
mov    (%rax),%rdi
lea    0xeb2(%rip),%rsi
lea    -0x38(%rbp),%rdx
mov    $0x0,%al
call   1090 <sscanf@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x1,-0x3c(%rbp)
jne    1286 <main+0xd6>
cmpl   $0xa,-0x38(%rbp)
jae    12a5 <main+0xf5>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <print_help@plt>
xor    %eax,%eax
mov    0x2d15(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    174e <main+0x59e>
mov    -0x38(%rbp),%eax
mov    %eax,%edx
mov    %edx,%eax
mov    $0xcccccccd,%ecx
imul   %rcx,%rdx
shr    $0x23,%rdx
mov    %edx,%esi
add    %esi,%esi
mov    %esi,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%eax
mov    %eax,-0x40(%rbp)
mov    -0x38(%rbp),%eax
imul   %rcx,%rax
shr    $0x23,%rax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x274(%rbp)
mov    -0x40(%rbp),%edi
movss  0xd4b(%rip),%xmm0
call   10a0 <pow@plt>
mov    %eax,%ecx
mov    -0x274(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xd18(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    146e <main+0x2be>
mov    0x2cd3(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    146e <main+0x2be>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <print_help@plt>
movl   $0x0,-0x4(%rbp)
jmp    174e <main+0x59e>
movl   $0x0,-0x44(%rbp)
mov    0x2ca1(%rip),%rax
mov    (%rax),%rdi
lea    0xdb5(%rip),%rsi
lea    -0x44(%rbp),%rdx
mov    $0x0,%al
call   1090 <sscanf@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x1,-0x48(%rbp)
jne    1383 <main+0x1d3>
cmpl   $0xa,-0x44(%rbp)
jae    13a2 <main+0x1f2>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <print_help@plt>
xor    %eax,%eax
mov    0x2c18(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    174e <main+0x59e>
mov    -0x44(%rbp),%eax
mov    %eax,%edx
mov    %edx,%eax
mov    $0xcccccccd,%ecx
imul   %rcx,%rdx
shr    $0x23,%rdx
mov    %edx,%esi
add    %esi,%esi
mov    %esi,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x44(%rbp),%eax
imul   %rcx,%rax
shr    $0x23,%rax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x278(%rbp)
mov    -0x4c(%rbp),%edi
movss  0xc4e(%rip),%xmm0
call   10a0 <pow@plt>
mov    %eax,%ecx
mov    -0x278(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xc03(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    146e <main+0x2be>
movl   $0x1,-0x14(%rbp)
jmp    146e <main+0x2be>
mov    $0x0,%al
call   1040 <handle_bad_opts@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <print_help@plt>
xor    %eax,%eax
mov    0x2b6d(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    174e <main+0x59e>
mov    0x2b74(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
lea    0xcb9(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    11fe <main+0x4e>
mov    0x2b2e(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rdx
movsd  0xb88(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x14(%rbp),%esi
lea    0xcf1(%rip),%rcx
lea    0xce6(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
movsd  0xb5b(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
lea    0xc83(%rip),%rsi
mov    $0x2,%al
call   1050 <fprintf@plt>
cmpl   $0x0,-0x14(%rbp)
je     14e0 <main+0x330>
movsd  -0x20(%rbp),%xmm0
movsd  0xb41(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0xffffffff,-0x50(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <serial_open@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
jge    151a <main+0x36a>
lea    0xc87(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2ab0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    174e <main+0x59e>
jmp    151f <main+0x36f>
mov    -0x50(%rbp),%edi
lea    -0x250(%rbp),%rsi
mov    $0x200,%edx
call   1070 <serial_read_line@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1564 <main+0x3b4>
mov    0x2a80(%rip),%rax
mov    (%rax),%edi
lea    0xc59(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    174e <main+0x59e>
lea    -0x250(%rbp),%rdi
lea    0xc5e(%rip),%rsi
lea    -0x258(%rbp),%rdx
lea    -0x261(%rbp),%rcx
mov    $0x0,%al
call   1090 <sscanf@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    %ecx,%eax
je     15c0 <main+0x410>
mov    0x2a2b(%rip),%rax
mov    (%rax),%edi
lea    -0x250(%rbp),%rdx
lea    0xc2e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    174e <main+0x59e>
xorps  %xmm0,%xmm0
ucomisd -0x258(%rbp),%xmm0
ff
jbe    15fc <main+0x44c>
mov    0x29f0(%rip),%rax
mov    (%rax),%edi
movsd  -0x258(%rbp),%xmm0
ff
lea    0xc21(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    174e <main+0x59e>
movsbl -0x261(%rbp),%ecx
mov    $0x2e,%eax
cmp    %ecx,%eax
je     1617 <main+0x467>
movb   $0x20,-0x261(%rbp)
movsd  0x9e9(%rip),%xmm0
mulsd  -0x258(%rbp),%xmm0
ff
movsd  %xmm0,-0x258(%rbp)
ff
xorps  %xmm0,%xmm0
ucomisd -0x258(%rbp),%xmm0
ff
jne    1674 <main+0x4c4>
jp     1674 <main+0x4c4>
mov    0x295b(%rip),%rax
mov    (%rax),%edi
movsbl -0x261(%rbp),%edx
movsd  -0x258(%rbp),%xmm1
ff
lea    0xbc6(%rip),%rsi
xorps  %xmm0,%xmm0
mov    $0x2,%al
call   1050 <fprintf@plt>
jmp    173b <main+0x58b>
mov    0x295d(%rip),%rax
mov    (%rax),%eax
shl    $0x2,%eax
mov    0x2951(%rip),%rcx
imul   (%rcx),%eax
cvtsi2ss %eax,%xmm1
movss  0x99a(%rip),%xmm0
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  -0x258(%rbp),%xmm1
ff
mulsd  -0x258(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x260(%rbp)
ff
movsd  -0x260(%rbp),%xmm0
ff
movsd  0x951(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    16ec <main+0x53c>
mov    0x2900(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x260(%rbp)
ff
movsd  -0x28(%rbp),%xmm1
movsd  -0x260(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x260(%rbp)
ff
mov    0x289c(%rip),%rax
mov    (%rax),%edi
movsd  0x8f2(%rip),%xmm0
mulsd  -0x260(%rbp),%xmm0
ff
movsbl -0x261(%rbp),%edx
movsd  -0x258(%rbp),%xmm1
ff
lea    0xaf7(%rip),%rsi
mov    $0x2,%al
call   1050 <fprintf@plt>
mov    0x2866(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
jmp    151f <main+0x36f>
mov    -0x4(%rbp),%eax
add    $0x280,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x228,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2deb(%rip),%rax
movq   $0x0,(%rax)
movsd  0xe24(%rip),%xmm0
xorpd  %xmm1,%xmm1
movsd  %xmm1,0x10(%rsp)
lea    0xf17(%rip),%r14
lea    0xf1d(%rip),%r15
lea    0xe45(%rip),%r13
xor    %r12d,%r12d
movsd  %xmm0,0x8(%rsp)
mov    %r12d,%ecx
nopw   0x0(%rax,%rax,1)
mov    %ecx,%r12d
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   10c0 <getopt@plt>
mov    $0x1,%ecx
cmp    $0x70,%eax
je     1210 <main+0x60>
lea    -0x3f(%rax),%ecx
cmp    $0x30,%ecx
ja     1379 <main+0x1c9>
movslq 0x0(%r13,%rcx,4),%rcx
add    %r13,%rcx
jmp    *%rcx
movl   $0x0,0x20(%rsp)
mov    0x2da9(%rip),%rax
mov    (%rax),%rdi
lea    0xec1(%rip),%rsi
lea    0x20(%rsp),%rdx
xor    %eax,%eax
call   1090 <sscanf@plt>
cmp    $0x1,%eax
jne    15cb <main+0x41b>
mov    0x20(%rsp),%edi
cmp    $0x9,%edi
jbe    15cb <main+0x41b>
mov    %r14,%r13
mov    %edi,%r14d
mov    $0xcccccccd,%eax
imul   %rax,%r14
shr    $0x23,%r14
lea    (%r14,%r14,1),%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
mov    %r14d,0x20(%rsp)
movss  0xd94(%rip),%xmm0
call   10a0 <pow@plt>
imul   %r14d,%eax
mov    %r13,%r14
lea    0xd89(%rip),%r13
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  0xd49(%rip),%xmm0
jmp    11fe <main+0x4e>
mov    0x2d25(%rip),%rax
mov    (%rax),%r14
movsd  0x8(%rsp),%xmm0
jmp    11fe <main+0x4e>
movl   $0x0,0x20(%rsp)
mov    0x2d08(%rip),%rax
mov    (%rax),%rdi
lea    0xe20(%rip),%rsi
lea    0x20(%rsp),%rdx
xor    %eax,%eax
call   1090 <sscanf@plt>
cmp    $0x1,%eax
jne    15cb <main+0x41b>
mov    0x20(%rsp),%edi
cmp    $0x9,%edi
jbe    15cb <main+0x41b>
mov    %r14,%r13
mov    %edi,%r14d
mov    $0xcccccccd,%eax
imul   %rax,%r14
shr    $0x23,%r14
lea    (%r14,%r14,1),%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
mov    %r14d,0x20(%rsp)
movss  0xcf3(%rip),%xmm0
call   10a0 <pow@plt>
imul   %r14d,%eax
mov    %r13,%r14
lea    0xce8(%rip),%r13
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  0xca0(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
jmp    11fe <main+0x4e>
cmp    $0xffffffff,%eax
jne    15fd <main+0x44d>
mov    0x2c1f(%rip),%r13
mov    0x0(%r13),%edi
movsd  0xc73(%rip),%xmm0
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm0
lea    0xde6(%rip),%rax
lea    0xddb(%rip),%rcx
movsd  0xc63(%rip),%xmm1
mulsd  0x10(%rsp),%xmm1
lea    0xd7e(%rip),%rsi
test   %r12d,%r12d
cmove  %rax,%rcx
je     13d9 <main+0x229>
mulsd  0xc4d(%rip),%xmm2
movsd  %xmm2,0x8(%rsp)
mov    %r14,%rdx
mov    $0x2,%al
call   1050 <fprintf@plt>
mov    %r14,%rdi
call   1060 <serial_open@plt>
test   %eax,%eax
js     15e3 <main+0x433>
mov    %eax,%ebx
lea    0x20(%rsp),%rsi
mov    %eax,%edi
mov    $0x200,%edx
call   1070 <serial_read_line@plt>
test   %rax,%rax
je     1463 <main+0x2b3>
mov    0x2bb6(%rip),%rax
mov    (%rax),%edi
lea    0xd93(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    144f <main+0x29f>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <handle_bad_opts@plt>
mov    (%rbx),%rdi
call   10d0 <print_help@plt>
mov    0x2b6f(%rip),%rax
sub    (%rax),%ebp
jmp    144f <main+0x29f>
mov    (%rbx),%rdi
call   10d0 <print_help@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x228,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd6a(%rip),%r14
lea    0x20(%rsp),%rbp
lea    0x18(%rsp),%r15
lea    0x7(%rsp),%r12
jmp    1519 <main+0x369>
xchg   %ax,%ax
mov    0x2b51(%rip),%rax
mov    (%rax),%eax
imul   %eax,%eax
shl    $0x2,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0xb9e(%rip),%xmm2
divss  %xmm0,%xmm2
cvtss2sd %xmm2,%xmm2
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
divsd  %xmm0,%xmm2
divsd  0x8(%rsp),%xmm2
movsd  0xb68(%rip),%xmm3
cmpltsd %xmm2,%xmm3
mov    0x2b14(%rip),%rax
movsd  (%rax),%xmm0
andpd  %xmm3,%xmm0
andnpd %xmm2,%xmm3
orpd   %xmm3,%xmm0
subsd  0x10(%rsp),%xmm0
mov    0x0(%r13),%edi
mulsd  %xmm4,%xmm0
lea    0xd3e(%rip),%rsi
mov    $0x2,%al
call   1050 <fprintf@plt>
mov    0x0(%r13),%edi
call   1080 <fflush@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x200,%edx
call   1070 <serial_read_line@plt>
test   %rax,%rax
jne    140b <main+0x25b>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1090 <sscanf@plt>
cmp    $0x2,%eax
jne    158a <main+0x3da>
movsd  0x18(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
ja     15ab <main+0x3fb>
mov    $0x2e,%edx
cmpb   $0x2e,0x7(%rsp)
je     1557 <main+0x3a7>
movb   $0x20,0x7(%rsp)
mov    $0x20,%edx
movsd  0xab9(%rip),%xmm4
mulsd  %xmm4,%xmm1
movsd  %xmm1,0x18(%rsp)
ucomisd 0xabf(%rip),%xmm1
jne    1480 <main+0x2d0>
jp     1480 <main+0x2d0>
mov    0x0(%r13),%edi
xorpd  %xmm0,%xmm0
jmp    14ea <main+0x33a>
mov    0x2a37(%rip),%rax
mov    (%rax),%edi
lea    0xc45(%rip),%rsi
lea    0x20(%rsp),%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1422 <main+0x272>
mov    0x2a16(%rip),%rax
mov    (%rax),%edi
lea    0xc53(%rip),%rsi
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1050 <fprintf@plt>
jmp    1422 <main+0x272>
mov    (%rbx),%rdi
call   10d0 <print_help@plt>
mov    0x29d6(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
jmp    144f <main+0x29f>
lea    0xba5(%rip),%rdi
call   10b0 <perror@plt>
mov    0x29ca(%rip),%rax
mov    (%rax),%ebp
jmp    144f <main+0x29f>
mov    0x29c4(%rip),%rcx
mov    (%rcx),%edi
lea    0xb10(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/ttyACM0\00"
@opterr = global i64 0
@.str.1 = [9 x i8] c"c:d:ho:p\00"
@optarg = global i8* null
@.str.2 = [3 x i8] c"%u\00"
@EINVAL = global i32 0
@stderr = global i32 0
@.str.3 = [35 x i8] c"BUG: switch fall-through on `%c'!\0A\00"
@stdout = global i32 0
@.str.4 = [72 x i8] c"Device: %s\0ACapacitance: %.3lf nF\0APierce/Colpitts: %s\0AOffset: %.3lf uH\0A\0A\00"
@.str.5 = [4 x i8] c"yes\00"
@.str.6 = [3 x i8] c"no\00"
@.str.7 = [31 x i8] c"ERROR: cannot open serial port\00"
@errno = global i32 0
@.str.8 = [38 x i8] c"ERROR: cannot read from serial port!\0A\00"
@.str.9 = [11 x i8] c"%lf MHz %c\00"
@.str.10 = [47 x i8] c"ERROR: cannot parse frequency from line `%s'!\0A\00"
@.str.11 = [33 x i8] c"ERROR: invalid frequency `%lf'!\0A\00"
@.str.12 = [27 x i8] c"%15.3lf uH %c (%9.0lf Hz)\0D\00"
@M_PI = global i32 0
@INFINITY = global double 0.000000e+00
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [512 x i8]
%19 = alloca double
%20 = alloca double
%21 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store double 2.200000e-08, double* %7
store double 0.000000e+00, double* %8
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %9
store i64 0, i64* @opterr
br label %22
22: ; preds = %104, %2
%23 = load i32, i32* %4
%24 = load i8**, i8*** %5
%25 = call i32 @getopt(i32 %23, i8** %24, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i32 %25, i32* %10
%26 = icmp ne i32 %25, -1
br i1 %26, label %27, label %105
27: ; preds = %22
%28 = load i32, i32* %10
switch i32 %28, label %99 [
i32 99, label %29
i32 100, label %56
i32 104, label %58
i32 111, label %63
i32 112, label %90
i32 63, label %91
]
29: ; preds = %27
store i32 0, i32* %11
%30 = load i8*, i8** @optarg
%31 = call i32 (i8*, i8*, ...) @sscanf(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %11)
store i32 %31, i32* %12
%32 = load i32, i32* %12
%33 = icmp ne i32 %32, 1
br i1 %33, label %37, label %34
34: ; preds = %29
%35 = load i32, i32* %11
%36 = icmp ult i32 %35, 10
br i1 %36, label %37, label %44
37: ; preds = %34, %29
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 @print_help(i8* %40)
%42 = load i32, i32* @EINVAL
%43 = sub nsw i32 0, %42
store i32 %43, i32* %3
br label %202
44: ; preds = %34
%45 = load i32, i32* %11
%46 = urem i32 %45, 10
store i32 %46, i32* %13
%47 = load i32, i32* %11
%48 = udiv i32 %47, 10
store i32 %48, i32* %11
%49 = load i32, i32* %11
%50 = load i32, i32* %13
%51 = call i32 @pow(float 1.000000e+01, i32 %50)
%52 = mul i32 %49, %51
%53 = uitofp i32 %52 to double
store double %53, double* %7
%54 = load double, double* %7
%55 = fdiv double %54, 1.000000e+12
store double %55, double* %7
br label %104
56: ; preds = %27
%57 = load i8*, i8** @optarg
store i8* %57, i8** %9
br label %104
58: ; preds = %27
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 0
%61 = load i8*, i8** %60
%62 = call i32 @print_help(i8* %61)
store i32 0, i32* %3
br label %202
63: ; preds = %27
store i32 0, i32* %14
%64 = load i8*, i8** @optarg
%65 = call i32 (i8*, i8*, ...) @sscanf(i8* %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %14)
store i32 %65, i32* %15
%66 = load i32, i32* %15
%67 = icmp ne i32 %66, 1
br i1 %67, label %71, label %68
68: ; preds = %63
%69 = load i32, i32* %14
%70 = icmp ult i32 %69, 10
br i1 %70, label %71, label %78
71: ; preds = %68, %63
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 0
%74 = load i8*, i8** %73
%75 = call i32 @print_help(i8* %74)
%76 = load i32, i32* @EINVAL
%77 = sub nsw i32 0, %76
store i32 %77, i32* %3
br label %202
78: ; preds = %68
%79 = load i32, i32* %14
%80 = urem i32 %79, 10
store i32 %80, i32* %16
%81 = load i32, i32* %14
%82 = udiv i32 %81, 10
store i32 %82, i32* %14
%83 = load i32, i32* %14
%84 = load i32, i32* %16
%85 = call i32 @pow(float 1.000000e+01, i32 %84)
%86 = mul i32 %83, %85
%87 = uitofp i32 %86 to double
store double %87, double* %8
%88 = load double, double* %8
%89 = fdiv double %88, 1.000000e+09
store double %89, double* %8
br label %104
90: ; preds = %27
store i32 1, i32* %6
br label %104
91: ; preds = %27
%92 = call i32 (...) @handle_bad_opts()
%93 = load i8**, i8*** %5
%94 = getelementptr inbounds i8*, i8** %93, i64 0
%95 = load i8*, i8** %94
%96 = call i32 @print_help(i8* %95)
%97 = load i32, i32* @EINVAL
%98 = sub nsw i32 0, %97
store i32 %98, i32* %3
br label %202
99: ; preds = %27
%100 = load i32, i32* @stderr
%101 = load i32, i32* %10
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %101)
%103 = call i32 (...) @abort()
unreachable
104: ; preds = %90, %78, %56, %44
br label %22
105: ; preds = %22
%106 = load i32, i32* @stdout
%107 = load i8*, i8** %9
%108 = load double, double* %7
%109 = fmul double %108, 1.000000e+09
%110 = load i32, i32* %6
%111 = icmp ne i32 %110, 0
%112 = zext i1 %111 to i64
%113 = select i1 %111, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0)
%114 = load double, double* %8
%115 = fmul double %114, 1.000000e+06
%116 = call i32 (i32, i8*, ...) @fprintf(i32 %106, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.4, i64 0, i64 0), i8* %107, double %109, i8* %113, double %115)
%117 = load i32, i32* %6
%118 = icmp ne i32 %117, 0
br i1 %118, label %119, label %122
119: ; preds = %105
%120 = load double, double* %7
%121 = fdiv double %120, 2.000000e+00
store double %121, double* %7
br label %122
122: ; preds = %119, %105
store i32 -1, i32* %17
%123 = load i8*, i8** %9
%124 = call i32 @serial_open(i8* %123)
store i32 %124, i32* %17
%125 = load i32, i32* %17
%126 = icmp slt i32 %125, 0
br i1 %126, label %127, label %130
127: ; preds = %122
%128 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%129 = load i32, i32* @errno
store i32 %129, i32* %3
br label %202
130: ; preds = %122
br label %131
131: ; preds = %130, %199
%132 = load i32, i32* %17
%133 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
%134 = call i64 @serial_read_line(i32 %132, i8* %133, i32 512)
%135 = icmp ne i64 0, %134
br i1 %135, label %136, label %139
136: ; preds = %131
%137 = load i32, i32* @stderr
%138 = call i32 (i32, i8*, ...) @fprintf(i32 %137, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %3
br label %202
139: ; preds = %131
%140 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
%141 = call i32 (i8*, i8*, ...) @sscanf(i8* %140, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), double* %19, i8* %21)
%142 = icmp ne i32 2, %141
br i1 %142, label %143, label %147
143: ; preds = %139
%144 = load i32, i32* @stderr
%145 = getelementptr inbounds [512 x i8], [512 x i8]* %18, i64 0, i64 0
%146 = call i32 (i32, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.10, i64 0, i64 0), i8* %145)
store i32 -1, i32* %3
br label %202
147: ; preds = %139
%148 = load double, double* %19
%149 = fcmp olt double %148, 0.000000e+00
br i1 %149, label %150, label %154
150: ; preds = %147
%151 = load i32, i32* @stderr
%152 = load double, double* %19
%153 = call i32 (i32, i8*, ...) @fprintf(i32 %151, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), double %152)
store i32 -1, i32* %3
br label %202
154: ; preds = %147
%155 = load i8, i8* %21
%156 = sext i8 %155 to i32
%157 = icmp ne i32 46, %156
br i1 %157, label %158, label %159
158: ; preds = %154
store i8 32, i8* %21
br label %159
159: ; preds = %158, %154
%160 = load double, double* %19
%161 = fmul double %160, 1.000000e+06
store double %161, double* %19
%162 = load double, double* %19
%163 = fcmp oeq double 0.000000e+00, %162
br i1 %163, label %164, label %170
164: ; preds = %159
%165 = load i32, i32* @stdout
%166 = load i8, i8* %21
%167 = sext i8 %166 to i32
%168 = load double, double* %19
%169 = call i32 (i32, i8*, ...) @fprintf(i32 %165, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), double 0.000000e+00, i32 %167, double %168)
br label %199
170: ; preds = %159
%171 = load i32, i32* @M_PI
%172 = mul nsw i32 4, %171
%173 = load i32, i32* @M_PI
%174 = mul nsw i32 %172, %173
%175 = sitofp i32 %174 to float
%176 = fdiv float 1.000000e+00, %175
%177 = fpext float %176 to double
%178 = load double, double* %19
%179 = load double, double* %19
%180 = fmul double %178, %179
%181 = fdiv double %177, %180
%182 = load double, double* %7
%183 = fdiv double %181, %182
store double %183, double* %20
%184 = load double, double* %20
%185 = fcmp ogt double %184, 1.000000e+01
br i1 %185, label %186, label %188
186: ; preds = %170
%187 = load double, double* @INFINITY
store double %187, double* %20
br label %188
188: ; preds = %186, %170
%189 = load double, double* %8
%190 = load double, double* %20
%191 = fsub double %190, %189
store double %191, double* %20
%192 = load i32, i32* @stdout
%193 = load double, double* %20
%194 = fmul double %193, 1.000000e+06
%195 = load i8, i8* %21
%196 = sext i8 %195 to i32
%197 = load double, double* %19
%198 = call i32 (i32, i8*, ...) @fprintf(i32 %192, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), double %194, i32 %196, double %197)
br label %199
199: ; preds = %188, %164
%200 = load i32, i32* @stdout
%201 = call i32 @fflush(i32 %200)
br label %131
202: ; preds = %150, %143, %136, %127, %91, %71, %58, %37
%203 = load i32, i32* %3
ret i32 %203
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/ttyACM0\00"
@opterr = global i64 0
@.str.1 = [9 x i8] c"c:d:ho:p\00"
@optarg = global i8* null
@.str.2 = [3 x i8] c"%u\00"
@EINVAL = global i32 0
@stderr = global i32 0
@.str.3 = [35 x i8] c"BUG: switch fall-through on `%c'!\0A\00"
@stdout = global i32 0
@.str.4 = [72 x i8] c"Device: %s\0ACapacitance: %.3lf nF\0APierce/Colpitts: %s\0AOffset: %.3lf uH\0A\0A\00"
@.str.5 = [4 x i8] c"yes\00"
@.str.6 = [3 x i8] c"no\00"
@.str.7 = [31 x i8] c"ERROR: cannot open serial port\00"
@errno = global i32 0
@.str.8 = [38 x i8] c"ERROR: cannot read from serial port!\0A\00"
@.str.9 = [11 x i8] c"%lf MHz %c\00"
@.str.10 = [47 x i8] c"ERROR: cannot parse frequency from line `%s'!\0A\00"
@.str.11 = [33 x i8] c"ERROR: invalid frequency `%lf'!\0A\00"
@.str.12 = [27 x i8] c"%15.3lf uH %c (%9.0lf Hz)\0D\00"
@M_PI = global i32 0
@INFINITY = global double 0.000000e+00
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [512 x i8]
%6 = alloca double
%7 = alloca i8
store i64 0, i64* @opterr
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %3 to i8*
br label %10
10: ; preds = %44, %2
%11 = phi i8* [ %45, %44 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %2 ]
%12 = phi double [ %16, %44 ], [ 0.000000e+00, %2 ]
%13 = phi double [ %20, %44 ], [ 2.200000e-08, %2 ]
%14 = phi i32 [ %23, %44 ], [ 0, %2 ]
br label %15
15: ; preds = %10, %61
%16 = phi double [ %12, %10 ], [ %67, %61 ]
%17 = phi double [ %13, %10 ], [ %20, %61 ]
%18 = phi i32 [ %14, %10 ], [ %23, %61 ]
br label %19
19: ; preds = %15, %37
%20 = phi double [ %17, %15 ], [ %43, %37 ]
%21 = phi i32 [ %18, %15 ], [ %23, %37 ]
br label %22
22: ; preds = %19, %22
%23 = phi i32 [ 1, %22 ], [ %21, %19 ]
%24 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
switch i32 %24, label %74 [
i32 -1, label %78
i32 99, label %25
i32 100, label %44
i32 104, label %46
i32 111, label %49
i32 112, label %22
i32 63, label %68
]
25: ; preds = %22
store i32 0, i32* %3
%26 = load i8*, i8** @optarg
%27 = call i32 (i8*, i8*, ...) @sscanf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%28 = icmp ne i32 %27, 1
%29 = load i32, i32* %3
%30 = icmp ult i32 %29, 10
%31 = select i1 %28, i1 true, i1 %30
br i1 %31, label %32, label %37
32: ; preds = %25
%33 = load i8*, i8** %1
%34 = call i32 @print_help(i8* %33)
%35 = load i32, i32* @EINVAL
%36 = sub nsw i32 0, %35
br label %146
37: ; preds = %25
%38 = urem i32 %29, 10
%39 = udiv i32 %29, 10
store i32 %39, i32* %3
%40 = call i32 @pow(float 1.000000e+01, i32 %38)
%41 = mul i32 %40, %39
%42 = uitofp i32 %41 to double
%43 = fdiv double %42, 1.000000e+12
br label %19
44: ; preds = %22
%45 = load i8*, i8** @optarg
br label %10
46: ; preds = %22
%47 = load i8*, i8** %1
%48 = call i32 @print_help(i8* %47)
br label %146
49: ; preds = %22
store i32 0, i32* %4
%50 = load i8*, i8** @optarg
%51 = call i32 (i8*, i8*, ...) @sscanf(i8* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%52 = icmp ne i32 %51, 1
%53 = load i32, i32* %4
%54 = icmp ult i32 %53, 10
%55 = select i1 %52, i1 true, i1 %54
br i1 %55, label %56, label %61
56: ; preds = %49
%57 = load i8*, i8** %1
%58 = call i32 @print_help(i8* %57)
%59 = load i32, i32* @EINVAL
%60 = sub nsw i32 0, %59
br label %146
61: ; preds = %49
%62 = urem i32 %53, 10
%63 = udiv i32 %53, 10
store i32 %63, i32* %4
%64 = call i32 @pow(float 1.000000e+01, i32 %62)
%65 = mul i32 %64, %63
%66 = uitofp i32 %65 to double
%67 = fdiv double %66, 1.000000e+09
br label %15
68: ; preds = %22
%69 = call i32 (...) @handle_bad_opts()
%70 = load i8*, i8** %1
%71 = call i32 @print_help(i8* %70)
%72 = load i32, i32* @EINVAL
%73 = sub nsw i32 0, %72
br label %146
74: ; preds = %22
%75 = load i32, i32* @stderr
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%77 = call i32 (...) @abort()
unreachable
78: ; preds = %22
%79 = load i32, i32* @stdout
%80 = fmul double %20, 1.000000e+09
%81 = icmp eq i32 %23, 0
%82 = select i1 %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0)
%83 = fmul double %16, 1.000000e+06
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.4, i64 0, i64 0), i8* %11, double %80, i8* %82, double %83)
%85 = fmul double %20, 5.000000e-01
%86 = select i1 %81, double %20, double %85
%87 = call i32 @serial_open(i8* %11)
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %78
%90 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%91 = load i32, i32* @errno
br label %146
92: ; preds = %78
%93 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%94 = bitcast double* %6 to i8*
%95 = call i64 @serial_read_line(i32 %87, i8* %93, i32 512)
%96 = icmp eq i64 %95, 0
br i1 %96, label %100, label %97
97: ; preds = %140, %92
%98 = load i32, i32* @stderr
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
br label %145
100: ; preds = %92, %140
%101 = call i32 (i8*, i8*, ...) @sscanf(i8* %93, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), double* %6, i8* %7)
%102 = icmp eq i32 %101, 2
br i1 %102, label %106, label %103
103: ; preds = %100
%104 = load i32, i32* @stderr
%105 = call i32 (i32, i8*, ...) @fprintf(i32 %104, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.10, i64 0, i64 0), i8* %93)
br label %145
106: ; preds = %100
%107 = load double, double* %6
%108 = fcmp olt double %107, 0.000000e+00
br i1 %108, label %109, label %112
109: ; preds = %106
%110 = load i32, i32* @stderr
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %110, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), double %107)
br label %145
112: ; preds = %106
%113 = load i8, i8* %7
%114 = icmp eq i8 %113, 46
br i1 %114, label %116, label %115
115: ; preds = %112
store i8 32, i8* %7
br label %116
116: ; preds = %115, %112
%117 = phi i32 [ 32, %115 ], [ 46, %112 ]
%118 = fmul double %107, 1.000000e+06
store double %118, double* %6
%119 = fcmp oeq double %118, 0.000000e+00
br i1 %119, label %120, label %123
120: ; preds = %116
%121 = load i32, i32* @stdout
%122 = call i32 (i32, i8*, ...) @fprintf(i32 %121, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), double 0.000000e+00, i32 %117, double %118)
br label %140
123: ; preds = %116
%124 = load i32, i32* @M_PI
%125 = shl nsw i32 %124, 2
%126 = mul nsw i32 %125, %124
%127 = sitofp i32 %126 to float
%128 = fdiv float 1.000000e+00, %127
%129 = fpext float %128 to double
%130 = fmul double %118, %118
%131 = fdiv double %129, %130
%132 = fdiv double %131, %86
%133 = fcmp ogt double %132, 1.000000e+01
%134 = load double, double* @INFINITY
%135 = select i1 %133, double %134, double %132
%136 = fsub double %135, %16
%137 = load i32, i32* @stdout
%138 = fmul double %136, 1.000000e+06
%139 = call i32 (i32, i8*, ...) @fprintf(i32 %137, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), double %138, i32 %117, double %118)
br label %140
140: ; preds = %123, %120
%141 = load i32, i32* @stdout
%142 = call i32 @fflush(i32 %141)
%143 = call i64 @serial_read_line(i32 %87, i8* %93, i32 512)
%144 = icmp eq i64 %143, 0
br i1 %144, label %100, label %97
145: ; preds = %109, %103, %97
br label %146
146: ; preds = %56, %32, %89, %145, %68, %46
%147 = phi i32 [ %73, %68 ], [ 0, %46 ], [ %91, %89 ], [ -1, %145 ], [ %36, %32 ], [ %60, %56 ]
ret i32 %147
}