#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 */

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ free(int *);
int *intblk();
int /*<<< orphan*/ sleep(int);
void main() {
  int i = 0;
  while (1) {
    int *ptr = intblk();
    *ptr = (++i * 2);
    if (!(*ptr % 3)) {
      continue;
    }
    if (*ptr > 500) {
      abort();
    }
    free(ptr);
    sleep(1);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <intblk@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x4(%rbp)
shl    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1188 <main+0x48>
jmp    114f <main+0xf>
mov    -0x10(%rbp),%rax
cmpl   $0x1f4,(%rax)
jle    119f <main+0x5f>
mov    $0x0,%al
call   1050 <abort@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
jmp    114f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0xfffffffe,%r12d
mov    $0x2,%ebp
mov    $0xaaaaaaab,%r14d
xor    %r15d,%r15d
jmp    116b <main+0x2b>
xchg   %ax,%ax
add    $0xfffffffe,%r12d
add    $0x2,%ebp
add    $0x1,%r15d
mov    %ebp,%eax
imul   %r14,%rax
shr    $0x21,%rax
lea    (%rax,%rax,2),%ebx
xor    %eax,%eax
call   1040 <intblk@plt>
mov    %ebp,(%rax)
add    %r12d,%ebx
je     1160 <main+0x20>
cmp    $0xfa,%r15d
jae    11a3 <main+0x63>
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
jmp    1160 <main+0x20>
xor    %eax,%eax
call   1050 <abort@plt>

LLVM IR (-O0):
define void @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
br label %3
3: ; preds = %0, %13, %20
%4 = call i32* (...) @intblk()
store i32* %4, i32** %2
%5 = load i32, i32* %1
%6 = add nsw i32 %5, 1
store i32 %6, i32* %1
%7 = mul nsw i32 %6, 2
%8 = load i32*, i32** %2
store i32 %7, i32* %8
%9 = load i32*, i32** %2
%10 = load i32, i32* %9
%11 = srem i32 %10, 3
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %3
br label %3
14: ; preds = %3
%15 = load i32*, i32** %2
%16 = load i32, i32* %15
%17 = icmp sgt i32 %16, 500
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 (...) @abort()
unreachable
20: ; preds = %14
%21 = load i32*, i32** %2
%22 = call i32 @free(i32* %21)
%23 = call i32 @sleep(i32 1)
br label %3
}

LLVM IR (-O2):
define void @main() {
br label %1
1: ; preds = %8, %0
%2 = phi i32 [ 0, %0 ], [ %4, %8 ]
%3 = tail call i32* (...) @intblk()
%4 = add nuw nsw i32 %2, 1
%5 = shl nuw nsw i32 %4, 1
store i32 %5, i32* %3
%6 = urem i32 %5, 3
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1, %13
br label %1
9: ; preds = %1
%10 = icmp ugt i32 %2, 249
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = tail call i32 (...) @abort()
unreachable
13: ; preds = %9
%14 = tail call i32 @free(i32* %3)
%15 = tail call i32 @sleep(i32 1)
br label %8
}