#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 */
typedef scalar_t__ time_t;
struct termios {
  int c_cflag;
  scalar_t__ *c_cc;
  scalar_t__ c_oflag;
  scalar_t__ c_lflag;
  int /*<<< orphan*/ c_iflag;
};
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ B115200;
int CLOCAL;
int CREAD;
int CS8;
int /*<<< orphan*/ INPCK;
int O_NOCTTY;
int O_NONBLOCK;
int O_RDWR;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ bzero(unsigned char *, int);
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int open(char *, int);
double pow(double, double);
int /*<<< orphan*/ printf(char *, ...);
double sin(double);
int /*<<< orphan*/ tcdrain(int);
int /*<<< orphan*/ tcgetattr(int, struct termios *);
int /*<<< orphan*/ tcsetattr(int, int /*<<< orphan*/, struct termios *);
scalar_t__ time(int /*<<< orphan*/ *);
int write(int, unsigned char *, int);
int main(int argc, char *argv[]) {
  int fd, i, bytesToGo, bytesSent, totalBytesSent = 0, frame = 0, hue1, hue2,
                                   brightness;
  unsigned char buffer[6 + (25 * 3)], lo, r, g, b;
  double sine1, sine2;
  time_t t, start, prev;
  struct termios tty;
  if (argc < 2) {
    (void)printf("Usage: %s device\n", argv[0]);
    return 1;
  }
  if ((fd = open(argv[1], O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0) {
    (void)printf("Can't open device '%s'.\n", argv[1]);
    return 1;
  }
  tcgetattr(fd, &tty);
  tty.c_iflag = INPCK;
  tty.c_lflag = 0;
  tty.c_oflag = 0;
  tty.c_cflag = CREAD | CS8 | CLOCAL;
  tty.c_cc[VMIN] = 0;
  tty.c_cc[VTIME] = 0;
  cfsetispeed(&tty, B115200);
  cfsetospeed(&tty, B115200);
  tcsetattr(fd, TCSANOW, &tty);
  bzero(buffer, sizeof(buffer));
  buffer[0] = 'A';
  buffer[1] = 'd';
  buffer[2] = 'a';
  buffer[3] = (25 - 1) >> 8;
  buffer[4] = (25 - 1) & 0xff;
  buffer[5] = buffer[3] ^ buffer[4] ^ 0x55;
  sine1 = 0.0;
  hue1 = 0;
  prev = start = time(NULL);
  for (;;) {
    sine2 = sine1;
    hue2 = hue1;
    for (i = 6; i < sizeof(buffer);) {
      lo = hue2 & 255;
      switch ((hue2 >> 8) % 6) {
      case 0:
        r = 255;
        g = lo;
        b = 0;
        break;
      case 1:
        r = 255 - lo;
        g = 255;
        b = 0;
        break;
      case 2:
        r = 0;
        g = 255;
        b = lo;
        break;
      case 3:
        r = 0;
        g = 255 - lo;
        b = 255;
        break;
      case 4:
        r = lo;
        g = 0;
        b = 255;
        break;
      case 5:
        r = 255;
        g = 0;
        b = 255 - lo;
        break;
      }
      brightness = (int)(pow(0.5 + sin(sine2) * 0.5, 3.0) * 255.0);
      buffer[i++] = (r * brightness) / 255;
      buffer[i++] = (g * brightness) / 255;
      buffer[i++] = (b * brightness) / 255;
      hue2 += 40;
      sine2 += 0.3;
    }
    hue1 = (hue1 + 5) % 1536;
    sine1 -= .03;
    tcdrain(fd);
    for (bytesSent = 0, bytesToGo = sizeof(buffer); bytesToGo > 0;) {
      if ((i = write(fd, &buffer[bytesSent], bytesToGo)) > 0) {
        bytesToGo -= i;
        bytesSent += i;
      }
    }
    totalBytesSent += sizeof(buffer);
    frame++;
    if ((t = time(NULL)) != prev) {
      (void)printf("Average frames/sec: %d, bytes/sec: %d\n",
                   (int)((float)frame / (float)(t - start)),
                   (int)((float)totalBytesSent / (float)(t - start)));
      prev = t;
    }
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1212 <main+0x52>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16f2 <main+0x532>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dc7(%rip),%rax
mov    (%rax),%esi
mov    0x2d86(%rip),%rax
or     (%rax),%esi
mov    0x2dad(%rip),%rax
or     (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1268 <main+0xa8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16f2 <main+0x532>
mov    -0x14(%rbp),%edi
lea    -0xe8(%rbp),%rsi
call   1090 <tcgetattr@plt>
mov    0x2d2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc8(%rbp)
movq   $0x0,-0xd0(%rbp)
movq   $0x0,-0xd8(%rbp)
mov    0x2d2d(%rip),%rax
mov    (%rax),%eax
mov    0x2d1c(%rip),%rcx
or     (%rcx),%eax
mov    0x2cd3(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0xe8(%rbp)
mov    -0xe0(%rbp),%rax
mov    0x2cf5(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0xe0(%rbp),%rax
mov    0x2cb4(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2caa(%rip),%rax
mov    (%rax),%esi
lea    -0xe8(%rbp),%rdi
call   10c0 <cfsetispeed@plt>
mov    0x2c95(%rip),%rax
mov    (%rax),%esi
lea    -0xe8(%rbp),%rdi
call   1050 <cfsetospeed@plt>
mov    -0x14(%rbp),%edi
mov    0x2cb5(%rip),%rax
mov    (%rax),%esi
lea    -0xe8(%rbp),%rdx
call   10a0 <tcsetattr@plt>
lea    -0x90(%rbp),%rdi
mov    $0x51,%esi
call   10e0 <bzero@plt>
movb   $0x41,-0x90(%rbp)
movb   $0x64,-0x8f(%rbp)
movb   $0x61,-0x8e(%rbp)
movb   $0x0,-0x8d(%rbp)
movb   $0x18,-0x8c(%rbp)
movzbl -0x8d(%rbp),%eax
movzbl -0x8c(%rbp),%ecx
xor    %ecx,%eax
xor    $0x55,%eax
mov    %al,-0x8b(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movl   $0x0,-0x2c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %rax,-0xb8(%rbp)
mov    %rax,-0xc0(%rbp)
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0xa8(%rbp)
ff
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
movl   $0x6,-0x18(%rbp)
movslq -0x18(%rbp),%rax
cmp    $0x51,%rax
jae    15d5 <main+0x415>
mov    -0x30(%rbp),%al
mov    %al,-0x91(%rbp)
mov    -0x30(%rbp),%eax
sar    $0x8,%eax
movslq %eax,%rcx
imul   $0x2aaaaaab,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rdx
add    %ecx,%edx
add    %edx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,%ecx
mov    %rcx,-0xf0(%rbp)
sub    $0x5,%eax
ja     14f7 <main+0x337>
mov    -0xf0(%rbp),%rax
lea    0xc07(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0xff,-0x92(%rbp)
mov    -0x91(%rbp),%al
mov    %al,-0x93(%rbp)
movb   $0x0,-0x94(%rbp)
jmp    14f7 <main+0x337>
movzbl -0x91(%rbp),%ecx
mov    $0xff,%eax
sub    %ecx,%eax
mov    %al,-0x92(%rbp)
movb   $0xff,-0x93(%rbp)
movb   $0x0,-0x94(%rbp)
jmp    14f7 <main+0x337>
movb   $0x0,-0x92(%rbp)
movb   $0xff,-0x93(%rbp)
mov    -0x91(%rbp),%al
mov    %al,-0x94(%rbp)
jmp    14f7 <main+0x337>
movb   $0x0,-0x92(%rbp)
movzbl -0x91(%rbp),%ecx
mov    $0xff,%eax
sub    %ecx,%eax
mov    %al,-0x93(%rbp)
movb   $0xff,-0x94(%rbp)
jmp    14f7 <main+0x337>
mov    -0x91(%rbp),%al
mov    %al,-0x92(%rbp)
movb   $0x0,-0x93(%rbp)
movb   $0xff,-0x94(%rbp)
jmp    14f7 <main+0x337>
movb   $0xff,-0x92(%rbp)
movb   $0x0,-0x93(%rbp)
movzbl -0x91(%rbp),%ecx
mov    $0xff,%eax
sub    %ecx,%eax
mov    %al,-0x94(%rbp)
movsd  -0xa8(%rbp),%xmm0
ff
call   1070 <sin@plt>
movsd  0xb14(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
movsd  0xafc(%rip),%xmm1
call   10d0 <pow@plt>
movsd  0xae7(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x34(%rbp)
movzbl -0x92(%rbp),%eax
imul   -0x34(%rbp),%eax
mov    $0xff,%ecx
cltd
idiv   %ecx
mov    %al,%cl
mov    -0x18(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
cltq
mov    %cl,-0x90(%rbp,%rax,1)
movzbl -0x93(%rbp),%eax
imul   -0x34(%rbp),%eax
mov    $0xff,%ecx
cltd
idiv   %ecx
mov    %al,%cl
mov    -0x18(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
cltq
mov    %cl,-0x90(%rbp,%rax,1)
movzbl -0x94(%rbp),%eax
imul   -0x34(%rbp),%eax
mov    $0xff,%ecx
cltd
idiv   %ecx
mov    %al,%cl
mov    -0x18(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
cltq
mov    %cl,-0x90(%rbp,%rax,1)
mov    -0x30(%rbp),%eax
add    $0x28,%eax
mov    %eax,-0x30(%rbp)
movsd  0xa48(%rip),%xmm0
addsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0xa8(%rbp)
ff
jmp    13c4 <main+0x204>
mov    -0x2c(%rbp),%eax
add    $0x5,%eax
mov    $0x600,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
movsd  -0xa0(%rbp),%xmm0
ff
movsd  0xa0a(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
mov    -0x14(%rbp),%edi
call   1030 <tcdrain@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x51,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1660 <main+0x4a0>
mov    -0x14(%rbp),%edi
movslq -0x20(%rbp),%rax
lea    -0x90(%rbp),%rsi
add    %rax,%rsi
mov    -0x1c(%rbp),%edx
call   1040 <write@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jle    165b <main+0x49b>
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1618 <main+0x458>
movslq -0x24(%rbp),%rax
add    $0x51,%rax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %rax,-0xb0(%rbp)
cmp    -0xc0(%rbp),%rax
je     16ed <main+0x52d>
cvtsi2ssl -0x28(%rbp),%xmm0
mov    -0xb0(%rbp),%rax
sub    -0xb8(%rbp),%rax
cvtsi2ss %rax,%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
cvtsi2ssl -0x24(%rbp),%xmm0
mov    -0xb0(%rbp),%rax
sub    -0xb8(%rbp),%rax
cvtsi2ss %rax,%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edx
lea    0x993(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xb0(%rbp),%rax
mov    %rax,-0xc0(%rbp)
jmp    13a7 <main+0x1e7>
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %rsi,%r14
cmp    $0x2,%edi
jge    11e5 <main+0x25>
lea    0xe60(%rip),%rdi
jmp    15aa <main+0x3ea>
mov    0x2dfc(%rip),%rax
mov    0x2dbd(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x8(%r14),%rdi
mov    0x2dde(%rip),%rax
or     (%rax),%esi
call   10b0 <open@plt>
test   %eax,%eax
js     159f <main+0x3df>
mov    %eax,%ebp
lea    0x38(%rsp),%r15
mov    %eax,%edi
mov    %r15,%rsi
call   1090 <tcgetattr@plt>
mov    0x2d7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x58(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x48(%rsp)
mov    0x2d92(%rip),%rax
mov    0x2d83(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2d38(%rip),%rax
or     (%rax),%ecx
mov    %ecx,0x38(%rsp)
mov    0x40(%rsp),%rax
mov    0x2d5e(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2d24(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2d1a(%rip),%rbx
mov    (%rbx),%esi
mov    %r15,%rdi
call   10c0 <cfsetispeed@plt>
mov    (%rbx),%esi
mov    %r15,%rdi
call   1050 <cfsetospeed@plt>
mov    0x2d37(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%r14d
mov    %ebp,%edi
mov    %r15,%rdx
call   10a0 <tcsetattr@plt>
lea    0x60(%rsp),%rdi
mov    $0x51,%esi
call   10e0 <bzero@plt>
movl   $0x616441,0x60(%rsp)
movw   $0x4d18,0x64(%rsp)
xor    %edi,%edi
call   1080 <time@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %ecx,%ecx
mov    %rcx,0x10(%rsp)
mov    %ecx,0x8(%rsp)
mov    %rax,0x28(%rsp)
mov    %rax,0x20(%rsp)
mov    %r14d,0x18(%rsp)
nopl   0x0(%rax,%rax,1)
movsd  (%rsp),%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,0x1c(%rsp)
mov    %rbx,0x30(%rsp)
mov    0x10(%rsp),%rax
mov    %eax,%ebx
not    %bl
mov    $0x8,%ebp
movsd  %xmm0,(%rsp)
mov    %eax,%r13d
mov    0x8(%rsp),%r14d
jmp    1423 <main+0x263>
mov    $0xff,%r14b
xor    %r15d,%r15d
mov    %ebx,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
call   1070 <sin@plt>
movsd  0xc97(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
movsd  0xc8f(%rip),%xmm1
call   10d0 <pow@plt>
mulsd  0xc8a(%rip),%xmm0
cvttsd2si %xmm0,%eax
movsd  0x8(%rsp),%xmm0
movzbl %r14b,%ecx
imul   %eax,%ecx
movslq %ecx,%rcx
imul   $0xffffffff80808081,%rcx,%rdx
shr    $0x20,%rdx
add    %edx,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
shr    $0x7,%ecx
add    %edx,%ecx
mov    %cl,0x5e(%rsp,%rbp,1)
movzbl %r15b,%ecx
imul   %eax,%ecx
movslq %ecx,%rcx
imul   $0xffffffff80808081,%rcx,%rdx
shr    $0x20,%rdx
add    %edx,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
shr    $0x7,%ecx
add    %edx,%ecx
mov    %cl,0x5f(%rsp,%rbp,1)
movzbl %r12b,%ecx
imul   %eax,%ecx
movslq %ecx,%rax
imul   $0xffffffff80808081,%rax,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
shr    $0x7,%eax
add    %ecx,%eax
mov    %al,0x60(%rsp,%rbp,1)
add    $0x28,%r13d
addsd  0xc0d(%rip),%xmm0
lea    0x3(%rbp),%rax
add    $0xfffffffffffffffe,%rbp
add    $0xd8,%bl
cmp    $0x4e,%rbp
mov    %rax,%rbp
jae    14b0 <main+0x2f0>
mov    %r13d,%eax
sar    $0x8,%eax
cltq
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
cmp    $0x5,%eax
ja     1350 <main+0x190>
lea    0xbd2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0xff,%r14b
xor    %r12d,%r12d
mov    %r13d,%r15d
jmp    1350 <main+0x190>
mov    $0xff,%r15b
xor    %r12d,%r12d
mov    %ebx,%r14d
jmp    1350 <main+0x190>
mov    $0xff,%r15b
xor    %r14d,%r14d
mov    %r13d,%r12d
jmp    1350 <main+0x190>
mov    $0xff,%r12b
xor    %r14d,%r14d
mov    %ebx,%r15d
jmp    1350 <main+0x190>
mov    $0xff,%r12b
xor    %r15d,%r15d
mov    %r13d,%r14d
jmp    1350 <main+0x190>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14d,0x8(%rsp)
mov    0x10(%rsp),%rdx
add    $0x5,%edx
movslq %edx,%rdx
imul   $0x2aaaaaab,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x28,%rax
add    %ecx,%eax
shl    $0x9,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%edx
mov    %rdx,0x10(%rsp)
mov    0x18(%rsp),%r14d
mov    %r14d,%edi
call   1030 <tcdrain@plt>
xor    %ebx,%ebx
mov    $0x51,%ebp
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
lea    (%rsp,%rax,1),%rsi
add    $0x60,%rsi
mov    %r14d,%edi
mov    %ebp,%edx
call   1040 <write@plt>
test   %eax,%eax
cmovs  %r13d,%eax
add    %eax,%ebx
sub    %eax,%ebp
jg     1500 <main+0x340>
movsd  (%rsp),%xmm0
addsd  0xaf3(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    0x30(%rsp),%rbx
movslq %ebx,%rbx
add    $0x51,%rbx
mov    0x1c(%rsp),%ebp
add    $0x1,%ebp
xor    %edi,%edi
call   1080 <time@plt>
movsd  (%rsp),%xmm0
cmp    0x20(%rsp),%rax
je     1310 <main+0x150>
mov    %rax,%r13
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
sub    0x28(%rsp),%rax
cvtsi2ss %rax,%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edx
lea    0xadd(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,0x20(%rsp)
jmp    1300 <main+0x140>
add    $0x8,%r14
lea    0xaa8(%rip),%rdi
mov    (%r14),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32, i64*, i64, i64, i32 }
@.str = [18 x i8] c"Usage: %s device\0A\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [25 x i8] c"Can't open device '%s'.\0A\00"
@INPCK = global i32 0
@CREAD = global i32 0
@CS8 = global i32 0
@CLOCAL = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@B115200 = global i32 0
@TCSANOW = global i32 0
@.str.2 = [39 x i8] c"Average frames/sec: %d, bytes/sec: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca [81 x i8]
%16 = alloca i8
%17 = alloca i8
%18 = alloca i8
%19 = alloca i8
%20 = alloca double
%21 = alloca double
%22 = alloca i64
%23 = alloca i64
%24 = alloca i64
%25 = alloca %struct.termios
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
store i32 0, i32* %11
%26 = load i32, i32* %4
%27 = icmp slt i32 %26, 2
br i1 %27, label %28, label %33
28: ; preds = %2
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %31)
store i32 1, i32* %3
br label %228
33: ; preds = %2
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = load i32, i32* @O_RDWR
%38 = load i32, i32* @O_NOCTTY
%39 = or i32 %37, %38
%40 = load i32, i32* @O_NONBLOCK
%41 = or i32 %39, %40
%42 = call i32 @open(i8* %36, i32 %41)
store i32 %42, i32* %6
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %33
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %47)
store i32 1, i32* %3
br label %228
49: ; preds = %33
%50 = load i32, i32* %6
%51 = call i32 @tcgetattr(i32 %50, %struct.termios* %25)
%52 = load i32, i32* @INPCK
%53 = getelementptr inbounds %struct.termios, %struct.termios* %25, i32 0, i32 4
store i32 %52, i32* %53
%54 = getelementptr inbounds %struct.termios, %struct.termios* %25, i32 0, i32 3
store i64 0, i64* %54
%55 = getelementptr inbounds %struct.termios, %struct.termios* %25, i32 0, i32 2
store i64 0, i64* %55
%56 = load i32, i32* @CREAD
%57 = load i32, i32* @CS8
%58 = or i32 %56, %57
%59 = load i32, i32* @CLOCAL
%60 = or i32 %58, %59
%61 = getelementptr inbounds %struct.termios, %struct.termios* %25, i32 0, i32 0
store i32 %60, i32* %61
%62 = getelementptr inbounds %struct.termios, %struct.termios* %25, i32 0, i32 1
%63 = load i64*, i64** %62
%64 = load i64, i64* @VMIN
%65 = getelementptr inbounds i64, i64* %63, i64 %64
store i64 0, i64* %65
%66 = getelementptr inbounds %struct.termios, %struct.termios* %25, i32 0, i32 1
%67 = load i64*, i64** %66
%68 = load i64, i64* @VTIME
%69 = getelementptr inbounds i64, i64* %67, i64 %68
store i64 0, i64* %69
%70 = load i32, i32* @B115200
%71 = call i32 @cfsetispeed(%struct.termios* %25, i32 %70)
%72 = load i32, i32* @B115200
%73 = call i32 @cfsetospeed(%struct.termios* %25, i32 %72)
%74 = load i32, i32* %6
%75 = load i32, i32* @TCSANOW
%76 = call i32 @tcsetattr(i32 %74, i32 %75, %struct.termios* %25)
%77 = getelementptr inbounds [81 x i8], [81 x i8]* %15, i64 0, i64 0
%78 = call i32 @bzero(i8* %77, i32 81)
%79 = getelementptr inbounds [81 x i8], [81 x i8]* %15, i64 0, i64 0
store i8 65, i8* %79
%80 = getelementptr inbounds [81 x i8], [81 x i8]* %15, i64 0, i64 1
store i8 100, i8* %80
%81 = getelementptr inbounds [81 x i8], [81 x i8]* %15, i64 0, i64 2
store i8 97, i8* %81
%82 = getelementptr inbounds [81 x i8], [81 x i8]* %15, i64 0, i64 3
store i8 0, i8* %82
%83 = getelementptr inbounds [81 x i8], [81 x i8]* %15, i64 0, i64 4
store i8 24, i8* %83
%84 = getelementptr inbounds [81 x i8], [81 x i8]* %15, i64 0, i64 3
%85 = load i8, i8* %84
%86 = zext i8 %85 to i32
%87 = getelementptr inbounds [81 x i8], [81 x i8]* %15, i64 0, i64 4
%88 = load i8, i8* %87
%89 = zext i8 %88 to i32
%90 = xor i32 %86, %89
%91 = xor i32 %90, 85
%92 = trunc i32 %91 to i8
%93 = getelementptr inbounds [81 x i8], [81 x i8]* %15, i64 0, i64 5
store i8 %92, i8* %93
store double 0.000000e+00, double* %20
store i32 0, i32* %12
%94 = call i64 @time(i32* null)
store i64 %94, i64* %23
store i64 %94, i64* %24
br label %95
95: ; preds = %227, %49
%96 = load double, double* %20
store double %96, double* %21
%97 = load i32, i32* %12
store i32 %97, i32* %13
store i32 6, i32* %7
br label %98
98: ; preds = %130, %95
%99 = load i32, i32* %7
%100 = sext i32 %99 to i64
%101 = icmp ult i64 %100, 81
br i1 %101, label %102, label %171
102: ; preds = %98
%103 = load i32, i32* %13
%104 = and i32 %103, 255
%105 = trunc i32 %104 to i8
store i8 %105, i8* %16
%106 = load i32, i32* %13
%107 = ashr i32 %106, 8
%108 = srem i32 %107, 6
switch i32 %108, label %130 [
i32 0, label %109
i32 1, label %111
i32 2, label %116
i32 3, label %118
i32 4, label %123
i32 5, label %125
]
109: ; preds = %102
store i8 -1, i8* %17
%110 = load i8, i8* %16
store i8 %110, i8* %18
store i8 0, i8* %19
br label %130
111: ; preds = %102
%112 = load i8, i8* %16
%113 = zext i8 %112 to i32
%114 = sub nsw i32 255, %113
%115 = trunc i32 %114 to i8
store i8 %115, i8* %17
store i8 -1, i8* %18
store i8 0, i8* %19
br label %130
116: ; preds = %102
store i8 0, i8* %17
store i8 -1, i8* %18
%117 = load i8, i8* %16
store i8 %117, i8* %19
br label %130
118: ; preds = %102
store i8 0, i8* %17
%119 = load i8, i8* %16
%120 = zext i8 %119 to i32
%121 = sub nsw i32 255, %120
%122 = trunc i32 %121 to i8
store i8 %122, i8* %18
store i8 -1, i8* %19
br label %130
123: ; preds = %102
%124 = load i8, i8* %16
store i8 %124, i8* %17
store i8 0, i8* %18
store i8 -1, i8* %19
br label %130
125: ; preds = %102
store i8 -1, i8* %17
store i8 0, i8* %18
%126 = load i8, i8* %16
%127 = zext i8 %126 to i32
%128 = sub nsw i32 255, %127
%129 = trunc i32 %128 to i8
store i8 %129, i8* %19
br label %130
130: ; preds = %102, %125, %123, %118, %116, %111, %109
%131 = load double, double* %21
%132 = call double @sin(double %131)
%133 = call double @llvm.fmuladd.f64(double %132, double 5.000000e-01, double 5.000000e-01)
%134 = call double @pow(double %133, double 3.000000e+00)
%135 = fmul double %134, 2.550000e+02
%136 = fptosi double %135 to i32
store i32 %136, i32* %14
%137 = load i8, i8* %17
%138 = zext i8 %137 to i32
%139 = load i32, i32* %14
%140 = mul nsw i32 %138, %139
%141 = sdiv i32 %140, 255
%142 = trunc i32 %141 to i8
%143 = load i32, i32* %7
%144 = add nsw i32 %143, 1
store i32 %144, i32* %7
%145 = sext i32 %143 to i64
%146 = getelementptr inbounds [81 x i8], [81 x i8]* %15, i64 0, i64 %145
store i8 %142, i8* %146
%147 = load i8, i8* %18
%148 = zext i8 %147 to i32
%149 = load i32, i32* %14
%150 = mul nsw i32 %148, %149
%151 = sdiv i32 %150, 255
%152 = trunc i32 %151 to i8
%153 = load i32, i32* %7
%154 = add nsw i32 %153, 1
store i32 %154, i32* %7
%155 = sext i32 %153 to i64
%156 = getelementptr inbounds [81 x i8], [81 x i8]* %15, i64 0, i64 %155
store i8 %152, i8* %156
%157 = load i8, i8* %19
%158 = zext i8 %157 to i32
%159 = load i32, i32* %14
%160 = mul nsw i32 %158, %159
%161 = sdiv i32 %160, 255
%162 = trunc i32 %161 to i8
%163 = load i32, i32* %7
%164 = add nsw i32 %163, 1
store i32 %164, i32* %7
%165 = sext i32 %163 to i64
%166 = getelementptr inbounds [81 x i8], [81 x i8]* %15, i64 0, i64 %165
store i8 %162, i8* %166
%167 = load i32, i32* %13
%168 = add nsw i32 %167, 40
store i32 %168, i32* %13
%169 = load double, double* %21
%170 = fadd double %169, 3.000000e-01
store double %170, double* %21
br label %98
171: ; preds = %98
%172 = load i32, i32* %12
%173 = add nsw i32 %172, 5
%174 = srem i32 %173, 1536
store i32 %174, i32* %12
%175 = load double, double* %20
%176 = fsub double %175, 3.000000e-02
store double %176, double* %20
%177 = load i32, i32* %6
%178 = call i32 @tcdrain(i32 %177)
store i32 0, i32* %9
store i32 81, i32* %8
br label %179
179: ; preds = %197, %171
%180 = load i32, i32* %8
%181 = icmp sgt i32 %180, 0
br i1 %181, label %182, label %198
182: ; preds = %179
%183 = load i32, i32* %6
%184 = load i32, i32* %9
%185 = sext i32 %184 to i64
%186 = getelementptr inbounds [81 x i8], [81 x i8]* %15, i64 0, i64 %185
%187 = load i32, i32* %8
%188 = call i32 @write(i32 %183, i8* %186, i32 %187)
store i32 %188, i32* %7
%189 = icmp sgt i32 %188, 0
br i1 %189, label %190, label %197
190: ; preds = %182
%191 = load i32, i32* %7
%192 = load i32, i32* %8
%193 = sub nsw i32 %192, %191
store i32 %193, i32* %8
%194 = load i32, i32* %7
%195 = load i32, i32* %9
%196 = add nsw i32 %195, %194
store i32 %196, i32* %9
br label %197
197: ; preds = %190, %182
br label %179
198: ; preds = %179
%199 = load i32, i32* %10
%200 = sext i32 %199 to i64
%201 = add i64 %200, 81
%202 = trunc i64 %201 to i32
store i32 %202, i32* %10
%203 = load i32, i32* %11
%204 = add nsw i32 %203, 1
store i32 %204, i32* %11
%205 = call i64 @time(i32* null)
store i64 %205, i64* %22
%206 = load i64, i64* %24
%207 = icmp ne i64 %205, %206
br i1 %207, label %208, label %227
208: ; preds = %198
%209 = load i32, i32* %11
%210 = sitofp i32 %209 to float
%211 = load i64, i64* %22
%212 = load i64, i64* %23
%213 = sub nsw i64 %211, %212
%214 = sitofp i64 %213 to float
%215 = fdiv float %210, %214
%216 = fptosi float %215 to i32
%217 = load i32, i32* %10
%218 = sitofp i32 %217 to float
%219 = load i64, i64* %22
%220 = load i64, i64* %23
%221 = sub nsw i64 %219, %220
%222 = sitofp i64 %221 to float
%223 = fdiv float %218, %222
%224 = fptosi float %223 to i32
%225 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %216, i32 %224)
%226 = load i64, i64* %22
store i64 %226, i64* %24
br label %227
227: ; preds = %208, %198
br label %95
228: ; preds = %44, %28
%229 = load i32, i32* %3
ret i32 %229
}

LLVM IR (-O2):
%struct.termios = type { i32, i64*, i64, i64, i32 }
@.str = [18 x i8] c"Usage: %s device\0A\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [25 x i8] c"Can't open device '%s'.\0A\00"
@INPCK = global i32 0
@CREAD = global i32 0
@CS8 = global i32 0
@CLOCAL = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@B115200 = global i32 0
@TCSANOW = global i32 0
@.str.2 = [39 x i8] c"Average frames/sec: %d, bytes/sec: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [81 x i8]
%4 = alloca %struct.termios
%5 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.termios* %4 to i8*
%7 = icmp slt i32 %0, 2
br i1 %7, label %149, label %8
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = load i32, i32* @O_RDWR
%12 = load i32, i32* @O_NOCTTY
%13 = or i32 %12, %11
%14 = load i32, i32* @O_NONBLOCK
%15 = or i32 %13, %14
%16 = tail call i32 @open(i8* %10, i32 %15)
%17 = icmp slt i32 %16, 0
br i1 %17, label %149, label %18
18: ; preds = %8
%19 = call i32 @tcgetattr(i32 %16, %struct.termios* %4)
%20 = load i32, i32* @INPCK
%21 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 4
store i32 %20, i32* %21
%22 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 2
%23 = bitcast i64* %22 to i8*
%24 = load i32, i32* @CREAD
%25 = load i32, i32* @CS8
%26 = or i32 %25, %24
%27 = load i32, i32* @CLOCAL
%28 = or i32 %26, %27
%29 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 0
store i32 %28, i32* %29
%30 = getelementptr inbounds %struct.termios, %struct.termios* %4, i64 0, i32 1
%31 = load i64*, i64** %30
%32 = load i64, i64* @VMIN
%33 = getelementptr inbounds i64, i64* %31, i64 %32
store i64 0, i64* %33
%34 = load i64, i64* @VTIME
%35 = getelementptr inbounds i64, i64* %31, i64 %34
store i64 0, i64* %35
%36 = load i32, i32* @B115200
%37 = call i32 @cfsetispeed(%struct.termios* %4, i32 %36)
%38 = load i32, i32* @B115200
%39 = call i32 @cfsetospeed(%struct.termios* %4, i32 %38)
%40 = load i32, i32* @TCSANOW
%41 = call i32 @tcsetattr(i32 %16, i32 %40, %struct.termios* %4)
%42 = call i32 @bzero(i8* %5, i32 81)
store i8 65, i8* %5
%43 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 1
store i8 100, i8* %43
%44 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 2
store i8 97, i8* %44
%45 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 3
store i8 0, i8* %45
%46 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 4
store i8 24, i8* %46
%47 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 5
store i8 77, i8* %47
%48 = call i64 @time(i32* null)
br label %49
49: ; preds = %138, %18
%50 = phi i64 [ %134, %138 ], [ 0, %18 ]
%51 = phi i32 [ %135, %138 ], [ 0, %18 ]
%52 = phi i32 [ %117, %138 ], [ 0, %18 ]
%53 = phi i8 [ %86, %138 ], [ undef, %18 ]
%54 = phi i8 [ %87, %138 ], [ undef, %18 ]
%55 = phi i8 [ %88, %138 ], [ undef, %18 ]
%56 = phi double [ %131, %138 ], [ 0.000000e+00, %18 ]
%57 = phi i64 [ %136, %138 ], [ %48, %18 ]
br label %58
58: ; preds = %49, %130
%59 = phi i64 [ %134, %130 ], [ %50, %49 ]
%60 = phi i32 [ %135, %130 ], [ %51, %49 ]
%61 = phi i32 [ %117, %130 ], [ %52, %49 ]
%62 = phi i8 [ %86, %130 ], [ %53, %49 ]
%63 = phi i8 [ %87, %130 ], [ %54, %49 ]
%64 = phi i8 [ %88, %130 ], [ %55, %49 ]
%65 = phi double [ %131, %130 ], [ %56, %49 ]
br label %66
66: ; preds = %58, %85
%67 = phi i64 [ 6, %58 ], [ %110, %85 ]
%68 = phi double [ %65, %58 ], [ %113, %85 ]
%69 = phi i8 [ %64, %58 ], [ %88, %85 ]
%70 = phi i8 [ %63, %58 ], [ %87, %85 ]
%71 = phi i8 [ %62, %58 ], [ %86, %85 ]
%72 = phi i32 [ %61, %58 ], [ %112, %85 ]
%73 = trunc i32 %72 to i8
%74 = ashr i32 %72, 8
%75 = srem i32 %74, 6
switch i32 %75, label %85 [
i32 0, label %76
i32 1, label %77
i32 2, label %79
i32 3, label %80
i32 4, label %82
i32 5, label %83
]
76: ; preds = %66
br label %85
77: ; preds = %66
%78 = xor i8 %73, -1
br label %85
79: ; preds = %66
br label %85
80: ; preds = %66
%81 = xor i8 %73, -1
br label %85
82: ; preds = %66
br label %85
83: ; preds = %66
%84 = xor i8 %73, -1
br label %85
85: ; preds = %66, %83, %82, %80, %79, %77, %76
%86 = phi i8 [ %71, %66 ], [ -1, %83 ], [ %73, %82 ], [ 0, %80 ], [ 0, %79 ], [ %78, %77 ], [ -1, %76 ]
%87 = phi i8 [ %70, %66 ], [ 0, %83 ], [ 0, %82 ], [ %81, %80 ], [ -1, %79 ], [ -1, %77 ], [ %73, %76 ]
%88 = phi i8 [ %69, %66 ], [ %84, %83 ], [ -1, %82 ], [ -1, %80 ], [ %73, %79 ], [ 0, %77 ], [ 0, %76 ]
%89 = call double @sin(double %68)
%90 = call double @llvm.fmuladd.f64(double %89, double 5.000000e-01, double 5.000000e-01)
%91 = call double @pow(double %90, double 3.000000e+00)
%92 = fmul double %91, 2.550000e+02
%93 = fptosi double %92 to i32
%94 = zext i8 %86 to i32
%95 = mul nsw i32 %93, %94
%96 = sdiv i32 %95, 255
%97 = trunc i32 %96 to i8
%98 = add nuw nsw i64 %67, 1
%99 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 %67
store i8 %97, i8* %99
%100 = zext i8 %87 to i32
%101 = mul nsw i32 %93, %100
%102 = sdiv i32 %101, 255
%103 = trunc i32 %102 to i8
%104 = add nuw nsw i64 %67, 2
%105 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 %98
store i8 %103, i8* %105
%106 = zext i8 %88 to i32
%107 = mul nsw i32 %93, %106
%108 = sdiv i32 %107, 255
%109 = trunc i32 %108 to i8
%110 = add nuw nsw i64 %67, 3
%111 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 %104
store i8 %109, i8* %111
%112 = add nsw i32 %72, 40
%113 = fadd double %68, 3.000000e-01
%114 = icmp ult i64 %67, 78
br i1 %114, label %66, label %115
115: ; preds = %85
%116 = add nsw i32 %61, 5
%117 = srem i32 %116, 1536
%118 = call i32 @tcdrain(i32 %16)
br label %119
119: ; preds = %115, %119
%120 = phi i32 [ 81, %115 ], [ %128, %119 ]
%121 = phi i32 [ 0, %115 ], [ %127, %119 ]
%122 = zext i32 %121 to i64
%123 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 %122
%124 = call i32 @write(i32 %16, i8* %123, i32 %120)
%125 = icmp sgt i32 %124, 0
%126 = select i1 %125, i32 %124, i32 0
%127 = add nuw nsw i32 %126, %121
%128 = sub nsw i32 %120, %126
%129 = icmp sgt i32 %128, 0
br i1 %129, label %119, label %130
130: ; preds = %119
%131 = fadd double %65, -3.000000e-02
%132 = shl i64 %59, 32
%133 = ashr exact i64 %132, 32
%134 = add nsw i64 %133, 81
%135 = add nuw nsw i32 %60, 1
%136 = call i64 @time(i32* null)
%137 = icmp eq i64 %136, %57
br i1 %137, label %58, label %138
138: ; preds = %130
%139 = trunc i64 %134 to i32
%140 = sitofp i32 %135 to float
%141 = sub nsw i64 %136, %48
%142 = sitofp i64 %141 to float
%143 = fdiv float %140, %142
%144 = fptosi float %143 to i32
%145 = sitofp i32 %139 to float
%146 = fdiv float %145, %142
%147 = fptosi float %146 to i32
%148 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %144, i32 %147)
br label %49
149: ; preds = %8, %2
%150 = phi i8** [ %1, %2 ], [ %9, %8 ]
%151 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), %8 ]
%152 = load i8*, i8** %150
%153 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %151, i8* %152)
ret i32 1
}