#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 */
scalar_t__ is_good(long);
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ time_start();
long time_stop();
int main() {
  long count = 0;
  time_start();
  for (long i = 1; i < 1000001; i++) {
    if (is_good(i)) {
      count++;
    }
  }
  printf("Count of good number is %ld\n", count);
  printf("Time: %ld millisecond\n", time_stop());
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <time_start@plt>
movq   $0x1,-0x18(%rbp)
cmpq   $0xf4241,-0x18(%rbp)
jge    11a9 <main+0x69>
mov    -0x18(%rbp),%rdi
call   1050 <is_good@plt>
cmp    $0x0,%rax
je     1193 <main+0x53>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1198 <main+0x58>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1166 <main+0x26>
mov    -0x10(%rbp),%rsi
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <time_stop@plt>
mov    %rax,%rsi
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <time_start@plt>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1050 <is_good@plt>
cmp    $0x1,%rax
sbb    $0xffffffffffffffff,%r14
add    $0x1,%rbx
cmp    $0xf4241,%rbx
jne    1160 <main+0x20>
lea    0xe7c(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <time_stop@plt>
lea    0xe83(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Count of good number is %ld\0A\00"
@.str.1 = [23 x i8] c"Time: %ld millisecond\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %2
%4 = call i32 (...) @time_start()
store i64 1, i64* %3
br label %5
5: ; preds = %16, %0
%6 = load i64, i64* %3
%7 = icmp slt i64 %6, 1000001
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = load i64, i64* %3
%10 = call i64 @is_good(i64 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i64, i64* %2
%14 = add nsw i64 %13, 1
store i64 %14, i64* %2
br label %15
15: ; preds = %12, %8
br label %16
16: ; preds = %15
%17 = load i64, i64* %3
%18 = add nsw i64 %17, 1
store i64 %18, i64* %3
br label %5
19: ; preds = %5
%20 = load i64, i64* %2
%21 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i64 %20)
%22 = call i64 (...) @time_stop()
%23 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Count of good number is %ld\0A\00"
@.str.1 = [23 x i8] c"Time: %ld millisecond\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @time_start()
br label %6
2: ; preds = %6
%3 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i64 %12)
%4 = tail call i64 (...) @time_stop()
%5 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %4)
ret i32 0
6: ; preds = %0, %6
%7 = phi i64 [ 1, %0 ], [ %13, %6 ]
%8 = phi i64 [ 0, %0 ], [ %12, %6 ]
%9 = tail call i64 @is_good(i64 %7)
%10 = icmp ne i64 %9, 0
%11 = zext i1 %10 to i64
%12 = add nuw nsw i64 %8, %11
%13 = add nuw nsw i64 %7, 1
%14 = icmp eq i64 %13, 1000001
br i1 %14, label %2, label %6
}