#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 CLOCKS_PER_SEC;
double clock();
unsigned int number_lenght(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  double start, end;
  unsigned int temp = 0, result = 0, max_lenght = 0;
  printf("Algorithm starts, please wait...\n");
  start = clock();
  for (unsigned int i = 1000; i > 2; --i) {
    if ((i % 2 != 0) && (i % 5 != 0)) {
      temp = number_lenght(i);
      if (temp > max_lenght) {
        max_lenght = temp;
        result = i;
      }
    }
  }
  end = clock();
  printf("%d\n", result);
  printf("Algorithm end.\n");
  printf("Total time: %f\n", (end - start) / CLOCKS_PER_SEC);
  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,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
movl   $0x3e8,-0x30(%rbp)
cmpl   $0x2,-0x30(%rbp)
jbe    11e5 <main+0xb5>
mov    -0x30(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11d2 <main+0xa2>
mov    -0x30(%rbp),%eax
mov    $0x5,%ecx
xor    %edx,%edx
div    %ecx
cmp    $0x0,%edx
je     11d2 <main+0xa2>
mov    -0x30(%rbp),%edi
call   1050 <number_lenght@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jbe    11cd <main+0x9d>
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    11d2 <main+0xa2>
jmp    11d7 <main+0xa7>
mov    -0x30(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x30(%rbp)
jmp    117c <main+0x4c>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x28(%rbp),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    0x2dc7(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe0a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x3e8,%ebx
mov    $0xcccccccd,%r15d
xor    %r14d,%r14d
jmp    1188 <main+0x48>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffff,%ebx
cmp    $0x2,%ebx
jbe    11bc <main+0x7c>
test   $0x1,%bl
je     1180 <main+0x40>
mov    %ebx,%eax
imul   %r15,%rax
shr    $0x22,%rax
lea    (%rax,%rax,4),%eax
neg    %eax
add    %ebx,%eax
add    $0x3e8,%eax
cmp    $0x3e8,%eax
je     1180 <main+0x40>
mov    %ebx,%edi
call   1060 <number_lenght@plt>
cmp    %ebp,%eax
cmova  %ebx,%r14d
cmova  %eax,%ebp
jmp    1180 <main+0x40>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe30(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe54(%rip),%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
mov    0x2def(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe00(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Algorithm starts, please wait...\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [16 x i8] c"Algorithm end.\0A\00"
@.str.3 = [16 x i8] c"Total time: %f\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%13 = call double (...) @clock()
store double %13, double* %6
store i32 1000, i32* %11
br label %14
14: ; preds = %36, %2
%15 = load i32, i32* %11
%16 = icmp ugt i32 %15, 2
br i1 %16, label %17, label %39
17: ; preds = %14
%18 = load i32, i32* %11
%19 = urem i32 %18, 2
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %35
21: ; preds = %17
%22 = load i32, i32* %11
%23 = urem i32 %22, 5
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %35
25: ; preds = %21
%26 = load i32, i32* %11
%27 = call i32 @number_lenght(i32 %26)
store i32 %27, i32* %8
%28 = load i32, i32* %8
%29 = load i32, i32* %10
%30 = icmp ugt i32 %28, %29
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = load i32, i32* %8
store i32 %32, i32* %10
%33 = load i32, i32* %11
store i32 %33, i32* %9
br label %34
34: ; preds = %31, %25
br label %35
35: ; preds = %34, %21, %17
br label %36
36: ; preds = %35
%37 = load i32, i32* %11
%38 = add i32 %37, -1
store i32 %38, i32* %11
br label %14
39: ; preds = %14
%40 = call double (...) @clock()
store double %40, double* %7
%41 = load i32, i32* %9
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%44 = load double, double* %7
%45 = load double, double* %6
%46 = fsub double %44, %45
%47 = load double, double* @CLOCKS_PER_SEC
%48 = fdiv double %46, %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %48)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.3 = [16 x i8] c"Total time: %f\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@str = [33 x i8] c"Algorithm starts, please wait...\00"
@str.4 = [15 x i8] c"Algorithm end.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%4 = tail call double (...) @clock()
br label %13
5: ; preds = %27
%6 = tail call double (...) @clock()
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.4, i64 0, i64 0))
%9 = fsub double %6, %4
%10 = load double, double* @CLOCKS_PER_SEC
%11 = fdiv double %9, %10
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %11)
ret i32 0
13: ; preds = %2, %27
%14 = phi i32 [ 1000, %2 ], [ %30, %27 ]
%15 = phi i32 [ 0, %2 ], [ %29, %27 ]
%16 = phi i32 [ 0, %2 ], [ %28, %27 ]
%17 = and i32 %14, 1
%18 = icmp eq i32 %17, 0
%19 = urem i32 %14, 5
%20 = icmp eq i32 %19, 0
%21 = or i1 %18, %20
br i1 %21, label %27, label %22
22: ; preds = %13
%23 = tail call i32 @number_lenght(i32 %14)
%24 = icmp ugt i32 %23, %15
%25 = select i1 %24, i32 %14, i32 %16
%26 = select i1 %24, i32 %23, i32 %15
br label %27
27: ; preds = %22, %13
%28 = phi i32 [ %16, %13 ], [ %25, %22 ]
%29 = phi i32 [ %15, %13 ], [ %26, %22 ]
%30 = add nsw i32 %14, -1
%31 = icmp ugt i32 %30, 2
br i1 %31, label %13, label %5
}