#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 */
struct timeval {
  long double tv_sec;
  long double tv_usec;
};
struct katcl_line {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ add_time_katcp(struct timeval *, struct timeval *,
                                  struct timeval *);
int /*<<< orphan*/ append_args_katcl(struct katcl_line *, int, char *,
                                     long double);
int /*<<< orphan*/ append_string_katcl(struct katcl_line *, int, char *);
char *arg_string_katcl(struct katcl_line *, int);
scalar_t__ cmp_time_katcp(struct timeval *, struct timeval *);
int complete_with_log(struct katcl_line *, struct timeval *,
                      struct katcl_line *);
struct katcl_line *create_katcl(int /*<<< orphan*/);
struct katcl_line *create_name_rpc_katcl(char *);
int /*<<< orphan*/ destroy_rpc_katcl(struct katcl_line *);
long double fmodl(long double, double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ log_message_katcl(struct katcl_line *, int, char *, char *,
                                     ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
double strtold(char *, char **);
int /*<<< orphan*/ sub_time_katcp(struct timeval *, struct timeval *,
                                  struct timeval *);
int /*<<< orphan*/ sync_message_katcl(struct katcl_line *, int, char *, char *,
                                      ...);
long double truncl(long double);
int main(int argc, char **argv) {
  struct katcl_line *l, *k;
  struct timeval start, ready, done, until, delta, request, elapsed, lead,
      local;
  int result, code;
  char *server, *end, *ptr;
  long double value, tmp;
  gettimeofday(&start, NULL);
  k = create_katcl(STDOUT_FILENO);
  if (k == NULL) {
    fprintf(stderr, "unable to create katcp message logic\n");
    return 2;
  }
  if (argc <= 6) {
    sync_message_katcl(
        k, 4, "k7-delay",
        "expect parameters: antpol loadtime delay delayrate fringe fringerate");
    return 1;
  }
  server = "localhost:1235";
  l = create_name_rpc_katcl(server ? server : "localhost:7147");
  if (l == NULL) {
    sync_message_katcl(k, 4, "k7-delay", "unable to connect to %s",
                       server ? server : "localhost:7147");
    return 1;
  }
  append_string_katcl(l, 0x10 | 0x01, "?fr-delay-set");
  append_string_katcl(l, 0x10, argv[1]);
  value = strtold(argv[5], &end);
  tmp = value * 180.0 * 0.3183098861837906715377675267450287L;
  tmp = fmodl(tmp, 360.0);
  append_args_katcl(l, 0x10, "%.16Lf", tmp);
  log_message_katcl(k, 1, "k7-delay", "fringe offset %srad mapped to %.16Lfdeg",
                    argv[5], tmp);
  value = strtold(argv[6], &end);
  tmp = value * 500.0 * 0.3183098861837906715377675267450287L;
  append_args_katcl(l, 0x10, "%.16Lf", tmp);
  log_message_katcl(k, 1, "k7-delay",
                    "fringe rate %srads/ms mapped to %.16Lfrotations/s",
                    argv[6], tmp);
  value = strtold(argv[3], &end);
  append_args_katcl(l, 0x10, "%.16Lf", value / 1000.0);
  log_message_katcl(k, 1, "k7-delay", "delay %sms mapped to %.16Lfs", argv[3],
                    value / 1000.0);
  value = strtold(argv[4], &end);
  append_args_katcl(l, 0x10, "%.16Lf", value);
  log_message_katcl(k, 1, "k7-delay", "delay rate is %.16Lfs/s or ms/ms",
                    value);
  value = strtold(argv[2], &end) / 1000.0;
  append_args_katcl(l, 0x10, "%Lf", value);
  log_message_katcl(k, 1, "k7-delay", "%s load time %sms mapped to %Lfs",
                    argv[1], argv[2], value);
  tmp = truncl(value);
  request.tv_sec = tmp;
  request.tv_usec = (value - tmp) * 1000000;
  append_string_katcl(l, 0x10 | 0x02, "now");
  gettimeofday(&ready, NULL);
  if (cmp_time_katcp(&request, &ready) <= 0) {
    sub_time_katcp(&delta, &ready, &request);
    sync_message_katcl(
        k, 4, "k7-delay", "requested time %lu.%06lus is %lu.%06lus in the past",
        request.tv_sec, request.tv_usec, delta.tv_sec, delta.tv_usec);
    code = 1;
  } else {
    delta.tv_sec = 20;
    delta.tv_usec = 0;
    add_time_katcp(&until, &ready, &delta);
    result = complete_with_log(l, &until, k);
    if (result < 0) {
      sync_message_katcl(k, 4, "k7-delay", "unable to complete request");
      code = 2;
    } else {
      ptr = arg_string_katcl(l, 1);
      if (ptr) {
        if (strcmp(ptr, "ok")) {
          code = 1;
        } else {
          code = 0;
        }
        append_string_katcl(l, 0x10 | 0x01 | 0x02, "?get-log");
        complete_with_log(l, &until, k);
        append_string_katcl(l, 0x10 | 0x01 | 0x02, "?clr-log");
        complete_with_log(l, &until, k);
      } else {
        code = 2;
      }
    }
  }
  gettimeofday(&done, NULL);
  destroy_rpc_katcl(l);
  sub_time_katcp(&lead, &request, &start);
  sub_time_katcp(&elapsed, &done, &start);
  sub_time_katcp(&local, &ready, &start);
  sync_message_katcl(
      k, 1, "k7-delay",
      "delay stats: lead=%lu.%06lus taken=%lu.%06lus setup=%lu.%06lus code=%d",
      lead.tv_sec, lead.tv_usec, elapsed.tv_sec, elapsed.tv_usec, local.tv_sec,
      local.tv_usec, code);
  destroy_rpc_katcl(k);
  return code;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <gettimeofday@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
call   1100 <create_katcl@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1284 <main+0x64>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xdcd(%rip),%rsi
call   10c0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    19d0 <main+0x7b0>
cmpl   $0x6,-0x8(%rbp)
jg     12b8 <main+0x98>
mov    -0x20(%rbp),%rdi
mov    $0x4,%esi
lea    0xdc8(%rip),%rdx
lea    0xdca(%rip),%rcx
mov    $0x0,%al
call   1030 <sync_message_katcl@plt>
movl   $0x1,-0x4(%rbp)
jmp    19d0 <main+0x7b0>
lea    0xdf5(%rip),%rax
mov    %rax,-0x150(%rbp)
cmpq   $0x0,-0x150(%rbp)
je     12e7 <main+0xc7>
mov    -0x150(%rbp),%rax
mov    %rax,-0x1b0(%rbp)
jmp    12fa <main+0xda>
lea    0xdd5(%rip),%rax
mov    %rax,-0x1b0(%rbp)
jmp    12fa <main+0xda>
mov    -0x1b0(%rbp),%rdi
call   1040 <create_name_rpc_katcl@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1388 <main+0x168>
mov    -0x20(%rbp),%rax
mov    %rax,-0x1b8(%rbp)
cmpq   $0x0,-0x150(%rbp)
je     1341 <main+0x121>
mov    -0x150(%rbp),%rax
mov    %rax,-0x1c0(%rbp)
jmp    1354 <main+0x134>
lea    0xd7b(%rip),%rax
mov    %rax,-0x1c0(%rbp)
jmp    1354 <main+0x134>
mov    -0x1b8(%rbp),%rdi
mov    -0x1c0(%rbp),%r8
mov    $0x4,%esi
lea    0xcf8(%rip),%rdx
lea    0xd5d(%rip),%rcx
mov    $0x0,%al
call   1030 <sync_message_katcl@plt>
movl   $0x1,-0x4(%rbp)
jmp    19d0 <main+0x7b0>
mov    -0x18(%rbp),%rdi
lea    0xd57(%rip),%rdx
mov    $0x11,%esi
call   1050 <append_string_katcl@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    $0x10,%esi
mov    %esi,-0x1d8(%rbp)
call   1050 <append_string_katcl@plt>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
lea    -0x158(%rbp),%rsi
mov    %rsi,-0x1e0(%rbp)
call   1110 <strtold@plt>
movsd  %xmm0,-0x188(%rbp)
ff
fldl   -0x188(%rbp)
fstpt  -0x170(%rbp)
fldt   -0x170(%rbp)
flds   0xc0c(%rip)
fmulp  %st,%st(1)
fldt   0xc24(%rip)
fld    %st(0)
fstpt  -0x200(%rbp)
fmulp  %st,%st(1)
fstpt  -0x180(%rbp)
fldt   -0x180(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
movsd  0xc11(%rip),%xmm0
call   1060 <fmodl@plt>
mov    -0x1d8(%rbp),%esi
fstpt  -0x180(%rbp)
mov    -0x18(%rbp),%rdi
fldt   -0x180(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xcb2(%rip),%rdx
mov    %rdx,-0x1e8(%rbp)
call   10a0 <append_args_katcl@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%r8
fldt   -0x180(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xbf6(%rip),%rdx
mov    %rdx,-0x1d0(%rbp)
lea    0xc81(%rip),%rcx
xor    %eax,%eax
mov    %al,-0x1c1(%rbp)
mov    $0x1,%esi
mov    %esi,-0x1d4(%rbp)
call   10d0 <log_message_katcl@plt>
mov    -0x1e0(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
call   1110 <strtold@plt>
fldt   -0x200(%rbp)
mov    -0x1e8(%rbp),%rdx
mov    -0x1d8(%rbp),%esi
movsd  %xmm0,-0x190(%rbp)
ff
fldl   -0x190(%rbp)
fstpt  -0x170(%rbp)
fldt   -0x170(%rbp)
flds   0xb27(%rip)
fmulp  %st,%st(1)
fmulp  %st,%st(1)
fstpt  -0x180(%rbp)
mov    -0x18(%rbp),%rdi
fldt   -0x180(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   10a0 <append_args_katcl@plt>
mov    -0x1d4(%rbp),%esi
mov    -0x1d0(%rbp),%rdx
mov    -0x1c1(%rbp),%al
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    0x30(%rcx),%r8
fldt   -0x180(%rbp)
mov    %rsp,%rcx
fstpt  (%rcx)
lea    0xbfb(%rip),%rcx
call   10d0 <log_message_katcl@plt>
mov    -0x1e0(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1110 <strtold@plt>
mov    -0x1e8(%rbp),%rdx
mov    -0x1d8(%rbp),%esi
movsd  %xmm0,-0x198(%rbp)
ff
fldl   -0x198(%rbp)
fstpt  -0x170(%rbp)
mov    -0x18(%rbp),%rdi
fldt   -0x170(%rbp)
flds   0xa92(%rip)
fld    %st(0)
fstpt  -0x1f4(%rbp)
fdivrp %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   10a0 <append_args_katcl@plt>
fldt   -0x1f4(%rbp)
mov    -0x1d4(%rbp),%esi
mov    -0x1d0(%rbp),%rdx
mov    -0x1c1(%rbp),%al
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    0x18(%rcx),%r8
fldt   -0x170(%rbp)
fdivp  %st,%st(1)
mov    %rsp,%rcx
fstpt  (%rcx)
lea    0xb96(%rip),%rcx
call   10d0 <log_message_katcl@plt>
mov    -0x1e0(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1110 <strtold@plt>
mov    -0x1e8(%rbp),%rdx
mov    -0x1d8(%rbp),%esi
movsd  %xmm0,-0x1a0(%rbp)
ff
fldl   -0x1a0(%rbp)
fstpt  -0x170(%rbp)
mov    -0x18(%rbp),%rdi
fldt   -0x170(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   10a0 <append_args_katcl@plt>
mov    -0x1d4(%rbp),%esi
mov    -0x1d0(%rbp),%rdx
mov    -0x1c1(%rbp),%al
mov    -0x20(%rbp),%rdi
fldt   -0x170(%rbp)
mov    %rsp,%rcx
fstpt  (%rcx)
lea    0xb3c(%rip),%rcx
call   10d0 <log_message_katcl@plt>
mov    -0x1e0(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1110 <strtold@plt>
mov    -0x1d8(%rbp),%esi
movsd  0x9d7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x1a8(%rbp)
ff
fldl   -0x1a8(%rbp)
fstpt  -0x170(%rbp)
mov    -0x18(%rbp),%rdi
fldt   -0x170(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xb08(%rip),%rdx
call   10a0 <append_args_katcl@plt>
mov    -0x1d4(%rbp),%esi
mov    -0x1d0(%rbp),%rdx
mov    -0x1c1(%rbp),%al
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    0x8(%rcx),%r8
mov    0x10(%rcx),%r9
fldt   -0x170(%rbp)
mov    %rsp,%rcx
fstpt  (%rcx)
lea    0xad2(%rip),%rcx
call   10d0 <log_message_katcl@plt>
fldt   -0x170(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1120 <truncl@plt>
fstpt  -0x180(%rbp)
fldt   -0x180(%rbp)
fstpt  -0xe0(%rbp)
fldt   -0x170(%rbp)
fldt   -0x180(%rbp)
fsubrp %st,%st(1)
flds   0x908(%rip)
fmulp  %st,%st(1)
fstpt  -0xd0(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x12,%esi
lea    0xaa0(%rip),%rdx
call   1050 <append_string_katcl@plt>
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <gettimeofday@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   10e0 <cmp_time_katcp@plt>
cmp    $0x0,%rax
jg     17b2 <main+0x592>
lea    -0xc0(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0xe0(%rbp),%rdx
call   1090 <sub_time_katcp@plt>
mov    -0x20(%rbp),%rdi
fldt   -0xe0(%rbp)
fldt   -0xd0(%rbp)
fldt   -0xc0(%rbp)
fldt   -0xb0(%rbp)
mov    %rsp,%rax
fstpt  0x30(%rax)
fstpt  0x20(%rax)
fstpt  0x10(%rax)
fstpt  (%rax)
lea    0x8d6(%rip),%rdx
lea    0xa29(%rip),%rcx
xor    %eax,%eax
mov    $0x4,%esi
call   1030 <sync_message_katcl@plt>
movl   $0x1,-0x148(%rbp)
jmp    18f5 <main+0x6d5>
flds   0x858(%rip)
fstpt  -0xc0(%rbp)
fldz
fstpt  -0xb0(%rbp)
lea    -0xa0(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0xc0(%rbp),%rdx
call   1080 <add_time_katcp@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    -0xa0(%rbp),%rsi
call   1130 <complete_with_log@plt>
mov    %eax,-0x144(%rbp)
cmpl   $0x0,-0x144(%rbp)
jge    1831 <main+0x611>
mov    -0x20(%rbp),%rdi
mov    $0x4,%esi
lea    0x852(%rip),%rdx
lea    0x9d9(%rip),%rcx
mov    $0x0,%al
call   1030 <sync_message_katcl@plt>
movl   $0x2,-0x148(%rbp)
jmp    18f0 <main+0x6d0>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   10f0 <arg_string_katcl@plt>
mov    %rax,-0x160(%rbp)
cmpq   $0x0,-0x160(%rbp)
je     18e1 <main+0x6c1>
mov    -0x160(%rbp),%rdi
lea    0x9ad(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     1880 <main+0x660>
movl   $0x1,-0x148(%rbp)
jmp    188a <main+0x66a>
movl   $0x0,-0x148(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x13,%esi
lea    0x978(%rip),%rdx
call   1050 <append_string_katcl@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    -0xa0(%rbp),%rsi
call   1130 <complete_with_log@plt>
mov    -0x18(%rbp),%rdi
mov    $0x13,%esi
lea    0x958(%rip),%rdx
call   1050 <append_string_katcl@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    -0xa0(%rbp),%rsi
call   1130 <complete_with_log@plt>
jmp    18eb <main+0x6cb>
movl   $0x2,-0x148(%rbp)
jmp    18f0 <main+0x6d0>
jmp    18f5 <main+0x6d5>
xor    %eax,%eax
mov    %eax,%esi
lea    -0x80(%rbp),%rdi
mov    %rdi,-0x210(%rbp)
call   1070 <gettimeofday@plt>
mov    -0x18(%rbp),%rdi
call   1140 <destroy_rpc_katcl@plt>
lea    -0x120(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
lea    -0x40(%rbp),%rdx
mov    %rdx,-0x208(%rbp)
call   1090 <sub_time_katcp@plt>
mov    -0x210(%rbp),%rsi
mov    -0x208(%rbp),%rdx
lea    -0x100(%rbp),%rdi
call   1090 <sub_time_katcp@plt>
mov    -0x208(%rbp),%rdx
lea    -0x140(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1090 <sub_time_katcp@plt>
mov    -0x20(%rbp),%rdi
fldt   -0x120(%rbp)
fldt   -0x110(%rbp)
fldt   -0x100(%rbp)
fldt   -0xf0(%rbp)
fldt   -0x140(%rbp)
fldt   -0x130(%rbp)
mov    -0x148(%rbp),%r8d
mov    %rsp,%rax
fstpt  0x50(%rax)
fstpt  0x40(%rax)
fstpt  0x30(%rax)
fstpt  0x20(%rax)
fstpt  0x10(%rax)
fstpt  (%rax)
lea    0x6bb(%rip),%rdx
lea    0x872(%rip),%rcx
xor    %eax,%eax
mov    $0x1,%esi
call   1030 <sync_message_katcl@plt>
mov    -0x20(%rbp),%rdi
call   1140 <destroy_rpc_katcl@plt>
mov    -0x148(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1e8,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
lea    0x1a0(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
call   1100 <create_katcl@plt>
test   %rax,%rax
je     1288 <main+0x68>
mov    %rax,%r13
cmp    $0x6,%ebx
jg     12a8 <main+0x88>
lea    0xdff(%rip),%rdx
lea    0xe01(%rip),%rcx
mov    %r13,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <sync_message_katcl@plt>
mov    $0x1,%r15d
jmp    17c6 <main+0x5a6>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
lea    0xda8(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x2,%r15d
jmp    17c6 <main+0x5a6>
lea    0xe05(%rip),%rdi
call   1040 <create_name_rpc_katcl@plt>
test   %rax,%rax
je     163f <main+0x41f>
mov    %rax,%r14
lea    0xe14(%rip),%rdx
mov    %rax,%rdi
mov    $0x11,%esi
call   1050 <append_string_katcl@plt>
mov    0x8(%rbp),%rdx
mov    %r14,%rdi
mov    $0x10,%esi
call   1050 <append_string_katcl@plt>
mov    0x28(%rbp),%rdi
lea    0x118(%rsp),%rbx
mov    %rbx,%rsi
call   1110 <strtold@plt>
movsd  %xmm0,0x98(%rsp)
fldl   0x98(%rsp)
fmuls  0xcf1(%rip)
fldt   0xd0b(%rip)
fld    %st(0)
fstpt  0x6c(%rsp)
fmulp  %st,%st(1)
fstpt  (%rsp)
movsd  0xd08(%rip),%xmm0
call   1060 <fmodl@plt>
fld    %st(0)
fstpt  0xc4(%rsp)
fstpt  (%rsp)
lea    0xda9(%rip),%r12
mov    %r14,%rdi
mov    $0x10,%esi
mov    %r12,%rdx
call   10a0 <append_args_katcl@plt>
mov    0x28(%rbp),%r8
fldt   0xc4(%rsp)
fstpt  (%rsp)
lea    0xd01(%rip),%rdx
lea    0xd84(%rip),%rcx
mov    $0x1,%r15d
mov    %r13,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   10d0 <log_message_katcl@plt>
mov    0x30(%rbp),%rdi
mov    %rbx,%rsi
call   1110 <strtold@plt>
movsd  %xmm0,0x90(%rsp)
fldl   0x90(%rsp)
fmuls  0xc61(%rip)
fldt   0x6c(%rsp)
fmulp  %st,%st(1)
fld    %st(0)
fstpt  0x6c(%rsp)
fstpt  (%rsp)
mov    %r14,%rdi
mov    $0x10,%esi
mov    %r12,%rdx
call   10a0 <append_args_katcl@plt>
mov    0x30(%rbp),%r8
fldt   0x6c(%rsp)
fstpt  (%rsp)
lea    0xd44(%rip),%rcx
mov    %r13,%rdi
mov    $0x1,%esi
lea    0xc83(%rip),%rdx
xor    %eax,%eax
call   10d0 <log_message_katcl@plt>
mov    0x18(%rbp),%rdi
mov    %rbx,%rsi
call   1110 <strtold@plt>
movsd  %xmm0,0x88(%rsp)
fldl   0x88(%rsp)
fdivs  0xbfc(%rip)
fld    %st(0)
fstpt  0x6c(%rsp)
fstpt  (%rsp)
mov    %r14,%rdi
mov    $0x10,%esi
mov    %r12,%rdx
call   10a0 <append_args_katcl@plt>
mov    0x18(%rbp),%r8
fldt   0x6c(%rsp)
fstpt  (%rsp)
lea    0xd13(%rip),%rcx
mov    %r13,%rdi
mov    $0x1,%esi
lea    0xc20(%rip),%rdx
mov    %rdx,%r12
xor    %eax,%eax
call   10d0 <log_message_katcl@plt>
mov    0x20(%rbp),%rdi
mov    %rbx,%rsi
call   1110 <strtold@plt>
movsd  %xmm0,0x80(%rsp)
fldl   0x80(%rsp)
fld    %st(0)
fstpt  0x6c(%rsp)
fstpt  (%rsp)
mov    %r14,%rdi
mov    $0x10,%esi
lea    0xc65(%rip),%rdx
call   10a0 <append_args_katcl@plt>
fldt   0x6c(%rsp)
fstpt  (%rsp)
lea    0xcd0(%rip),%rcx
mov    %r13,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   10d0 <log_message_katcl@plt>
mov    0x10(%rbp),%rdi
mov    %rbx,%rsi
call   1110 <strtold@plt>
divsd  0xb7b(%rip),%xmm0
movsd  %xmm0,0x78(%rsp)
fldl   0x78(%rsp)
fld    %st(0)
fstpt  0x6c(%rsp)
fstpt  (%rsp)
lea    0xcb1(%rip),%rdx
mov    %r14,%rdi
mov    $0x10,%esi
call   10a0 <append_args_katcl@plt>
mov    0x8(%rbp),%r8
mov    0x10(%rbp),%r9
fldt   0x6c(%rsp)
fstpt  (%rsp)
lea    0xc92(%rip),%rcx
mov    %r13,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   10d0 <log_message_katcl@plt>
fldt   0x6c(%rsp)
fstpt  (%rsp)
call   1120 <truncl@plt>
fld    %st(0)
fstpt  0xa0(%rsp)
fldt   0x6c(%rsp)
fsubp  %st,%st(1)
fmuls  0xadf(%rip)
fstpt  0xb0(%rsp)
lea    0xc72(%rip),%rdx
mov    %r14,%rdi
mov    $0x12,%esi
call   1050 <append_string_katcl@plt>
lea    0xf0(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
lea    0xa0(%rsp),%rdi
mov    %rbx,%rsi
call   10e0 <cmp_time_katcp@plt>
test   %rax,%rax
jle    166e <main+0x44e>
flds   0xa97(%rip)
fstpt  0xd0(%rsp)
fldz
fstpt  0xe0(%rsp)
lea    0x180(%rsp),%rbx
lea    0xf0(%rsp),%rsi
lea    0xd0(%rsp),%rdx
mov    %rbx,%rdi
call   1080 <add_time_katcp@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1130 <complete_with_log@plt>
test   %eax,%eax
js     16d5 <main+0x4b5>
mov    %r14,%rdi
mov    $0x1,%esi
call   10f0 <arg_string_katcl@plt>
test   %rax,%rax
je     16f2 <main+0x4d2>
lea    0xc24(%rip),%rsi
mov    %rax,%rdi
call   10b0 <strcmp@plt>
xor    %r15d,%r15d
test   %rax,%rax
setne  %r15b
lea    0xc0e(%rip),%rdx
mov    %r14,%rdi
mov    $0x13,%esi
call   1050 <append_string_katcl@plt>
lea    0x180(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1130 <complete_with_log@plt>
lea    0xbed(%rip),%rdx
mov    %r14,%rdi
mov    $0x13,%esi
call   1050 <append_string_katcl@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1130 <complete_with_log@plt>
jmp    16f8 <main+0x4d8>
lea    0xa20(%rip),%rdx
lea    0xa76(%rip),%rcx
lea    0xa60(%rip),%r8
mov    %r13,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <sync_message_katcl@plt>
mov    $0x1,%r15d
jmp    17c6 <main+0x5a6>
lea    0xd0(%rsp),%rdi
lea    0xf0(%rsp),%rsi
lea    0xa0(%rsp),%rdx
call   1090 <sub_time_katcp@plt>
fldt   0xa0(%rsp)
fldt   0xb0(%rsp)
fldt   0xd0(%rsp)
fldt   0xe0(%rsp)
fstpt  0x30(%rsp)
fstpt  0x20(%rsp)
fstpt  0x10(%rsp)
fstpt  (%rsp)
lea    0x9a9(%rip),%rdx
lea    0xaed(%rip),%rcx
mov    %r13,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <sync_message_katcl@plt>
jmp    16f8 <main+0x4d8>
lea    0x98a(%rip),%rdx
lea    0xb02(%rip),%rcx
mov    %r13,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <sync_message_katcl@plt>
mov    $0x2,%r15d
lea    0x1c0(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    %r14,%rdi
call   1140 <destroy_rpc_katcl@plt>
lea    0x140(%rsp),%rdi
lea    0xa0(%rsp),%rsi
lea    0x1a0(%rsp),%rbp
mov    %rbp,%rdx
call   1090 <sub_time_katcp@plt>
lea    0x160(%rsp),%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1090 <sub_time_katcp@plt>
lea    0x120(%rsp),%rdi
lea    0xf0(%rsp),%rsi
mov    %rbp,%rdx
call   1090 <sub_time_katcp@plt>
fldt   0x140(%rsp)
fldt   0x150(%rsp)
fldt   0x160(%rsp)
fldt   0x170(%rsp)
fldt   0x120(%rsp)
fldt   0x130(%rsp)
fstpt  0x50(%rsp)
fstpt  0x40(%rsp)
fstpt  0x30(%rsp)
fstpt  0x20(%rsp)
fstpt  0x10(%rsp)
fstpt  (%rsp)
lea    0x8c1(%rip),%rdx
lea    0xa69(%rip),%rcx
mov    %r13,%rdi
mov    $0x1,%esi
mov    %r15d,%r8d
xor    %eax,%eax
call   1030 <sync_message_katcl@plt>
mov    %r13,%rdi
call   1140 <destroy_rpc_katcl@plt>
mov    %r15d,%eax
add    $0x1e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.katcl_line = type { i32 }
%struct.timeval = type { x86_fp80, x86_fp80 }
@STDOUT_FILENO = global i32 0
@stderr = global i32 0
@.str = [38 x i8] c"unable to create katcp message logic\0A\00"
@.str.1 = [9 x i8] c"k7-delay\00"
@.str.2 = [69 x i8] c"expect parameters: antpol loadtime delay delayrate fringe fringerate\00"
@.str.3 = [15 x i8] c"localhost:1235\00"
@.str.4 = [15 x i8] c"localhost:7147\00"
@.str.5 = [24 x i8] c"unable to connect to %s\00"
@.str.6 = [14 x i8] c"?fr-delay-set\00"
@.str.7 = [7 x i8] c"%.16Lf\00"
@.str.8 = [40 x i8] c"fringe offset %srad mapped to %.16Lfdeg\00"
@.str.9 = [50 x i8] c"fringe rate %srads/ms mapped to %.16Lfrotations/s\00"
@.str.10 = [29 x i8] c"delay %sms mapped to %.16Lfs\00"
@.str.11 = [33 x i8] c"delay rate is %.16Lfs/s or ms/ms\00"
@.str.12 = [4 x i8] c"%Lf\00"
@.str.13 = [33 x i8] c"%s load time %sms mapped to %Lfs\00"
@.str.14 = [4 x i8] c"now\00"
@.str.15 = [52 x i8] c"requested time %lu.%06lus is %lu.%06lus in the past\00"
@.str.16 = [27 x i8] c"unable to complete request\00"
@.str.17 = [3 x i8] c"ok\00"
@.str.18 = [9 x i8] c"?get-log\00"
@.str.19 = [9 x i8] c"?clr-log\00"
@.str.20 = [71 x i8] c"delay stats: lead=%lu.%06lus taken=%lu.%06lus setup=%lu.%06lus code=%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.katcl_line*
%7 = alloca %struct.katcl_line*
%8 = alloca %struct.timeval
%9 = alloca %struct.timeval
%10 = alloca %struct.timeval
%11 = alloca %struct.timeval
%12 = alloca %struct.timeval
%13 = alloca %struct.timeval
%14 = alloca %struct.timeval
%15 = alloca %struct.timeval
%16 = alloca %struct.timeval
%17 = alloca i32
%18 = alloca i32
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca x86_fp80
%23 = alloca x86_fp80
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%24 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%25 = load i32, i32* @STDOUT_FILENO
%26 = call %struct.katcl_line* @create_katcl(i32 %25)
store %struct.katcl_line* %26, %struct.katcl_line** %7
%27 = load %struct.katcl_line*, %struct.katcl_line** %7
%28 = icmp eq %struct.katcl_line* %27, null
br i1 %28, label %29, label %32
29: ; preds = %2
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i32 2, i32* %3
br label %236
32: ; preds = %2
%33 = load i32, i32* %4
%34 = icmp sle i32 %33, 6
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load %struct.katcl_line*, %struct.katcl_line** %7
%37 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %36, i32 4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %236
38: ; preds = %32
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8** %19
%39 = load i8*, i8** %19
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = load i8*, i8** %19
br label %44
43: ; preds = %38
br label %44
44: ; preds = %43, %41
%45 = phi i8* [ %42, %41 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), %43 ]
%46 = call %struct.katcl_line* @create_name_rpc_katcl(i8* %45)
store %struct.katcl_line* %46, %struct.katcl_line** %6
%47 = load %struct.katcl_line*, %struct.katcl_line** %6
%48 = icmp eq %struct.katcl_line* %47, null
br i1 %48, label %49, label %59
49: ; preds = %44
%50 = load %struct.katcl_line*, %struct.katcl_line** %7
%51 = load i8*, i8** %19
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = load i8*, i8** %19
br label %56
55: ; preds = %49
br label %56
56: ; preds = %55, %53
%57 = phi i8* [ %54, %53 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), %55 ]
%58 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %50, i32 4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %57)
store i32 1, i32* %3
br label %236
59: ; preds = %44
%60 = load %struct.katcl_line*, %struct.katcl_line** %6
%61 = call i32 @append_string_katcl(%struct.katcl_line* %60, i32 17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%62 = load %struct.katcl_line*, %struct.katcl_line** %6
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 1
%65 = load i8*, i8** %64
%66 = call i32 @append_string_katcl(%struct.katcl_line* %62, i32 16, i8* %65)
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 5
%69 = load i8*, i8** %68
%70 = call double @strtold(i8* %69, i8** %20)
%71 = fpext double %70 to x86_fp80
store x86_fp80 %71, x86_fp80* %22
%72 = load x86_fp80, x86_fp80* %22
%73 = fmul x86_fp80 %72, 0xK4006B400000000000000
%74 = fmul x86_fp80 %73, 0xK3FFDA2F9836E4E44152A
store x86_fp80 %74, x86_fp80* %23
%75 = load x86_fp80, x86_fp80* %23
%76 = call x86_fp80 @fmodl(x86_fp80 %75, double 3.600000e+02)
store x86_fp80 %76, x86_fp80* %23
%77 = load %struct.katcl_line*, %struct.katcl_line** %6
%78 = load x86_fp80, x86_fp80* %23
%79 = call i32 @append_args_katcl(%struct.katcl_line* %77, i32 16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), x86_fp80 %78)
%80 = load %struct.katcl_line*, %struct.katcl_line** %7
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 5
%83 = load i8*, i8** %82
%84 = load x86_fp80, x86_fp80* %23
%85 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %80, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i8* %83, x86_fp80 %84)
%86 = load i8**, i8*** %5
%87 = getelementptr inbounds i8*, i8** %86, i64 6
%88 = load i8*, i8** %87
%89 = call double @strtold(i8* %88, i8** %20)
%90 = fpext double %89 to x86_fp80
store x86_fp80 %90, x86_fp80* %22
%91 = load x86_fp80, x86_fp80* %22
%92 = fmul x86_fp80 %91, 0xK4007FA00000000000000
%93 = fmul x86_fp80 %92, 0xK3FFDA2F9836E4E44152A
store x86_fp80 %93, x86_fp80* %23
%94 = load %struct.katcl_line*, %struct.katcl_line** %6
%95 = load x86_fp80, x86_fp80* %23
%96 = call i32 @append_args_katcl(%struct.katcl_line* %94, i32 16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), x86_fp80 %95)
%97 = load %struct.katcl_line*, %struct.katcl_line** %7
%98 = load i8**, i8*** %5
%99 = getelementptr inbounds i8*, i8** %98, i64 6
%100 = load i8*, i8** %99
%101 = load x86_fp80, x86_fp80* %23
%102 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %97, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0), i8* %100, x86_fp80 %101)
%103 = load i8**, i8*** %5
%104 = getelementptr inbounds i8*, i8** %103, i64 3
%105 = load i8*, i8** %104
%106 = call double @strtold(i8* %105, i8** %20)
%107 = fpext double %106 to x86_fp80
store x86_fp80 %107, x86_fp80* %22
%108 = load %struct.katcl_line*, %struct.katcl_line** %6
%109 = load x86_fp80, x86_fp80* %22
%110 = fdiv x86_fp80 %109, 0xK4008FA00000000000000
%111 = call i32 @append_args_katcl(%struct.katcl_line* %108, i32 16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), x86_fp80 %110)
%112 = load %struct.katcl_line*, %struct.katcl_line** %7
%113 = load i8**, i8*** %5
%114 = getelementptr inbounds i8*, i8** %113, i64 3
%115 = load i8*, i8** %114
%116 = load x86_fp80, x86_fp80* %22
%117 = fdiv x86_fp80 %116, 0xK4008FA00000000000000
%118 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %112, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %115, x86_fp80 %117)
%119 = load i8**, i8*** %5
%120 = getelementptr inbounds i8*, i8** %119, i64 4
%121 = load i8*, i8** %120
%122 = call double @strtold(i8* %121, i8** %20)
%123 = fpext double %122 to x86_fp80
store x86_fp80 %123, x86_fp80* %22
%124 = load %struct.katcl_line*, %struct.katcl_line** %6
%125 = load x86_fp80, x86_fp80* %22
%126 = call i32 @append_args_katcl(%struct.katcl_line* %124, i32 16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), x86_fp80 %125)
%127 = load %struct.katcl_line*, %struct.katcl_line** %7
%128 = load x86_fp80, x86_fp80* %22
%129 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %127, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), x86_fp80 %128)
%130 = load i8**, i8*** %5
%131 = getelementptr inbounds i8*, i8** %130, i64 2
%132 = load i8*, i8** %131
%133 = call double @strtold(i8* %132, i8** %20)
%134 = fdiv double %133, 1.000000e+03
%135 = fpext double %134 to x86_fp80
store x86_fp80 %135, x86_fp80* %22
%136 = load %struct.katcl_line*, %struct.katcl_line** %6
%137 = load x86_fp80, x86_fp80* %22
%138 = call i32 @append_args_katcl(%struct.katcl_line* %136, i32 16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), x86_fp80 %137)
%139 = load %struct.katcl_line*, %struct.katcl_line** %7
%140 = load i8**, i8*** %5
%141 = getelementptr inbounds i8*, i8** %140, i64 1
%142 = load i8*, i8** %141
%143 = load i8**, i8*** %5
%144 = getelementptr inbounds i8*, i8** %143, i64 2
%145 = load i8*, i8** %144
%146 = load x86_fp80, x86_fp80* %22
%147 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %139, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0), i8* %142, i8* %145, x86_fp80 %146)
%148 = load x86_fp80, x86_fp80* %22
%149 = call x86_fp80 @llvm.trunc.f80(x86_fp80 %148)
store x86_fp80 %149, x86_fp80* %23
%150 = load x86_fp80, x86_fp80* %23
%151 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
store x86_fp80 %150, x86_fp80* %151
%152 = load x86_fp80, x86_fp80* %22
%153 = load x86_fp80, x86_fp80* %23
%154 = fsub x86_fp80 %152, %153
%155 = fmul x86_fp80 %154, 0xK4012F424000000000000
%156 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
store x86_fp80 %155, x86_fp80* %156
%157 = load %struct.katcl_line*, %struct.katcl_line** %6
%158 = call i32 @append_string_katcl(%struct.katcl_line* %157, i32 18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0))
%159 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%160 = call i64 @cmp_time_katcp(%struct.timeval* %13, %struct.timeval* %9)
%161 = icmp sle i64 %160, 0
br i1 %161, label %162, label %174
162: ; preds = %59
%163 = call i32 @sub_time_katcp(%struct.timeval* %12, %struct.timeval* %9, %struct.timeval* %13)
%164 = load %struct.katcl_line*, %struct.katcl_line** %7
%165 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%166 = load x86_fp80, x86_fp80* %165
%167 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%168 = load x86_fp80, x86_fp80* %167
%169 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%170 = load x86_fp80, x86_fp80* %169
%171 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
%172 = load x86_fp80, x86_fp80* %171
%173 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %164, i32 4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.15, i64 0, i64 0), x86_fp80 %166, x86_fp80 %168, x86_fp80 %170, x86_fp80 %172)
store i32 1, i32* %18
br label %211
174: ; preds = %59
%175 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
store x86_fp80 0xK4003A000000000000000, x86_fp80* %175
%176 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
store x86_fp80 0xK00000000000000000000, x86_fp80* %176
%177 = call i32 @add_time_katcp(%struct.timeval* %11, %struct.timeval* %9, %struct.timeval* %12)
%178 = load %struct.katcl_line*, %struct.katcl_line** %6
%179 = load %struct.katcl_line*, %struct.katcl_line** %7
%180 = call i32 @complete_with_log(%struct.katcl_line* %178, %struct.timeval* %11, %struct.katcl_line* %179)
store i32 %180, i32* %17
%181 = load i32, i32* %17
%182 = icmp slt i32 %181, 0
br i1 %182, label %183, label %186
183: ; preds = %174
%184 = load %struct.katcl_line*, %struct.katcl_line** %7
%185 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %184, i32 4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0))
store i32 2, i32* %18
br label %210
186: ; preds = %174
%187 = load %struct.katcl_line*, %struct.katcl_line** %6
%188 = call i8* @arg_string_katcl(%struct.katcl_line* %187, i32 1)
store i8* %188, i8** %21
%189 = load i8*, i8** %21
%190 = icmp ne i8* %189, null
br i1 %190, label %191, label %208
191: ; preds = %186
%192 = load i8*, i8** %21
%193 = call i64 @strcmp(i8* %192, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
%194 = icmp ne i64 %193, 0
br i1 %194, label %195, label %196
195: ; preds = %191
store i32 1, i32* %18
br label %197
196: ; preds = %191
store i32 0, i32* %18
br label %197
197: ; preds = %196, %195
%198 = load %struct.katcl_line*, %struct.katcl_line** %6
%199 = call i32 @append_string_katcl(%struct.katcl_line* %198, i32 19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.18, i64 0, i64 0))
%200 = load %struct.katcl_line*, %struct.katcl_line** %6
%201 = load %struct.katcl_line*, %struct.katcl_line** %7
%202 = call i32 @complete_with_log(%struct.katcl_line* %200, %struct.timeval* %11, %struct.katcl_line* %201)
%203 = load %struct.katcl_line*, %struct.katcl_line** %6
%204 = call i32 @append_string_katcl(%struct.katcl_line* %203, i32 19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i64 0, i64 0))
%205 = load %struct.katcl_line*, %struct.katcl_line** %6
%206 = load %struct.katcl_line*, %struct.katcl_line** %7
%207 = call i32 @complete_with_log(%struct.katcl_line* %205, %struct.timeval* %11, %struct.katcl_line* %206)
br label %209
208: ; preds = %186
store i32 2, i32* %18
br label %209
209: ; preds = %208, %197
br label %210
210: ; preds = %209, %183
br label %211
211: ; preds = %210, %162
%212 = call i32 @gettimeofday(%struct.timeval* %10, i32* null)
%213 = load %struct.katcl_line*, %struct.katcl_line** %6
%214 = call i32 @destroy_rpc_katcl(%struct.katcl_line* %213)
%215 = call i32 @sub_time_katcp(%struct.timeval* %15, %struct.timeval* %13, %struct.timeval* %8)
%216 = call i32 @sub_time_katcp(%struct.timeval* %14, %struct.timeval* %10, %struct.timeval* %8)
%217 = call i32 @sub_time_katcp(%struct.timeval* %16, %struct.timeval* %9, %struct.timeval* %8)
%218 = load %struct.katcl_line*, %struct.katcl_line** %7
%219 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 0
%220 = load x86_fp80, x86_fp80* %219
%221 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
%222 = load x86_fp80, x86_fp80* %221
%223 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%224 = load x86_fp80, x86_fp80* %223
%225 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
%226 = load x86_fp80, x86_fp80* %225
%227 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
%228 = load x86_fp80, x86_fp80* %227
%229 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 1
%230 = load x86_fp80, x86_fp80* %229
%231 = load i32, i32* %18
%232 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %218, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.20, i64 0, i64 0), x86_fp80 %220, x86_fp80 %222, x86_fp80 %224, x86_fp80 %226, x86_fp80 %228, x86_fp80 %230, i32 %231)
%233 = load %struct.katcl_line*, %struct.katcl_line** %7
%234 = call i32 @destroy_rpc_katcl(%struct.katcl_line* %233)
%235 = load i32, i32* %18
store i32 %235, i32* %3
br label %236
236: ; preds = %211, %56, %35, %29
%237 = load i32, i32* %3
ret i32 %237
}

LLVM IR (-O2):
%struct.timeval = type { x86_fp80, x86_fp80 }
%struct.katcl_line = type { i32 }
@STDOUT_FILENO = global i32 0
@stderr = global i32 0
@.str = [38 x i8] c"unable to create katcp message logic\0A\00"
@.str.1 = [9 x i8] c"k7-delay\00"
@.str.2 = [69 x i8] c"expect parameters: antpol loadtime delay delayrate fringe fringerate\00"
@.str.3 = [15 x i8] c"localhost:1235\00"
@.str.5 = [24 x i8] c"unable to connect to %s\00"
@.str.6 = [14 x i8] c"?fr-delay-set\00"
@.str.7 = [7 x i8] c"%.16Lf\00"
@.str.8 = [40 x i8] c"fringe offset %srad mapped to %.16Lfdeg\00"
@.str.9 = [50 x i8] c"fringe rate %srads/ms mapped to %.16Lfrotations/s\00"
@.str.10 = [29 x i8] c"delay %sms mapped to %.16Lfs\00"
@.str.11 = [33 x i8] c"delay rate is %.16Lfs/s or ms/ms\00"
@.str.12 = [4 x i8] c"%Lf\00"
@.str.13 = [33 x i8] c"%s load time %sms mapped to %Lfs\00"
@.str.14 = [4 x i8] c"now\00"
@.str.15 = [52 x i8] c"requested time %lu.%06lus is %lu.%06lus in the past\00"
@.str.16 = [27 x i8] c"unable to complete request\00"
@.str.17 = [3 x i8] c"ok\00"
@.str.18 = [9 x i8] c"?get-log\00"
@.str.19 = [9 x i8] c"?clr-log\00"
@.str.20 = [71 x i8] c"delay stats: lead=%lu.%06lus taken=%lu.%06lus setup=%lu.%06lus code=%d\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca %struct.timeval
%9 = alloca %struct.timeval
%10 = alloca %struct.timeval
%11 = alloca %struct.timeval
%12 = alloca i8*
%13 = bitcast %struct.timeval* %3 to i8*
%14 = bitcast %struct.timeval* %4 to i8*
%15 = bitcast %struct.timeval* %5 to i8*
%16 = bitcast %struct.timeval* %6 to i8*
%17 = bitcast %struct.timeval* %7 to i8*
%18 = bitcast %struct.timeval* %8 to i8*
%19 = bitcast %struct.timeval* %9 to i8*
%20 = bitcast %struct.timeval* %10 to i8*
%21 = bitcast %struct.timeval* %11 to i8*
%22 = bitcast i8** %12 to i8*
%23 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%24 = load i32, i32* @STDOUT_FILENO
%25 = tail call %struct.katcl_line* @create_katcl(i32 %24)
%26 = icmp eq %struct.katcl_line* %25, null
br i1 %26, label %27, label %30
27: ; preds = %2
%28 = load i32, i32* @stderr
%29 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %144
30: ; preds = %2
%31 = icmp slt i32 %0, 7
br i1 %31, label %32, label %34
32: ; preds = %30
%33 = tail call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %25, i32 4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.2, i64 0, i64 0))
br label %144
34: ; preds = %30
%35 = tail call %struct.katcl_line* @create_name_rpc_katcl(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp eq %struct.katcl_line* %35, null
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = tail call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %25, i32 4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %144
39: ; preds = %34
%40 = tail call i32 @append_string_katcl(%struct.katcl_line* %35, i32 17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%41 = getelementptr inbounds i8*, i8** %1, i64 1
%42 = load i8*, i8** %41
%43 = tail call i32 @append_string_katcl(%struct.katcl_line* %35, i32 16, i8* %42)
%44 = getelementptr inbounds i8*, i8** %1, i64 5
%45 = load i8*, i8** %44
%46 = call double @strtold(i8* %45, i8** %12)
%47 = fpext double %46 to x86_fp80
%48 = fmul x86_fp80 %47, 0xK4006B400000000000000
%49 = fmul x86_fp80 %48, 0xK3FFDA2F9836E4E44152A
%50 = tail call x86_fp80 @fmodl(x86_fp80 %49, double 3.600000e+02)
%51 = tail call i32 @append_args_katcl(%struct.katcl_line* %35, i32 16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), x86_fp80 %50)
%52 = load i8*, i8** %44
%53 = tail call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %25, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i8* %52, x86_fp80 %50)
%54 = getelementptr inbounds i8*, i8** %1, i64 6
%55 = load i8*, i8** %54
%56 = call double @strtold(i8* %55, i8** %12)
%57 = fpext double %56 to x86_fp80
%58 = fmul x86_fp80 %57, 0xK4007FA00000000000000
%59 = fmul x86_fp80 %58, 0xK3FFDA2F9836E4E44152A
%60 = tail call i32 @append_args_katcl(%struct.katcl_line* %35, i32 16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), x86_fp80 %59)
%61 = load i8*, i8** %54
%62 = tail call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %25, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.9, i64 0, i64 0), i8* %61, x86_fp80 %59)
%63 = getelementptr inbounds i8*, i8** %1, i64 3
%64 = load i8*, i8** %63
%65 = call double @strtold(i8* %64, i8** %12)
%66 = fpext double %65 to x86_fp80
%67 = fdiv x86_fp80 %66, 0xK4008FA00000000000000
%68 = tail call i32 @append_args_katcl(%struct.katcl_line* %35, i32 16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), x86_fp80 %67)
%69 = load i8*, i8** %63
%70 = tail call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %25, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %69, x86_fp80 %67)
%71 = getelementptr inbounds i8*, i8** %1, i64 4
%72 = load i8*, i8** %71
%73 = call double @strtold(i8* %72, i8** %12)
%74 = fpext double %73 to x86_fp80
%75 = tail call i32 @append_args_katcl(%struct.katcl_line* %35, i32 16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), x86_fp80 %74)
%76 = tail call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %25, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), x86_fp80 %74)
%77 = getelementptr inbounds i8*, i8** %1, i64 2
%78 = load i8*, i8** %77
%79 = call double @strtold(i8* %78, i8** %12)
%80 = fdiv double %79, 1.000000e+03
%81 = fpext double %80 to x86_fp80
%82 = tail call i32 @append_args_katcl(%struct.katcl_line* %35, i32 16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), x86_fp80 %81)
%83 = load i8*, i8** %41
%84 = load i8*, i8** %77
%85 = tail call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @log_message_katcl(%struct.katcl_line* %25, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0), i8* %83, i8* %84, x86_fp80 %81)
%86 = tail call x86_fp80 @llvm.trunc.f80(x86_fp80 %81)
%87 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i64 0, i32 0
store x86_fp80 %86, x86_fp80* %87
%88 = fsub x86_fp80 %81, %86
%89 = fmul x86_fp80 %88, 0xK4012F424000000000000
%90 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i64 0, i32 1
store x86_fp80 %89, x86_fp80* %90
%91 = tail call i32 @append_string_katcl(%struct.katcl_line* %35, i32 18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0))
%92 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%93 = call i64 @cmp_time_katcp(%struct.timeval* %8, %struct.timeval* %4)
%94 = icmp slt i64 %93, 1
br i1 %94, label %95, label %104
95: ; preds = %39
%96 = call i32 @sub_time_katcp(%struct.timeval* %7, %struct.timeval* %4, %struct.timeval* %8)
%97 = load x86_fp80, x86_fp80* %87
%98 = load x86_fp80, x86_fp80* %90
%99 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 0
%100 = load x86_fp80, x86_fp80* %99
%101 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 1
%102 = load x86_fp80, x86_fp80* %101
%103 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %25, i32 4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.15, i64 0, i64 0), x86_fp80 %97, x86_fp80 %98, x86_fp80 %100, x86_fp80 %102)
br label %123
104: ; preds = %39
%105 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 0
store x86_fp80 0xK4003A000000000000000, x86_fp80* %105
%106 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 1
store x86_fp80 0xK00000000000000000000, x86_fp80* %106
%107 = call i32 @add_time_katcp(%struct.timeval* %6, %struct.timeval* %4, %struct.timeval* %7)
%108 = call i32 @complete_with_log(%struct.katcl_line* %35, %struct.timeval* %6, %struct.katcl_line* %25)
%109 = icmp slt i32 %108, 0
br i1 %109, label %110, label %112
110: ; preds = %104
%111 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %25, i32 4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0))
br label %123
112: ; preds = %104
%113 = call i8* @arg_string_katcl(%struct.katcl_line* %35, i32 1)
%114 = icmp eq i8* %113, null
br i1 %114, label %123, label %115
115: ; preds = %112
%116 = call i64 @strcmp(i8* %113, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
%117 = icmp ne i64 %116, 0
%118 = zext i1 %117 to i32
%119 = call i32 @append_string_katcl(%struct.katcl_line* %35, i32 19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.18, i64 0, i64 0))
%120 = call i32 @complete_with_log(%struct.katcl_line* %35, %struct.timeval* %6, %struct.katcl_line* %25)
%121 = call i32 @append_string_katcl(%struct.katcl_line* %35, i32 19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.19, i64 0, i64 0))
%122 = call i32 @complete_with_log(%struct.katcl_line* %35, %struct.timeval* %6, %struct.katcl_line* %25)
br label %123
123: ; preds = %112, %110, %115, %95
%124 = phi i32 [ 1, %95 ], [ 2, %110 ], [ %118, %115 ], [ 2, %112 ]
%125 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%126 = call i32 @destroy_rpc_katcl(%struct.katcl_line* %35)
%127 = call i32 @sub_time_katcp(%struct.timeval* %10, %struct.timeval* %8, %struct.timeval* %3)
%128 = call i32 @sub_time_katcp(%struct.timeval* %9, %struct.timeval* %5, %struct.timeval* %3)
%129 = call i32 @sub_time_katcp(%struct.timeval* %11, %struct.timeval* %4, %struct.timeval* %3)
%130 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 0
%131 = load x86_fp80, x86_fp80* %130
%132 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 1
%133 = load x86_fp80, x86_fp80* %132
%134 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i64 0, i32 0
%135 = load x86_fp80, x86_fp80* %134
%136 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i64 0, i32 1
%137 = load x86_fp80, x86_fp80* %136
%138 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i64 0, i32 0
%139 = load x86_fp80, x86_fp80* %138
%140 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i64 0, i32 1
%141 = load x86_fp80, x86_fp80* %140
%142 = call i32 (%struct.katcl_line*, i32, i8*, i8*, ...) @sync_message_katcl(%struct.katcl_line* %25, i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.20, i64 0, i64 0), x86_fp80 %131, x86_fp80 %133, x86_fp80 %135, x86_fp80 %137, x86_fp80 %139, x86_fp80 %141, i32 %124)
%143 = call i32 @destroy_rpc_katcl(%struct.katcl_line* %25)
br label %144
144: ; preds = %123, %37, %32, %27
%145 = phi i32 [ 2, %27 ], [ 1, %32 ], [ 1, %37 ], [ %124, %123 ]
ret i32 %145
}