#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 atoi(char *);
int /*<<< orphan*/ putchar(int);
int main(int argc, char **argv) {
  int tick = 0;
  bool max = false;
  int halfPeriod;
  if (argc == 2) {
    halfPeriod = atoi(argv[1]) / 2;
  } else {
    halfPeriod = 60;
  }
  while (1) {
    if (tick == halfPeriod) {
      tick = 0;
      max = !max;
    }
    if (max == true) {
      putchar(255);
    } else {
      putchar(0);
    }
    tick += 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    116b <main+0x4b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
jmp    1172 <main+0x52>
movl   $0x3c,-0x1c(%rbp)
jmp    1177 <main+0x57>
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    119b <main+0x7b>
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    11b4 <main+0x94>
mov    $0xff,%edi
call   1030 <putchar@plt>
jmp    11bb <main+0x9b>
xor    %edi,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1177 <main+0x57>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x3c,%r15d
cmp    $0x2,%edi
jne    1148 <main+0x28>
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
mov    %eax,%r15d
shr    $0x1f,%r15d
add    %eax,%r15d
sar    %r15d
xor    %ebp,%ebp
mov    $0x1,%r14d
xor    %ebx,%ebx
jmp    1165 <main+0x45>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
call   1030 <putchar@plt>
mov    %ebx,%eax
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
cmp    %r15d,%ebp
lea    0x1(%rbp),%ecx
cmovne %eax,%ebx
mov    %ecx,%ebp
cmove  %r14d,%ebp
mov    $0xff,%edi
cmp    $0x1,%ebx
je     1160 <main+0x40>
xor    %edi,%edi
jmp    1160 <main+0x40>

LLVM IR (-O0):
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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
%16 = sdiv i32 %15, 2
store i32 %16, i32* %8
br label %18
17: ; preds = %2
store i32 60, i32* %8
br label %18
18: ; preds = %17, %11
br label %19
19: ; preds = %18, %35
%20 = load i32, i32* %6
%21 = load i32, i32* %8
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %28
23: ; preds = %19
store i32 0, i32* %6
%24 = load i32, i32* %7
%25 = icmp ne i32 %24, 0
%26 = xor i1 %25, true
%27 = zext i1 %26 to i32
store i32 %27, i32* %7
br label %28
28: ; preds = %23, %19
%29 = load i32, i32* %7
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @putchar(i32 255)
br label %35
33: ; preds = %28
%34 = call i32 @putchar(i32 0)
br label %35
35: ; preds = %33, %31
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %19
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = sdiv i32 %7, 2
br label %9
9: ; preds = %2, %4
%10 = phi i32 [ %8, %4 ], [ 60, %2 ]
br label %11
11: ; preds = %11, %9
%12 = phi i32 [ 0, %9 ], [ %22, %11 ]
%13 = phi i32 [ 0, %9 ], [ %17, %11 ]
%14 = icmp eq i32 %12, %10
%15 = icmp eq i32 %13, 0
%16 = zext i1 %15 to i32
%17 = select i1 %14, i32 %16, i32 %13
%18 = icmp eq i32 %17, 1
%19 = select i1 %18, i32 255, i32 0
%20 = tail call i32 @putchar(i32 %19)
%21 = add nsw i32 %12, 1
%22 = select i1 %14, i32 1, i32 %21
br label %11
}