#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 lg(double);
int /*<<< orphan*/ printf(char *, double, ...);
int main() {
  double N, a, b;
  N = a = b = 0;
  int isAGreaterThanB = 1;
  int prevIsGreater = 1;
  int countChanges = 0;
  while (countChanges < 5) {
    N++;
    a = 10 * N * lg(N);
    b = 2 * (N * N);
    printf("is %f > %f?\n", a, b);
    prevIsGreater = isAGreaterThanB;
    isAGreaterThanB = (a > b) ? 1 : 0;
    printf("N: %f\n", N);
    if (!isAGreaterThanB == prevIsGreater)
      countChanges++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x5,-0x2c(%rbp)
jge    1232 <main+0x112>
movsd  0xea2(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe88(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <lg@plt>
movsd  -0x38(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xe48(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe46(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
xor    %eax,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xe1f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x24(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    -0x28(%rbp),%eax
jne    122d <main+0x10d>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115c <main+0x3c>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
mov    $0x1,%r12d
xor    %r13d,%r13d
lea    0xeca(%rip),%r14
lea    0xed0(%rip),%r15
nopl   (%rax)
movsd  (%rsp),%xmm0
addsd  0xea3(%rip),%xmm0
movsd  %xmm0,(%rsp)
movapd %xmm0,%xmm1
mulsd  0xe9a(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
call   1040 <lg@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm1,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    %r14,%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %ebx,%ebx
xor    %ebp,%ebp
movsd  0x8(%rsp),%xmm0
ucomisd 0x10(%rsp),%xmm0
setbe  %bl
seta   %bpl
mov    %r15,%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
xor    %r12d,%ebx
xor    $0x1,%ebx
add    %ebx,%r13d
mov    %ebp,%r12d
cmp    $0x5,%r13d
jb     1150 <main+0x30>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"is %f > %f?\0A\00"
@.str.1 = [7 x i8] c"N: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %3
store double 0.000000e+00, double* %2
store i32 1, i32* %5
store i32 1, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %44, %0
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %45
11: ; preds = %8
%12 = load double, double* %2
%13 = fadd double %12, 1.000000e+00
store double %13, double* %2
%14 = load double, double* %2
%15 = fmul double 1.000000e+01, %14
%16 = load double, double* %2
%17 = call i32 @lg(double %16)
%18 = sitofp i32 %17 to double
%19 = fmul double %15, %18
store double %19, double* %3
%20 = load double, double* %2
%21 = load double, double* %2
%22 = fmul double %20, %21
%23 = fmul double 2.000000e+00, %22
store double %23, double* %4
%24 = load double, double* %3
%25 = load double, double* %4
%26 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %24, double %25)
%27 = load i32, i32* %5
store i32 %27, i32* %6
%28 = load double, double* %3
%29 = load double, double* %4
%30 = fcmp ogt double %28, %29
%31 = zext i1 %30 to i64
%32 = select i1 %30, i32 1, i32 0
store i32 %32, i32* %5
%33 = load double, double* %2
%34 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %33)
%35 = load i32, i32* %5
%36 = icmp ne i32 %35, 0
%37 = xor i1 %36, true
%38 = zext i1 %37 to i32
%39 = load i32, i32* %6
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %44
41: ; preds = %11
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %44
44: ; preds = %41, %11
br label %8
45: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"is %f > %f?\0A\00"
@.str.1 = [7 x i8] c"N: %f\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %20, %1 ]
%3 = phi i32 [ 1, %0 ], [ %14, %1 ]
%4 = phi double [ 0.000000e+00, %0 ], [ %5, %1 ]
%5 = fadd double %4, 1.000000e+00
%6 = fmul double %5, 1.000000e+01
%7 = tail call i32 @lg(double %5)
%8 = sitofp i32 %7 to double
%9 = fmul double %6, %8
%10 = fmul double %5, %5
%11 = fmul double %10, 2.000000e+00
%12 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %9, double %11)
%13 = fcmp ogt double %9, %11
%14 = zext i1 %13 to i32
%15 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %5)
%16 = xor i1 %13, true
%17 = zext i1 %16 to i32
%18 = xor i32 %3, %17
%19 = xor i32 %18, 1
%20 = add nuw nsw i32 %19, %2
%21 = icmp ult i32 %20, 5
br i1 %21, label %1, label %22
22: ; preds = %1
ret i32 0
}