#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 timespec {
  int tv_nsec;
  int tv_sec;
};
struct sched_param {
  int sched_priority;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int EXIT_FAILURE;
int /*<<< orphan*/ SCHED_FIFO;
int /*<<< orphan*/ TIMER_ABSTIME;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ clock_nanosleep(int /*<<< orphan*/, int /*<<< orphan*/,
                                   struct timespec *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ ioperm(unsigned int, int, int);
int /*<<< orphan*/ outb(unsigned char, unsigned int);
scalar_t__ parity(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sched_getparam(int /*<<< orphan*/, struct sched_param *);
scalar_t__ sched_setscheduler(int /*<<< orphan*/, int /*<<< orphan*/,
                              struct sched_param *);
int sscanf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int _argc, char *_argv[]) {
  struct timespec traintime;
  struct timespec synctime;
  unsigned long long msec;
  struct sched_param sch_param;
  int i;
  unsigned int portbase;
  unsigned char outbits;
  unsigned int site_id;
  if (_argc > 4 || _argc < 3) {
    printf("wrong number of parameters (%i instead of 2 or 3), aborting\n",
           _argc - 1);
    return (EXIT_FAILURE);
  }
  if (sscanf(_argv[1], "%u", &portbase) != 1) {
    printf("cannot read the first argument (portbase), aborting\n");
    return (EXIT_FAILURE);
  }
  if (sscanf(_argv[2], "%hhu", &outbits) != 1) {
    printf("cannot read the second argument (outbits), aborting\n");
    return (EXIT_FAILURE);
  }
  if (_argc == 4) {
    if (sscanf(_argv[3], "%u", &site_id) != 1) {
      printf("cannot read the third argument (site ID), aborting\n");
      return (EXIT_FAILURE);
    }
  }
  if (sizeof(unsigned long long) * 8 < 42 + 5 + 2) {
    printf("\"unsigned long long\" is too short on your platform, aborting\n");
    return (EXIT_FAILURE);
  }
  if (ioperm(portbase, 1, 1)) {
    fprintf(stderr,
            "Cannot get the port. Maybe you should run this program as root\n");
    return (1);
  }
  outb(0, portbase);
  sch_param.sched_priority = 20;
  if (sched_setscheduler(0, SCHED_FIFO, &sch_param)) {
    fprintf(stderr, "Cannot set new priority\n");
    return (1);
  }
  sch_param.sched_priority = 0;
  sched_getparam(0, &sch_param);
  fprintf(stdout, "Running with new static priority = %i\n",
          sch_param.sched_priority);
  fprintf(stdout, "LPT address: 0x%x, output bit mask: 0x%x\n", portbase,
          outbits);
  if (_argc == 4) {
    fprintf(stdout, "Site id: %i\n", site_id);
  } else {
    fprintf(stdout, "Site id is not specified\n");
  }
  clock_gettime(CLOCK_REALTIME, &synctime);
  synctime.tv_nsec = 0;
  synctime.tv_sec += 1;
  synctime.tv_sec -= synctime.tv_sec % 60;
  synctime.tv_sec += 60;
  while (1) {
    synctime.tv_sec += 10;
    clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &synctime, NULL);
    outb(outbits, portbase);
    clock_gettime(CLOCK_REALTIME, &traintime);
    msec = traintime.tv_nsec / 1000000;
    msec += traintime.tv_sec * 1000;
    msec += (((unsigned long long)parity(msec)) << 42);
    if (_argc == 4) {
      msec += (((unsigned long long)site_id) << (42 + 1));
      msec += (((unsigned long long)parity(site_id)) << (42 + 5 + 1));
    }
    traintime.tv_sec = 0;
    traintime.tv_nsec = 15000000;
    clock_nanosleep(CLOCK_REALTIME, 0, &traintime, NULL);
    outb(0, portbase);
    for (i = 0; i < (_argc == 4 ? 42 + 5 + 2 : 42 + 1); i++) {
      traintime.tv_nsec = (1 + 2 * (msec % 2)) * 15000000;
      msec /= 2;
      clock_nanosleep(CLOCK_REALTIME, 0, &traintime, NULL);
      outb(outbits, portbase);
      traintime.tv_nsec = 15000000;
      clock_nanosleep(CLOCK_REALTIME, 0, &traintime, NULL);
      outb(0, portbase);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jg     11ca <main+0x2a>
cmpl   $0x3,-0x8(%rbp)
jge    11ef <main+0x4f>
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2de3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15a5 <main+0x405>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3f(%rip),%rsi
lea    -0x38(%rbp),%rdx
mov    $0x0,%al
call   10b0 <sscanf@plt>
cmp    $0x1,%eax
je     1231 <main+0x91>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2da1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15a5 <main+0x405>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe35(%rip),%rsi
lea    -0x39(%rbp),%rdx
mov    $0x0,%al
call   10b0 <sscanf@plt>
cmp    $0x1,%eax
je     1273 <main+0xd3>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15a5 <main+0x405>
cmpl   $0x4,-0x8(%rbp)
jne    12c4 <main+0x124>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xdb1(%rip),%rsi
lea    -0x40(%rbp),%rdx
mov    $0x0,%al
call   10b0 <sscanf@plt>
cmp    $0x1,%eax
je     12bf <main+0x11f>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    15a5 <main+0x405>
jmp    12c4 <main+0x124>
mov    -0x38(%rbp),%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1090 <ioperm@plt>
cmp    $0x0,%rax
je     1300 <main+0x160>
mov    0x2cec(%rip),%rax
mov    (%rax),%edi
lea    0xdf6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15a5 <main+0x405>
mov    -0x38(%rbp),%esi
xor    %edi,%edi
call   1050 <outb@plt>
movl   $0x14,-0x30(%rbp)
mov    0x2cc8(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
lea    -0x30(%rbp),%rdx
call   1070 <sched_setscheduler@plt>
cmp    $0x0,%rax
je     1352 <main+0x1b2>
mov    0x2c9a(%rip),%rax
mov    (%rax),%edi
lea    0xde4(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15a5 <main+0x405>
movl   $0x0,-0x30(%rbp)
xor    %edi,%edi
lea    -0x30(%rbp),%rsi
call   1060 <sched_getparam@plt>
mov    0x2c55(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%edx
lea    0xdc5(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2c3b(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%edx
movzbl -0x39(%rbp),%ecx
lea    0xdce(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
cmpl   $0x4,-0x8(%rbp)
jne    13c5 <main+0x225>
mov    0x2c13(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%edx
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    13dc <main+0x23c>
mov    0x2bf4(%rip),%rax
mov    (%rax),%edi
lea    0xdc5(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2bd5(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1030 <clock_gettime@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    -0x1c(%rbp),%eax
sub    %edx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x3c,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x1c(%rbp)
mov    0x2b8e(%rip),%rax
mov    (%rax),%edi
mov    0x2bb5(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   10c0 <clock_nanosleep@plt>
mov    -0x39(%rbp),%al
mov    -0x38(%rbp),%esi
movzbl %al,%edi
call   1050 <outb@plt>
mov    0x2b61(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x18(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x28(%rbp)
imul   $0x3e8,-0x14(%rbp),%eax
cltq
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%edi
call   1080 <parity@plt>
shl    $0x2a,%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    14c8 <main+0x328>
mov    -0x40(%rbp),%eax
shl    $0x2b,%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x40(%rbp),%edi
call   1080 <parity@plt>
shl    $0x30,%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0xe4e1c0,-0x18(%rbp)
mov    0x2adb(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
lea    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   10c0 <clock_nanosleep@plt>
mov    -0x38(%rbp),%esi
xor    %edi,%edi
call   1050 <outb@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x8(%rbp),%esi
mov    $0x2b,%ecx
mov    $0x31,%edx
cmp    $0x4,%esi
cmove  %edx,%ecx
cmp    %ecx,%eax
jge    15a0 <main+0x400>
mov    -0x28(%rbp),%rax
and    $0x1,%rax
shl    $0x1,%rax
add    $0x1,%rax
imul   $0xe4e1c0,%rax,%rax
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    0x2a6e(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
lea    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   10c0 <clock_nanosleep@plt>
mov    -0x39(%rbp),%al
mov    -0x38(%rbp),%esi
movzbl %al,%edi
call   1050 <outb@plt>
movl   $0xe4e1c0,-0x18(%rbp)
mov    0x2a41(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
lea    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   10c0 <clock_nanosleep@plt>
mov    -0x38(%rbp),%esi
xor    %edi,%edi
call   1050 <outb@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    14ff <main+0x35f>
jmp    141a <main+0x27a>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edi,%ebp
lea    -0x5(%rbp),%eax
cmp    $0xfffffffd,%eax
ja     11e0 <main+0x30>
add    $0xffffffff,%ebp
lea    0xe2e(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1284 <main+0xd4>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe4f(%rip),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
jne    126f <main+0xbf>
mov    0x10(%rbx),%rdi
lea    0xe36(%rip),%rsi
lea    0x3(%rsp),%rdx
xor    %eax,%eax
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
jne    1278 <main+0xc8>
cmp    $0x4,%ebp
jne    1240 <main+0x90>
mov    0x18(%rbx),%rdi
lea    0xe12(%rip),%rsi
lea    0x24(%rsp),%rdx
xor    %eax,%eax
call   10c0 <sscanf@plt>
cmp    $0x1,%eax
jne    12e4 <main+0x134>
mov    0x4(%rsp),%edi
mov    $0x1,%ebx
mov    $0x1,%esi
mov    $0x1,%edx
call   10a0 <ioperm@plt>
test   %rax,%rax
je     129e <main+0xee>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
lea    0xdd8(%rip),%rsi
jmp    12db <main+0x12b>
lea    0xf07(%rip),%rdi
jmp    127f <main+0xcf>
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d3d(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x4(%rsp),%esi
xor    %edi,%edi
call   1060 <outb@plt>
movl   $0x14,0x8(%rsp)
mov    0x2d28(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
xor    %edi,%edi
call   1080 <sched_setscheduler@plt>
test   %rax,%rax
je     12ed <main+0x13d>
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
lea    0xdaa(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    128d <main+0xdd>
lea    0xe2b(%rip),%rdi
jmp    127f <main+0xcf>
movl   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   1070 <sched_getparam@plt>
mov    0x2cb8(%rip),%rbx
mov    (%rbx),%edi
mov    0x8(%rsp),%edx
lea    0xd89(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    (%rbx),%edi
mov    0x4(%rsp),%edx
movzbl 0x3(%rsp),%ecx
lea    0xd97(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    (%rbx),%edi
cmp    $0x4,%ebp
jne    1358 <main+0x1a8>
mov    0x24(%rsp),%edx
lea    0xda8(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
movl   $0x31,0x20(%rsp)
jmp    136e <main+0x1be>
lea    0xd9d(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
movl   $0x2b,0x20(%rsp)
mov    0x2c43(%rip),%r14
mov    (%r14),%edi
lea    0x10(%rsp),%rsi
call   1040 <clock_gettime@plt>
movl   $0x0,0x10(%rsp)
mov    0x14(%rsp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
imul   $0xffffffff88888889,%rcx,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x3c,%eax,%eax
add    $0x3c,%eax
lea    0x18(%rsp),%r12
mov    %rbp,%r15
xchg   %ax,%ax
add    $0xa,%eax
mov    %eax,0x14(%rsp)
mov    (%r14),%edi
mov    0x2c17(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
xor    %ecx,%ecx
call   10d0 <clock_nanosleep@plt>
movzbl 0x3(%rsp),%edi
mov    0x4(%rsp),%esi
call   1060 <outb@plt>
mov    (%r14),%edi
mov    %r12,%rsi
call   1040 <clock_gettime@plt>
movslq 0x18(%rsp),%rax
imul   $0x431bde83,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x32,%rax
add    %ecx,%eax
cltq
movslq 0x1c(%rsp),%rcx
imul   $0x3e8,%rcx,%r13
add    %rax,%r13
mov    %r13d,%edi
call   1090 <parity@plt>
mov    %rax,%rbx
shl    $0x2a,%rbx
add    %r13,%rbx
cmp    $0x4,%ebp
jne    1456 <main+0x2a6>
mov    0x24(%rsp),%edi
mov    %rdi,%rbp
shl    $0x2b,%rbp
add    %rbx,%rbp
call   1090 <parity@plt>
mov    %rax,%rbx
shl    $0x30,%rbx
add    %rbp,%rbx
movq   $0xe4e1c0,0x18(%rsp)
mov    (%r14),%edi
xor    %esi,%esi
mov    %r12,%rdx
xor    %ecx,%ecx
call   10d0 <clock_nanosleep@plt>
mov    0x4(%rsp),%esi
xor    %edi,%edi
call   1060 <outb@plt>
mov    0x20(%rsp),%ebp
nopl   (%rax)
mov    %ebx,%eax
and    $0x1,%eax
add    %eax,%eax
add    $0x1,%eax
imul   $0xe4e1c0,%eax,%eax
mov    %eax,0x18(%rsp)
shr    %rbx
mov    (%r14),%edi
xor    %esi,%esi
mov    %r12,%rdx
xor    %ecx,%ecx
call   10d0 <clock_nanosleep@plt>
movzbl 0x3(%rsp),%edi
mov    0x4(%rsp),%esi
call   1060 <outb@plt>
movl   $0xe4e1c0,0x18(%rsp)
mov    (%r14),%edi
xor    %esi,%esi
mov    %r12,%rdx
xor    %ecx,%ecx
call   10d0 <clock_nanosleep@plt>
mov    0x4(%rsp),%esi
xor    %edi,%edi
call   1060 <outb@plt>
add    $0xffffffff,%ebp
jne    1480 <main+0x2d0>
mov    0x14(%rsp),%eax
mov    %r15,%rbp
jmp    13c0 <main+0x210>

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
%struct.sched_param = type { i32 }
@.str = [61 x i8] c"wrong number of parameters (%i instead of 2 or 3), aborting\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [53 x i8] c"cannot read the first argument (portbase), aborting\0A\00"
@.str.3 = [5 x i8] c"%hhu\00"
@.str.4 = [53 x i8] c"cannot read the second argument (outbits), aborting\0A\00"
@.str.5 = [52 x i8] c"cannot read the third argument (site ID), aborting\0A\00"
@stderr = global i32 0
@.str.6 = [64 x i8] c"Cannot get the port. Maybe you should run this program as root\0A\00"
@SCHED_FIFO = global i32 0
@.str.7 = [25 x i8] c"Cannot set new priority\0A\00"
@stdout = global i32 0
@.str.8 = [39 x i8] c"Running with new static priority = %i\0A\00"
@.str.9 = [42 x i8] c"LPT address: 0x%x, output bit mask: 0x%x\0A\00"
@.str.10 = [13 x i8] c"Site id: %i\0A\00"
@.str.11 = [26 x i8] c"Site id is not specified\0A\00"
@CLOCK_REALTIME = global i32 0
@TIMER_ABSTIME = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timespec
%7 = alloca %struct.timespec
%8 = alloca i64
%9 = alloca %struct.sched_param
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 4
br i1 %15, label %19, label %16
16: ; preds = %2
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 3
br i1 %18, label %19, label %24
19: ; preds = %16, %2
%20 = load i32, i32* %4
%21 = sub nsw i32 %20, 1
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %3
br label %188
24: ; preds = %16
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 (i8*, i8*, ...) @sscanf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %11)
%29 = icmp ne i32 %28, 1
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0))
%32 = load i32, i32* @EXIT_FAILURE
store i32 %32, i32* %3
br label %188
33: ; preds = %24
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32 (i8*, i8*, ...) @sscanf(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%38 = icmp ne i32 %37, 1
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
%41 = load i32, i32* @EXIT_FAILURE
store i32 %41, i32* %3
br label %188
42: ; preds = %33
%43 = load i32, i32* %4
%44 = icmp eq i32 %43, 4
br i1 %44, label %45, label %55
45: ; preds = %42
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 3
%48 = load i8*, i8** %47
%49 = call i32 (i8*, i8*, ...) @sscanf(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %13)
%50 = icmp ne i32 %49, 1
br i1 %50, label %51, label %54
51: ; preds = %45
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0))
%53 = load i32, i32* @EXIT_FAILURE
store i32 %53, i32* %3
br label %188
54: ; preds = %45
br label %55
55: ; preds = %54, %42
%56 = load i32, i32* %11
%57 = call i64 @ioperm(i32 %56, i32 1, i32 1)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %55
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %188
62: ; preds = %55
%63 = load i32, i32* %11
%64 = call i32 @outb(i8 zeroext 0, i32 %63)
%65 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %9, i32 0, i32 0
store i32 20, i32* %65
%66 = load i32, i32* @SCHED_FIFO
%67 = call i64 @sched_setscheduler(i32 0, i32 %66, %struct.sched_param* %9)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %62
%70 = load i32, i32* @stderr
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %188
72: ; preds = %62
%73 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %9, i32 0, i32 0
store i32 0, i32* %73
%74 = call i32 @sched_getparam(i32 0, %struct.sched_param* %9)
%75 = load i32, i32* @stdout
%76 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %9, i32 0, i32 0
%77 = load i32, i32* %76
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i32 %77)
%79 = load i32, i32* @stdout
%80 = load i32, i32* %11
%81 = load i8, i8* %12
%82 = zext i8 %81 to i32
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i32 %80, i32 %82)
%84 = load i32, i32* %4
%85 = icmp eq i32 %84, 4
br i1 %85, label %86, label %90
86: ; preds = %72
%87 = load i32, i32* @stdout
%88 = load i32, i32* %13
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i32 %88)
br label %93
90: ; preds = %72
%91 = load i32, i32* @stdout
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
br label %93
93: ; preds = %90, %86
%94 = load i32, i32* @CLOCK_REALTIME
%95 = call i32 @clock_gettime(i32 %94, %struct.timespec* %7)
%96 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 0
store i32 0, i32* %96
%97 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 1
%98 = load i32, i32* %97
%99 = add nsw i32 %98, 1
store i32 %99, i32* %97
%100 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 1
%101 = load i32, i32* %100
%102 = srem i32 %101, 60
%103 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 1
%104 = load i32, i32* %103
%105 = sub nsw i32 %104, %102
store i32 %105, i32* %103
%106 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 1
%107 = load i32, i32* %106
%108 = add nsw i32 %107, 60
store i32 %108, i32* %106
br label %109
109: ; preds = %93, %187
%110 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 1
%111 = load i32, i32* %110
%112 = add nsw i32 %111, 10
store i32 %112, i32* %110
%113 = load i32, i32* @CLOCK_REALTIME
%114 = load i32, i32* @TIMER_ABSTIME
%115 = call i32 @clock_nanosleep(i32 %113, i32 %114, %struct.timespec* %7, i32* null)
%116 = load i8, i8* %12
%117 = load i32, i32* %11
%118 = call i32 @outb(i8 zeroext %116, i32 %117)
%119 = load i32, i32* @CLOCK_REALTIME
%120 = call i32 @clock_gettime(i32 %119, %struct.timespec* %6)
%121 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
%122 = load i32, i32* %121
%123 = sdiv i32 %122, 1000000
%124 = sext i32 %123 to i64
store i64 %124, i64* %8
%125 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
%126 = load i32, i32* %125
%127 = mul nsw i32 %126, 1000
%128 = sext i32 %127 to i64
%129 = load i64, i64* %8
%130 = add i64 %129, %128
store i64 %130, i64* %8
%131 = load i64, i64* %8
%132 = trunc i64 %131 to i32
%133 = call i64 @parity(i32 %132)
%134 = shl i64 %133, 42
%135 = load i64, i64* %8
%136 = add i64 %135, %134
store i64 %136, i64* %8
%137 = load i32, i32* %4
%138 = icmp eq i32 %137, 4
br i1 %138, label %139, label %150
139: ; preds = %109
%140 = load i32, i32* %13
%141 = zext i32 %140 to i64
%142 = shl i64 %141, 43
%143 = load i64, i64* %8
%144 = add i64 %143, %142
store i64 %144, i64* %8
%145 = load i32, i32* %13
%146 = call i64 @parity(i32 %145)
%147 = shl i64 %146, 48
%148 = load i64, i64* %8
%149 = add i64 %148, %147
store i64 %149, i64* %8
br label %150
150: ; preds = %139, %109
%151 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
store i32 0, i32* %151
%152 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
store i32 15000000, i32* %152
%153 = load i32, i32* @CLOCK_REALTIME
%154 = call i32 @clock_nanosleep(i32 %153, i32 0, %struct.timespec* %6, i32* null)
%155 = load i32, i32* %11
%156 = call i32 @outb(i8 zeroext 0, i32 %155)
store i32 0, i32* %10
br label %157
157: ; preds = %184, %150
%158 = load i32, i32* %10
%159 = load i32, i32* %4
%160 = icmp eq i32 %159, 4
%161 = zext i1 %160 to i64
%162 = select i1 %160, i32 49, i32 43
%163 = icmp slt i32 %158, %162
br i1 %163, label %164, label %187
164: ; preds = %157
%165 = load i64, i64* %8
%166 = urem i64 %165, 2
%167 = mul i64 2, %166
%168 = add i64 1, %167
%169 = mul i64 %168, 15000000
%170 = trunc i64 %169 to i32
%171 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
store i32 %170, i32* %171
%172 = load i64, i64* %8
%173 = udiv i64 %172, 2
store i64 %173, i64* %8
%174 = load i32, i32* @CLOCK_REALTIME
%175 = call i32 @clock_nanosleep(i32 %174, i32 0, %struct.timespec* %6, i32* null)
%176 = load i8, i8* %12
%177 = load i32, i32* %11
%178 = call i32 @outb(i8 zeroext %176, i32 %177)
%179 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
store i32 15000000, i32* %179
%180 = load i32, i32* @CLOCK_REALTIME
%181 = call i32 @clock_nanosleep(i32 %180, i32 0, %struct.timespec* %6, i32* null)
%182 = load i32, i32* %11
%183 = call i32 @outb(i8 zeroext 0, i32 %182)
br label %184
184: ; preds = %164
%185 = load i32, i32* %10
%186 = add nsw i32 %185, 1
store i32 %186, i32* %10
br label %157
187: ; preds = %157
br label %109
188: ; preds = %69, %59, %51, %39, %30, %19
%189 = load i32, i32* %3
ret i32 %189
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
%struct.sched_param = type { i32 }
@.str = [61 x i8] c"wrong number of parameters (%i instead of 2 or 3), aborting\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"%u\00"
@.str.3 = [5 x i8] c"%hhu\00"
@stderr = global i32 0
@.str.6 = [64 x i8] c"Cannot get the port. Maybe you should run this program as root\0A\00"
@SCHED_FIFO = global i32 0
@.str.7 = [25 x i8] c"Cannot set new priority\0A\00"
@stdout = global i32 0
@.str.8 = [39 x i8] c"Running with new static priority = %i\0A\00"
@.str.9 = [42 x i8] c"LPT address: 0x%x, output bit mask: 0x%x\0A\00"
@.str.10 = [13 x i8] c"Site id: %i\0A\00"
@.str.11 = [26 x i8] c"Site id is not specified\0A\00"
@CLOCK_REALTIME = global i32 0
@TIMER_ABSTIME = global i32 0
@str = [51 x i8] c"cannot read the third argument (site ID), aborting\00"
@str.12 = [52 x i8] c"cannot read the second argument (outbits), aborting\00"
@str.13 = [52 x i8] c"cannot read the first argument (portbase), aborting\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timespec
%4 = alloca %struct.timespec
%5 = alloca %struct.sched_param
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32
%9 = bitcast %struct.timespec* %3 to i8*
%10 = bitcast %struct.timespec* %4 to i8*
%11 = bitcast %struct.sched_param* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = bitcast i32* %8 to i8*
%14 = add i32 %0, -5
%15 = icmp ult i32 %14, -2
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = add nsw i32 %0, -1
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @EXIT_FAILURE
br label %150
20: ; preds = %2
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = call i32 (i8*, i8*, ...) @sscanf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%24 = icmp eq i32 %23, 1
br i1 %24, label %28, label %25
25: ; preds = %20
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.13, i64 0, i64 0))
%27 = load i32, i32* @EXIT_FAILURE
br label %150
28: ; preds = %20
%29 = getelementptr inbounds i8*, i8** %1, i64 2
%30 = load i8*, i8** %29
%31 = call i32 (i8*, i8*, ...) @sscanf(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%32 = icmp eq i32 %31, 1
br i1 %32, label %36, label %33
33: ; preds = %28
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.12, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
br label %150
36: ; preds = %28
%37 = icmp eq i32 %0, 4
br i1 %37, label %38, label %46
38: ; preds = %36
%39 = getelementptr inbounds i8*, i8** %1, i64 3
%40 = load i8*, i8** %39
%41 = call i32 (i8*, i8*, ...) @sscanf(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%42 = icmp eq i32 %41, 1
br i1 %42, label %46, label %43
43: ; preds = %38
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%45 = load i32, i32* @EXIT_FAILURE
br label %150
46: ; preds = %38, %36
%47 = load i32, i32* %6
%48 = call i64 @ioperm(i32 %47, i32 1, i32 1)
%49 = icmp eq i64 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %46
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.6, i64 0, i64 0))
br label %150
53: ; preds = %46
%54 = load i32, i32* %6
%55 = call i32 @outb(i8 zeroext 0, i32 %54)
%56 = getelementptr inbounds %struct.sched_param, %struct.sched_param* %5, i64 0, i32 0
store i32 20, i32* %56
%57 = load i32, i32* @SCHED_FIFO
%58 = call i64 @sched_setscheduler(i32 0, i32 %57, %struct.sched_param* %5)
%59 = icmp eq i64 %58, 0
br i1 %59, label %63, label %60
60: ; preds = %53
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
br label %150
63: ; preds = %53
store i32 0, i32* %56
%64 = call i32 @sched_getparam(i32 0, %struct.sched_param* %5)
%65 = load i32, i32* @stdout
%66 = load i32, i32* %56
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i32 %66)
%68 = load i32, i32* @stdout
%69 = load i32, i32* %6
%70 = load i8, i8* %7
%71 = zext i8 %70 to i32
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i32 %69, i32 %71)
%73 = load i32, i32* @stdout
br i1 %37, label %74, label %77
74: ; preds = %63
%75 = load i32, i32* %8
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i32 %75)
br label %79
77: ; preds = %63
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
br label %79
79: ; preds = %77, %74
%80 = phi i32 [ 43, %77 ], [ 49, %74 ]
%81 = load i32, i32* @CLOCK_REALTIME
%82 = call i32 @clock_gettime(i32 %81, %struct.timespec* %4)
%83 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 0
store i32 0, i32* %83
%84 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 1
%85 = load i32, i32* %84
%86 = add nsw i32 %85, 1
%87 = srem i32 %86, 60
%88 = add i32 %85, 61
%89 = sub i32 %88, %87
%90 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%91 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
br label %94
92: ; preds = %130
%93 = load i32, i32* %84
br label %94
94: ; preds = %92, %79
%95 = phi i32 [ %93, %92 ], [ %89, %79 ]
%96 = add nsw i32 %95, 10
store i32 %96, i32* %84
%97 = load i32, i32* @CLOCK_REALTIME
%98 = load i32, i32* @TIMER_ABSTIME
%99 = call i32 @clock_nanosleep(i32 %97, i32 %98, %struct.timespec* %4, i32* null)
%100 = load i8, i8* %7
%101 = load i32, i32* %6
%102 = call i32 @outb(i8 zeroext %100, i32 %101)
%103 = load i32, i32* @CLOCK_REALTIME
%104 = call i32 @clock_gettime(i32 %103, %struct.timespec* %3)
%105 = load i32, i32* %90
%106 = sdiv i32 %105, 1000000
%107 = sext i32 %106 to i64
%108 = load i32, i32* %91
%109 = mul nsw i32 %108, 1000
%110 = sext i32 %109 to i64
%111 = add nsw i64 %110, %107
%112 = trunc i64 %111 to i32
%113 = call i64 @parity(i32 %112)
%114 = shl i64 %113, 42
%115 = add i64 %111, %114
br i1 %37, label %116, label %124
116: ; preds = %94
%117 = load i32, i32* %8
%118 = zext i32 %117 to i64
%119 = shl i64 %118, 43
%120 = add i64 %119, %115
%121 = call i64 @parity(i32 %117)
%122 = shl i64 %121, 48
%123 = add i64 %120, %122
br label %124
124: ; preds = %116, %94
%125 = phi i64 [ %123, %116 ], [ %115, %94 ]
store i32 0, i32* %91
store i32 15000000, i32* %90
%126 = load i32, i32* @CLOCK_REALTIME
%127 = call i32 @clock_nanosleep(i32 %126, i32 0, %struct.timespec* %3, i32* null)
%128 = load i32, i32* %6
%129 = call i32 @outb(i8 zeroext 0, i32 %128)
br label %130
130: ; preds = %124, %130
%131 = phi i32 [ 0, %124 ], [ %148, %130 ]
%132 = phi i64 [ %125, %124 ], [ %138, %130 ]
%133 = trunc i64 %132 to i32
%134 = shl i32 %133, 1
%135 = and i32 %134, 2
%136 = or i32 %135, 1
%137 = mul nuw nsw i32 %136, 15000000
store i32 %137, i32* %90
%138 = lshr i64 %132, 1
%139 = load i32, i32* @CLOCK_REALTIME
%140 = call i32 @clock_nanosleep(i32 %139, i32 0, %struct.timespec* %3, i32* null)
%141 = load i8, i8* %7
%142 = load i32, i32* %6
%143 = call i32 @outb(i8 zeroext %141, i32 %142)
store i32 15000000, i32* %90
%144 = load i32, i32* @CLOCK_REALTIME
%145 = call i32 @clock_nanosleep(i32 %144, i32 0, %struct.timespec* %3, i32* null)
%146 = load i32, i32* %6
%147 = call i32 @outb(i8 zeroext 0, i32 %146)
%148 = add nuw nsw i32 %131, 1
%149 = icmp eq i32 %148, %80
br i1 %149, label %92, label %130
150: ; preds = %60, %50, %43, %33, %25, %16
%151 = phi i32 [ %19, %16 ], [ %27, %25 ], [ %35, %33 ], [ %45, %43 ], [ 1, %50 ], [ 1, %60 ]
ret i32 %151
}