#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 timeb {
  scalar_t__ time;
};

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ ftime(struct timeb *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ stdout;
int main(void) {
  int i = 0;
  int x = 3, y = 1;
  struct timeb t1, t2;
  ftime(&t1);
  while (1) {
    ftime(&t2);
    while (t2.time >= t1.time + 1) {
      t1 = t2;
      printf("\033[%d;%dH\033[37m\033[47m[]", y, x);
      printf("\033[%d;%dH\033[35m\033[45m[]", ++y, x);
      fflush(stdout);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
call   1050 <ftime@plt>
lea    -0x20(%rbp),%rdi
call   1050 <ftime@plt>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jl     11c0 <main+0x90>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x10(%rbp)
mov    -0xc(%rbp),%edx
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
jmp    1166 <main+0x36>
jmp    115d <main+0x2d>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsp,%rdi
call   1050 <ftime@plt>
mov    $0x1,%ebx
lea    0x8(%rsp),%r14
lea    0xeaa(%rip),%r15
lea    0xeb8(%rip),%r12
mov    0x2e7c(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1050 <ftime@plt>
mov    0x8(%rsp),%rax
cmp    (%rsp),%rax
jle    1170 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rax,(%rsp)
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x3,%edx
call   1030 <printf@plt>
add    $0x1,%ebx
mov    %r12,%rdi
mov    %ebx,%esi
mov    $0x3,%edx
call   1030 <printf@plt>
mov    0x0(%r13),%edi
call   1040 <fflush@plt>
mov    0x8(%rsp),%rax
cmp    (%rsp),%rax
jg     1190 <main+0x60>
jmp    1170 <main+0x40>

LLVM IR (-O0):
%struct.timeb = type { i64 }
@.str = [21 x i8] c"\1B[%d;%dH\1B[37m\1B[47m[]\00"
@.str.1 = [21 x i8] c"\1B[%d;%dH\1B[35m\1B[45m[]\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.timeb
%6 = alloca %struct.timeb
store i32 0, i32* %1
store i32 0, i32* %2
store i32 3, i32* %3
store i32 1, i32* %4
%7 = call i32 @ftime(%struct.timeb* %5)
br label %8
8: ; preds = %0, %29
%9 = call i32 @ftime(%struct.timeb* %6)
br label %10
10: ; preds = %17, %8
%11 = getelementptr inbounds %struct.timeb, %struct.timeb* %6, i32 0, i32 0
%12 = load i64, i64* %11
%13 = getelementptr inbounds %struct.timeb, %struct.timeb* %5, i32 0, i32 0
%14 = load i64, i64* %13
%15 = add nsw i64 %14, 1
%16 = icmp sge i64 %12, %15
br i1 %16, label %17, label %29
17: ; preds = %10
%18 = bitcast %struct.timeb* %5 to i8*
%19 = bitcast %struct.timeb* %6 to i8*
%20 = load i32, i32* %4
%21 = load i32, i32* %3
%22 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21)
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
%25 = load i32, i32* %3
%26 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %25)
%27 = load i32, i32* @stdout
%28 = call i32 @fflush(i32 %27)
br label %10
29: ; preds = %10
br label %8
}

LLVM IR (-O2):
%struct.timeb = type { i64 }
@.str = [21 x i8] c"\1B[%d;%dH\1B[37m\1B[47m[]\00"
@.str.1 = [21 x i8] c"\1B[%d;%dH\1B[35m\1B[45m[]\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca %struct.timeb
%2 = alloca %struct.timeb
%3 = bitcast %struct.timeb* %1 to i8*
%4 = bitcast %struct.timeb* %2 to i8*
%5 = call i32 @ftime(%struct.timeb* %1)
%6 = getelementptr inbounds %struct.timeb, %struct.timeb* %2, i64 0, i32 0
%7 = getelementptr inbounds %struct.timeb, %struct.timeb* %1, i64 0, i32 0
br label %8
8: ; preds = %15, %0
%9 = phi i32 [ 1, %0 ], [ %19, %15 ]
br label %10
10: ; preds = %8, %10
%11 = call i32 @ftime(%struct.timeb* %2)
%12 = load i64, i64* %6
%13 = load i64, i64* %7
%14 = icmp sgt i64 %12, %13
br i1 %14, label %15, label %10
15: ; preds = %10, %15
%16 = phi i64 [ %23, %15 ], [ %12, %10 ]
%17 = phi i32 [ %19, %15 ], [ %9, %10 ]
store i64 %16, i64* %7
%18 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %17, i32 3)
%19 = add nsw i32 %17, 1
%20 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 3)
%21 = load i32, i32* @stdout
%22 = call i32 @fflush(i32 %21)
%23 = load i64, i64* %6
%24 = load i64, i64* %7
%25 = icmp sgt i64 %23, %24
br i1 %25, label %15, label %8
}