#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 fw_cdev_get_info {
  unsigned long rom;
  int rom_length;
  unsigned long bus_reset;
  int cycle_timer;
  scalar_t__ local_time;
};
struct fw_cdev_get_cycle_timer {
  unsigned long rom;
  int rom_length;
  unsigned long bus_reset;
  int cycle_timer;
  scalar_t__ local_time;
};
struct fw_cdev_event_bus_reset {
  scalar_t__ node_id;
  scalar_t__ local_node_id;
};
typedef int /*<<< orphan*/ rom;
typedef scalar_t__ __u64;
typedef int __u32;

/* Variables and functions */
int /*<<< orphan*/ FW_CDEV_IOC_GET_CYCLE_TIMER;
int /*<<< orphan*/ FW_CDEV_IOC_GET_INFO;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ cooked_ioctl(int, int /*<<< orphan*/,
                                struct fw_cdev_get_info *, char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ print_ct(int, scalar_t__);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rolled_over(int, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ system(char *);
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: %s /dev/fw[0-n]*\n", argv[0]);
    return -1;
  }
  int fd = open(argv[1], O_RDWR);
  if (fd < 0) {
    fprintf(stderr, "Failed to open %s: %m\n", argv[0]);
    return -1;
  }
  __u32 rom[4];
  struct fw_cdev_event_bus_reset reset;
  struct fw_cdev_get_info info = {
      .rom = (unsigned long)rom,
      .rom_length = sizeof(rom),
      .bus_reset = (unsigned long)&reset,
  };
  cooked_ioctl(fd, FW_CDEV_IOC_GET_INFO, &info, "info");
  if (reset.node_id != reset.local_node_id) {
    fprintf(stderr, "Not a local node\n");
    return -1;
  }
  struct fw_cdev_get_cycle_timer ct;
  __u32 c0, c1;
  __u64 l0, l1, end_time;
  int i, j1, j2, j3;
  cooked_ioctl(fd, FW_CDEV_IOC_GET_CYCLE_TIMER, &ct, "cycle timer");
  c1 = ct.cycle_timer;
  l1 = ct.local_time;
  end_time = l1 + 60 * 1000000ULL;
  for (i = j1 = j2 = j3 = 0; l1 < end_time; i++) {
    cooked_ioctl(fd, FW_CDEV_IOC_GET_CYCLE_TIMER, &ct, "cycle timer");
    c0 = c1;
    l0 = l1;
    c1 = ct.cycle_timer;
    l1 = ct.local_time;
    if (c1 <= c0 && !rolled_over(c0, c1)) {
      print_ct(c0, l0);
      print_ct(c1, l1);
      printf("\n");
      j1++;
      if ((c1 & 0xfffff000) < (c0 & 0xfffff000))
        j2++;
      if ((c1 & 0xfe000000) < (c0 & 0xfe000000))
        j3++;
    }
  }
  printf("--------------------------------------------------------\n\n");
  fflush(stdout);
  char buf[200];
  sprintf(buf, "grep %06X /usr/share/misc/oui.db", rom[3] >> 8);
  if (system(buf) != 0)
    printf("%06X (unknown Vendor OUI)\n", rom[3] >> 8);
  printf("\n%d cycleOffset backwards out of %d samples (%.2e)\n", j1, i,
         (double)j1 / (double)i);
  printf("%d cycleCount backwards (%.2e)\n", j2, (double)j2 / (double)i);
  printf("%d cycleSeconds backwards (%.2e)\n", j3, (double)j3 / (double)i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11dd <main+0x4d>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe36(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1538 <main+0x3a8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dfc(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    122a <main+0x9a>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe02(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1538 <main+0x3a8>
lea    -0x30(%rbp),%rax
mov    %rax,-0x68(%rbp)
movl   $0x10,-0x60(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x50(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2d86(%rip),%rax
mov    (%rax),%esi
lea    -0x68(%rbp),%rdx
lea    0xdc9(%rip),%rcx
call   1030 <cooked_ioctl@plt>
mov    -0x40(%rbp),%rax
cmp    -0x38(%rbp),%rax
je     129d <main+0x10d>
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
lea    0xdab(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1538 <main+0x3a8>
mov    -0x14(%rbp),%edi
mov    0x2d21(%rip),%rax
mov    (%rax),%esi
lea    -0x90(%rbp),%rdx
lea    0xd90(%rip),%rcx
call   1030 <cooked_ioctl@plt>
mov    -0x78(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0xa8(%rbp),%rax
add    $0x3938700,%rax
mov    %rax,-0xb0(%rbp)
movl   $0x0,-0xc0(%rbp)
movl   $0x0,-0xbc(%rbp)
movl   $0x0,-0xb8(%rbp)
movl   $0x0,-0xb4(%rbp)
mov    -0xa8(%rbp),%rax
cmp    -0xb0(%rbp),%rax
jge    1454 <main+0x2c4>
mov    -0x14(%rbp),%edi
mov    0x2c9e(%rip),%rax
mov    (%rax),%esi
lea    -0x90(%rbp),%rdx
lea    0xd0d(%rip),%rcx
call   1030 <cooked_ioctl@plt>
mov    -0x98(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    -0xa8(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x78(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x98(%rbp),%eax
cmp    -0x94(%rbp),%eax
jg     143b <main+0x2ab>
mov    -0x94(%rbp),%edi
mov    -0x98(%rbp),%esi
call   10b0 <rolled_over@plt>
cmp    $0x0,%eax
jne    143b <main+0x2ab>
mov    -0x94(%rbp),%edi
mov    -0xa0(%rbp),%rsi
call   1060 <print_ct@plt>
mov    -0x98(%rbp),%edi
mov    -0xa8(%rbp),%rsi
call   1060 <print_ct@plt>
lea    0xcc8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
mov    -0x98(%rbp),%eax
and    $0xfffff000,%eax
mov    -0x94(%rbp),%ecx
and    $0xfffff000,%ecx
cmp    %ecx,%eax
jae    1408 <main+0x278>
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
mov    -0x98(%rbp),%eax
and    $0xfe000000,%eax
mov    -0x94(%rbp),%ecx
and    $0xfe000000,%ecx
cmp    %ecx,%eax
jae    1436 <main+0x2a6>
mov    -0xc0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc0(%rbp)
jmp    143b <main+0x2ab>
jmp    1440 <main+0x2b0>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    130c <main+0x17c>
lea    0xbf8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2b57(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
lea    -0x190(%rbp),%rdi
mov    -0x24(%rbp),%edx
sar    $0x8,%edx
lea    0xc0a(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x190(%rbp),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
je     14b3 <main+0x323>
mov    -0x24(%rbp),%esi
sar    $0x8,%esi
lea    0xc03(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xb8(%rbp),%esi
mov    -0xb4(%rbp),%edx
cvtsi2sdl -0xb8(%rbp),%xmm0
ff
cvtsi2sdl -0xb4(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
lea    0xbf0(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0xbc(%rbp),%esi
cvtsi2sdl -0xbc(%rbp),%xmm0
ff
cvtsi2sdl -0xb4(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
lea    0xbfc(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0xc0(%rbp),%esi
cvtsi2sdl -0xc0(%rbp),%xmm0
ff
cvtsi2sdl -0xb4(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
lea    0xbf4(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x158,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    1377 <main+0x1c7>
mov    0x8(%rbx),%rdi
mov    0x2e10(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
test   %eax,%eax
js     138c <main+0x1dc>
mov    %eax,%ebp
lea    0x20(%rsp),%rax
mov    %rax,0x68(%rsp)
movl   $0x10,0x70(%rsp)
lea    0x30(%rsp),%rax
mov    %rax,0x78(%rsp)
movl   $0x0,0x80(%rsp)
movq   $0x0,0x88(%rsp)
mov    0x2dbd(%rip),%rax
mov    (%rax),%esi
lea    0xe04(%rip),%rcx
lea    0x68(%rsp),%rdx
mov    %ebp,%edi
call   1030 <cooked_ioctl@plt>
mov    0x30(%rsp),%rax
cmp    0x38(%rsp),%rax
jne    13bd <main+0x20d>
mov    0x2d79(%rip),%rax
mov    (%rax),%esi
lea    0xdef(%rip),%rcx
lea    0x40(%rsp),%rdx
mov    %ebp,%edi
call   1030 <cooked_ioctl@plt>
mov    0x60(%rsp),%r14
xor    %ebx,%ebx
movabs $0x7ffffffffc6c78ff,%rax
ff ff 7f
movl   $0x0,0xc(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0x14(%rsp)
cmp    %rax,%r14
jg     13d6 <main+0x226>
lea    0x3938700(%r14),%rax
mov    %rax,0x18(%rsp)
movl   $0x0,0x14(%rsp)
mov    0x58(%rsp),%r13d
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
xor    %ebx,%ebx
jmp    12de <main+0x12e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebx
cmp    0x18(%rsp),%r14
jge    13d6 <main+0x226>
mov    %r13d,%r12d
mov    %r14,%r15
mov    0x2cdd(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
lea    0x40(%rsp),%rdx
lea    0xd4c(%rip),%rcx
call   1030 <cooked_ioctl@plt>
mov    0x58(%rsp),%r13d
mov    0x60(%rsp),%r14
cmp    %r12d,%r13d
jg     12d0 <main+0x120>
mov    %r12d,%edi
mov    %r13d,%esi
call   10d0 <rolled_over@plt>
test   %eax,%eax
jne    12d0 <main+0x120>
mov    %r12d,%edi
mov    %r15,%rsi
call   1080 <print_ct@plt>
mov    %r13d,%edi
mov    %r14,%rsi
call   1080 <print_ct@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
addl   $0x1,0xc(%rsp)
mov    %r13d,%eax
and    $0xfffff000,%eax
mov    %r12d,%ecx
and    $0xfffff000,%ecx
cmp    %ecx,%eax
adcl   $0x0,0x10(%rsp)
mov    %r13d,%eax
and    $0xfe000000,%eax
and    $0xfe000000,%r12d
cmp    %r12d,%eax
adcl   $0x0,0x14(%rsp)
jmp    12d0 <main+0x120>
mov    0x2c52(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xc76(%rip),%rsi
jmp    139f <main+0x1ef>
mov    0x2c3d(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xc7a(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x158,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c0c(%rip),%rax
mov    (%rax),%edi
lea    0xc68(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    13a6 <main+0x1f6>
lea    0xd28(%rip),%rdi
call   1050 <puts@plt>
mov    0x2bd7(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    0x2c(%rsp),%edx
sar    $0x8,%edx
lea    0xc55(%rip),%rsi
lea    0x90(%rsp),%rbp
mov    %rbp,%rdi
call   10c0 <sprintf@plt>
mov    %rbp,%rdi
call   1060 <system@plt>
test   %rax,%rax
je     1430 <main+0x280>
mov    0x2c(%rsp),%esi
sar    $0x8,%esi
lea    0xc4b(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rsp),%esi
cvtsi2sd %esi,%xmm0
cvtsi2sd %ebx,%xmm1
movsd  %xmm1,0x18(%rsp)
divsd  %xmm1,%xmm0
lea    0xc42(%rip),%rdi
mov    %ebx,%edx
mov    $0x1,%al
call   1070 <printf@plt>
mov    0x10(%rsp),%esi
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
divsd  0x18(%rsp),%xmm0
lea    0xc55(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    0x14(%rsp),%esi
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
divsd  0x18(%rsp),%xmm0
lea    0xc56(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
jmp    13ab <main+0x1fb>

LLVM IR (-O0):
%struct.fw_cdev_event_bus_reset = type { i64, i64 }
%struct.fw_cdev_get_info = type { i64, i32, i64, i32, i64 }
%struct.fw_cdev_get_cycle_timer = type { i64, i32, i64, i32, i64 }
@stderr = global i32 0
@.str = [25 x i8] c"Usage: %s /dev/fw[0-n]*\0A\00"
@O_RDWR = global i32 0
@.str.1 = [23 x i8] c"Failed to open %s: %m\0A\00"
@FW_CDEV_IOC_GET_INFO = global i32 0
@.str.2 = [5 x i8] c"info\00"
@.str.3 = [18 x i8] c"Not a local node\0A\00"
@FW_CDEV_IOC_GET_CYCLE_TIMER = global i32 0
@.str.4 = [12 x i8] c"cycle timer\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [59 x i8] c"--------------------------------------------------------\0A\0A\00"
@stdout = global i32 0
@.str.7 = [33 x i8] c"grep %06X /usr/share/misc/oui.db\00"
@.str.8 = [27 x i8] c"%06X (unknown Vendor OUI)\0A\00"
@.str.9 = [52 x i8] c"\0A%d cycleOffset backwards out of %d samples (%.2e)\0A\00"
@.str.10 = [32 x i8] c"%d cycleCount backwards (%.2e)\0A\00"
@.str.11 = [34 x i8] c"%d cycleSeconds backwards (%.2e)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [4 x i32]
%8 = alloca %struct.fw_cdev_event_bus_reset
%9 = alloca %struct.fw_cdev_get_info
%10 = alloca %struct.fw_cdev_get_cycle_timer
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca [200 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 2
br i1 %22, label %23, label %29
23: ; preds = %2
%24 = load i32, i32* @stderr
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %27)
store i32 -1, i32* %3
br label %169
29: ; preds = %2
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = load i32, i32* @O_RDWR
%34 = call i32 @open(i8* %32, i32 %33)
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %29
%38 = load i32, i32* @stderr
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 0
%41 = load i8*, i8** %40
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %41)
store i32 -1, i32* %3
br label %169
43: ; preds = %29
%44 = getelementptr inbounds %struct.fw_cdev_get_info, %struct.fw_cdev_get_info* %9, i32 0, i32 0
%45 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 0
%46 = ptrtoint i32* %45 to i64
store i64 %46, i64* %44
%47 = getelementptr inbounds %struct.fw_cdev_get_info, %struct.fw_cdev_get_info* %9, i32 0, i32 1
store i32 16, i32* %47
%48 = getelementptr inbounds %struct.fw_cdev_get_info, %struct.fw_cdev_get_info* %9, i32 0, i32 2
%49 = ptrtoint %struct.fw_cdev_event_bus_reset* %8 to i64
store i64 %49, i64* %48
%50 = getelementptr inbounds %struct.fw_cdev_get_info, %struct.fw_cdev_get_info* %9, i32 0, i32 3
store i32 0, i32* %50
%51 = getelementptr inbounds %struct.fw_cdev_get_info, %struct.fw_cdev_get_info* %9, i32 0, i32 4
store i64 0, i64* %51
%52 = load i32, i32* %6
%53 = load i32, i32* @FW_CDEV_IOC_GET_INFO
%54 = call i32 @cooked_ioctl(i32 %52, i32 %53, %struct.fw_cdev_get_info* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%55 = getelementptr inbounds %struct.fw_cdev_event_bus_reset, %struct.fw_cdev_event_bus_reset* %8, i32 0, i32 0
%56 = load i64, i64* %55
%57 = getelementptr inbounds %struct.fw_cdev_event_bus_reset, %struct.fw_cdev_event_bus_reset* %8, i32 0, i32 1
%58 = load i64, i64* %57
%59 = icmp ne i64 %56, %58
br i1 %59, label %60, label %63
60: ; preds = %43
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %169
63: ; preds = %43
%64 = load i32, i32* %6
%65 = load i32, i32* @FW_CDEV_IOC_GET_CYCLE_TIMER
%66 = bitcast %struct.fw_cdev_get_cycle_timer* %10 to %struct.fw_cdev_get_info*
%67 = call i32 @cooked_ioctl(i32 %64, i32 %65, %struct.fw_cdev_get_info* %66, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%68 = getelementptr inbounds %struct.fw_cdev_get_cycle_timer, %struct.fw_cdev_get_cycle_timer* %10, i32 0, i32 3
%69 = load i32, i32* %68
store i32 %69, i32* %12
%70 = getelementptr inbounds %struct.fw_cdev_get_cycle_timer, %struct.fw_cdev_get_cycle_timer* %10, i32 0, i32 4
%71 = load i64, i64* %70
store i64 %71, i64* %14
%72 = load i64, i64* %14
%73 = add i64 %72, 60000000
store i64 %73, i64* %15
store i32 0, i32* %19
store i32 0, i32* %18
store i32 0, i32* %17
store i32 0, i32* %16
br label %74
74: ; preds = %126, %63
%75 = load i64, i64* %14
%76 = load i64, i64* %15
%77 = icmp slt i64 %75, %76
br i1 %77, label %78, label %129
78: ; preds = %74
%79 = load i32, i32* %6
%80 = load i32, i32* @FW_CDEV_IOC_GET_CYCLE_TIMER
%81 = bitcast %struct.fw_cdev_get_cycle_timer* %10 to %struct.fw_cdev_get_info*
%82 = call i32 @cooked_ioctl(i32 %79, i32 %80, %struct.fw_cdev_get_info* %81, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%83 = load i32, i32* %12
store i32 %83, i32* %11
%84 = load i64, i64* %14
store i64 %84, i64* %13
%85 = getelementptr inbounds %struct.fw_cdev_get_cycle_timer, %struct.fw_cdev_get_cycle_timer* %10, i32 0, i32 3
%86 = load i32, i32* %85
store i32 %86, i32* %12
%87 = getelementptr inbounds %struct.fw_cdev_get_cycle_timer, %struct.fw_cdev_get_cycle_timer* %10, i32 0, i32 4
%88 = load i64, i64* %87
store i64 %88, i64* %14
%89 = load i32, i32* %12
%90 = load i32, i32* %11
%91 = icmp sle i32 %89, %90
br i1 %91, label %92, label %125
92: ; preds = %78
%93 = load i32, i32* %11
%94 = load i32, i32* %12
%95 = call i32 @rolled_over(i32 %93, i32 %94)
%96 = icmp ne i32 %95, 0
br i1 %96, label %125, label %97
97: ; preds = %92
%98 = load i32, i32* %11
%99 = load i64, i64* %13
%100 = call i32 @print_ct(i32 %98, i64 %99)
%101 = load i32, i32* %12
%102 = load i64, i64* %14
%103 = call i32 @print_ct(i32 %101, i64 %102)
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%105 = load i32, i32* %17
%106 = add nsw i32 %105, 1
store i32 %106, i32* %17
%107 = load i32, i32* %12
%108 = and i32 %107, -4096
%109 = load i32, i32* %11
%110 = and i32 %109, -4096
%111 = icmp ult i32 %108, %110
br i1 %111, label %112, label %115
112: ; preds = %97
%113 = load i32, i32* %18
%114 = add nsw i32 %113, 1
store i32 %114, i32* %18
br label %115
115: ; preds = %112, %97
%116 = load i32, i32* %12
%117 = and i32 %116, -33554432
%118 = load i32, i32* %11
%119 = and i32 %118, -33554432
%120 = icmp ult i32 %117, %119
br i1 %120, label %121, label %124
121: ; preds = %115
%122 = load i32, i32* %19
%123 = add nsw i32 %122, 1
store i32 %123, i32* %19
br label %124
124: ; preds = %121, %115
br label %125
125: ; preds = %124, %92, %78
br label %126
126: ; preds = %125
%127 = load i32, i32* %16
%128 = add nsw i32 %127, 1
store i32 %128, i32* %16
br label %74
129: ; preds = %74
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.6, i64 0, i64 0))
%131 = load i32, i32* @stdout
%132 = call i32 @fflush(i32 %131)
%133 = getelementptr inbounds [200 x i8], [200 x i8]* %20, i64 0, i64 0
%134 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 3
%135 = load i32, i32* %134
%136 = ashr i32 %135, 8
%137 = call i32 @sprintf(i8* %133, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %136)
%138 = getelementptr inbounds [200 x i8], [200 x i8]* %20, i64 0, i64 0
%139 = call i64 @system(i8* %138)
%140 = icmp ne i64 %139, 0
br i1 %140, label %141, label %146
141: ; preds = %129
%142 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 3
%143 = load i32, i32* %142
%144 = ashr i32 %143, 8
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i32 %144)
br label %146
146: ; preds = %141, %129
%147 = load i32, i32* %17
%148 = load i32, i32* %16
%149 = load i32, i32* %17
%150 = sitofp i32 %149 to double
%151 = load i32, i32* %16
%152 = sitofp i32 %151 to double
%153 = fdiv double %150, %152
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.9, i64 0, i64 0), i32 %147, i32 %148, double %153)
%155 = load i32, i32* %18
%156 = load i32, i32* %18
%157 = sitofp i32 %156 to double
%158 = load i32, i32* %16
%159 = sitofp i32 %158 to double
%160 = fdiv double %157, %159
%161 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i32 %155, double %160)
%162 = load i32, i32* %19
%163 = load i32, i32* %19
%164 = sitofp i32 %163 to double
%165 = load i32, i32* %16
%166 = sitofp i32 %165 to double
%167 = fdiv double %164, %166
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i32 %162, double %167)
store i32 0, i32* %3
br label %169
169: ; preds = %146, %60, %37, %23
%170 = load i32, i32* %3
ret i32 %170
}

LLVM IR (-O2):
%struct.fw_cdev_event_bus_reset = type { i64, i64 }
%struct.fw_cdev_get_info = type { i64, i32, i64, i32, i64 }
%struct.fw_cdev_get_cycle_timer = type { i64, i32, i64, i32, i64 }
@stderr = global i32 0
@.str = [25 x i8] c"Usage: %s /dev/fw[0-n]*\0A\00"
@O_RDWR = global i32 0
@.str.1 = [23 x i8] c"Failed to open %s: %m\0A\00"
@FW_CDEV_IOC_GET_INFO = global i32 0
@.str.2 = [5 x i8] c"info\00"
@.str.3 = [18 x i8] c"Not a local node\0A\00"
@FW_CDEV_IOC_GET_CYCLE_TIMER = global i32 0
@.str.4 = [12 x i8] c"cycle timer\00"
@stdout = global i32 0
@.str.7 = [33 x i8] c"grep %06X /usr/share/misc/oui.db\00"
@.str.8 = [27 x i8] c"%06X (unknown Vendor OUI)\0A\00"
@.str.9 = [52 x i8] c"\0A%d cycleOffset backwards out of %d samples (%.2e)\0A\00"
@.str.10 = [32 x i8] c"%d cycleCount backwards (%.2e)\0A\00"
@.str.11 = [34 x i8] c"%d cycleSeconds backwards (%.2e)\0A\00"
@str = [58 x i8] c"--------------------------------------------------------\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4 x i32]
%4 = alloca %struct.fw_cdev_event_bus_reset
%5 = alloca %struct.fw_cdev_get_info
%6 = alloca %struct.fw_cdev_get_cycle_timer
%7 = alloca [200 x i8]
%8 = icmp eq i32 %0, 2
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %124
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_RDWR
%17 = tail call i32 @open(i8* %15, i32 %16)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %1
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %124
23: ; preds = %13
%24 = bitcast [4 x i32]* %3 to i8*
%25 = bitcast %struct.fw_cdev_event_bus_reset* %4 to i8*
%26 = bitcast %struct.fw_cdev_get_info* %5 to i8*
%27 = getelementptr inbounds %struct.fw_cdev_get_info, %struct.fw_cdev_get_info* %5, i64 0, i32 0
%28 = ptrtoint [4 x i32]* %3 to i64
store i64 %28, i64* %27
%29 = getelementptr inbounds %struct.fw_cdev_get_info, %struct.fw_cdev_get_info* %5, i64 0, i32 1
store i32 16, i32* %29
%30 = getelementptr inbounds %struct.fw_cdev_get_info, %struct.fw_cdev_get_info* %5, i64 0, i32 2
%31 = ptrtoint %struct.fw_cdev_event_bus_reset* %4 to i64
store i64 %31, i64* %30
%32 = getelementptr inbounds %struct.fw_cdev_get_info, %struct.fw_cdev_get_info* %5, i64 0, i32 3
store i32 0, i32* %32
%33 = getelementptr inbounds %struct.fw_cdev_get_info, %struct.fw_cdev_get_info* %5, i64 0, i32 4
store i64 0, i64* %33
%34 = load i32, i32* @FW_CDEV_IOC_GET_INFO
%35 = call i32 @cooked_ioctl(i32 %17, i32 %34, %struct.fw_cdev_get_info* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%36 = getelementptr inbounds %struct.fw_cdev_event_bus_reset, %struct.fw_cdev_event_bus_reset* %4, i64 0, i32 0
%37 = load i64, i64* %36
%38 = getelementptr inbounds %struct.fw_cdev_event_bus_reset, %struct.fw_cdev_event_bus_reset* %4, i64 0, i32 1
%39 = load i64, i64* %38
%40 = icmp eq i64 %37, %39
br i1 %40, label %44, label %41
41: ; preds = %23
%42 = load i32, i32* @stderr
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %122
44: ; preds = %23
%45 = bitcast %struct.fw_cdev_get_cycle_timer* %6 to i8*
%46 = load i32, i32* @FW_CDEV_IOC_GET_CYCLE_TIMER
%47 = bitcast %struct.fw_cdev_get_cycle_timer* %6 to %struct.fw_cdev_get_info*
%48 = call i32 @cooked_ioctl(i32 %17, i32 %46, %struct.fw_cdev_get_info* %47, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%49 = getelementptr inbounds %struct.fw_cdev_get_cycle_timer, %struct.fw_cdev_get_cycle_timer* %6, i64 0, i32 3
%50 = getelementptr inbounds %struct.fw_cdev_get_cycle_timer, %struct.fw_cdev_get_cycle_timer* %6, i64 0, i32 4
%51 = load i64, i64* %50
%52 = add i64 %51, 60000000
%53 = icmp slt i64 %51, 9223372036794775808
br i1 %53, label %54, label %92
54: ; preds = %44
%55 = load i32, i32* %49
br label %56
56: ; preds = %54, %86
%57 = phi i32 [ %89, %86 ], [ 0, %54 ]
%58 = phi i32 [ %88, %86 ], [ 0, %54 ]
%59 = phi i32 [ %87, %86 ], [ 0, %54 ]
%60 = phi i32 [ %90, %86 ], [ 0, %54 ]
%61 = phi i64 [ %66, %86 ], [ %51, %54 ]
%62 = phi i32 [ %65, %86 ], [ %55, %54 ]
%63 = load i32, i32* @FW_CDEV_IOC_GET_CYCLE_TIMER
%64 = call i32 @cooked_ioctl(i32 %17, i32 %63, %struct.fw_cdev_get_info* %47, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%65 = load i32, i32* %49
%66 = load i64, i64* %50
%67 = icmp sgt i32 %65, %62
br i1 %67, label %86, label %68
68: ; preds = %56
%69 = call i32 @rolled_over(i32 %62, i32 %65)
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %86
71: ; preds = %68
%72 = call i32 @print_ct(i32 %62, i64 %61)
%73 = call i32 @print_ct(i32 %65, i64 %66)
%74 = call i32 @putchar(i32 10)
%75 = add nsw i32 %59, 1
%76 = and i32 %65, -4096
%77 = and i32 %62, -4096
%78 = icmp ult i32 %76, %77
%79 = zext i1 %78 to i32
%80 = add nsw i32 %58, %79
%81 = and i32 %65, -33554432
%82 = and i32 %62, -33554432
%83 = icmp ult i32 %81, %82
%84 = zext i1 %83 to i32
%85 = add nsw i32 %57, %84
br label %86
86: ; preds = %71, %56, %68
%87 = phi i32 [ %59, %68 ], [ %59, %56 ], [ %75, %71 ]
%88 = phi i32 [ %58, %68 ], [ %58, %56 ], [ %80, %71 ]
%89 = phi i32 [ %57, %68 ], [ %57, %56 ], [ %85, %71 ]
%90 = add nuw nsw i32 %60, 1
%91 = icmp slt i64 %66, %52
br i1 %91, label %56, label %92
92: ; preds = %86, %44
%93 = phi i32 [ 0, %44 ], [ %90, %86 ]
%94 = phi i32 [ 0, %44 ], [ %87, %86 ]
%95 = phi i32 [ 0, %44 ], [ %88, %86 ]
%96 = phi i32 [ 0, %44 ], [ %89, %86 ]
%97 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str, i64 0, i64 0))
%98 = load i32, i32* @stdout
%99 = call i32 @fflush(i32 %98)
%100 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%101 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
%102 = load i32, i32* %101
%103 = ashr i32 %102, 8
%104 = call i32 @sprintf(i8* %100, i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %103)
%105 = call i64 @system(i8* %100)
%106 = icmp eq i64 %105, 0
br i1 %106, label %111, label %107
107: ; preds = %92
%108 = load i32, i32* %101
%109 = ashr i32 %108, 8
%110 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i32 %109)
br label %111
111: ; preds = %107, %92
%112 = sitofp i32 %94 to double
%113 = sitofp i32 %93 to double
%114 = fdiv double %112, %113
%115 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.9, i64 0, i64 0), i32 %94, i32 %93, double %114)
%116 = sitofp i32 %95 to double
%117 = fdiv double %116, %113
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i32 %95, double %117)
%119 = sitofp i32 %96 to double
%120 = fdiv double %119, %113
%121 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0), i32 %96, double %120)
br label %122
122: ; preds = %111, %41
%123 = phi i32 [ -1, %41 ], [ 0, %111 ]
br label %124
124: ; preds = %19, %122, %9
%125 = phi i32 [ -1, %9 ], [ -1, %19 ], [ %123, %122 ]
ret i32 %125
}