#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 */
double atoi(char *);
int /*<<< orphan*/ putchar(int /*<<< orphan*/);
int /*<<< orphan*/ round(double);
int main(int argc, char **argv) {
  int tick = 0;
  double period, step, amp = 0.0;
  if (argc == 2) {
    period = atoi(argv[1]);
  } else {
    period = 120;
  }
  step = 255 / period;
  while (1) {
    if (tick == period) {
      tick = 0;
      amp = 0;
    }
    if (amp < 255) {
      amp += step;
    }
    putchar(round(amp));
    tick += 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1176 <main+0x46>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    1183 <main+0x53>
movsd  0xe82(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe7d(%rip),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jne    11ba <main+0x8a>
jp     11ba <main+0x8a>
movl   $0x0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe46(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    11dc <main+0xac>
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <round@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1195 <main+0x65>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
cmp    $0x2,%edi
jne    1145 <main+0x15>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
jmp    114d <main+0x1d>
movsd  0xeb3(%rip),%xmm0
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
movsd  0xeb5(%rip),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
jmp    11aa <main+0x7a>
nopl   (%rax)
addsd  %xmm0,%xmm2
movapd %xmm2,0x20(%rsp)
movapd %xmm2,%xmm0
call   1040 <round@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
movsd  0x10(%rsp),%xmm0
ucomisd 0x18(%rsp),%xmm0
mov    $0x1,%eax
cmovne %ebx,%eax
cmovnp %eax,%ebx
movapd 0x20(%rsp),%xmm1
xorps  %xmm3,%xmm3
cvtsi2sd %ebx,%xmm3
movapd %xmm0,%xmm2
movsd  %xmm3,0x18(%rsp)
cmpeqsd %xmm3,%xmm2
andnpd %xmm1,%xmm2
movsd  0xe44(%rip),%xmm0
ucomisd %xmm2,%xmm0
movsd  0xe30(%rip),%xmm0
jbe    1170 <main+0x40>
movsd  0x8(%rsp),%xmm0
jmp    1170 <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 double
%8 = alloca double
%9 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store double 0.000000e+00, double* %9
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call double @atoi(i8* %15)
store double %16, double* %7
br label %18
17: ; preds = %2
store double 1.200000e+02, double* %7
br label %18
18: ; preds = %17, %12
%19 = load double, double* %7
%20 = fdiv double 2.550000e+02, %19
store double %20, double* %8
br label %21
21: ; preds = %18, %34
%22 = load i32, i32* %6
%23 = sitofp i32 %22 to double
%24 = load double, double* %7
%25 = fcmp oeq double %23, %24
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 0, i32* %6
store double 0.000000e+00, double* %9
br label %27
27: ; preds = %26, %21
%28 = load double, double* %9
%29 = fcmp olt double %28, 2.550000e+02
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = load double, double* %8
%32 = load double, double* %9
%33 = fadd double %32, %31
store double %33, double* %9
br label %34
34: ; preds = %30, %27
%35 = load double, double* %9
%36 = call i32 @round(double %35)
%37 = call i32 @putchar(i32 %36)
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %21
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call double @atoi(i8* %6)
br label %8
8: ; preds = %2, %4
%9 = phi double [ %7, %4 ], [ 1.200000e+02, %2 ]
%10 = fdiv double 2.550000e+02, %9
br label %11
11: ; preds = %11, %8
%12 = phi i32 [ 0, %8 ], [ %23, %11 ]
%13 = phi double [ 0.000000e+00, %8 ], [ %19, %11 ]
%14 = sitofp i32 %12 to double
%15 = fcmp oeq double %9, %14
%16 = select i1 %15, double 0.000000e+00, double %13
%17 = fcmp olt double %16, 2.550000e+02
%18 = select i1 %17, double %10, double -0.000000e+00
%19 = fadd double %16, %18
%20 = tail call i32 @round(double %19)
%21 = tail call i32 @putchar(i32 %20)
%22 = add nsw i32 %12, 1
%23 = select i1 %15, i32 1, i32 %22
br label %11
}