#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 */
typedef int uint32_t;
typedef int clock_t;

/* Variables and functions */
int CLOCKS_PER_SEC;
int FindLTP(int);
int clock();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  uint32_t num;
  clock_t start, end;
  double ms;
  do {
    printf("Please input a number between 1 and 2166: ");
    scanf("%i", &num);
  } while ((num > 2166) || (num < 1));
  start = clock();
  num = FindLTP(num);
  end = clock();
  ms = (end - start) * 1000 / CLOCKS_PER_SEC;
  printf("Time spent %04.2lf ms\n", ms);
  printf("Left-truncatable prime at the specified position is: %i\r\n", num);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x1,%al
cmpl   $0x876,-0x8(%rbp)
mov    %al,-0x19(%rbp)
jg     1189 <main+0x49>
cmpl   $0x1,-0x8(%rbp)
setl   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    114f <main+0xf>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <FindLTP@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
imul   $0x3e8,%eax,%eax
mov    0x2e22(%rip),%rcx
cltd
idivl  (%rcx)
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe50(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%r14
lea    0xed6(%rip),%r15
lea    0x4(%rsp),%rbx
mov    $0xfffff789,%ebp
nop
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
add    %ebp,%eax
cmp    $0xfffff78a,%eax
jb     1160 <main+0x20>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%edi
call   1060 <FindLTP@plt>
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1030 <clock@plt>
sub    %ebx,%eax
imul   $0x3e8,%eax,%eax
mov    0x2e3a(%rip),%rcx
cltd
idivl  (%rcx)
cvtsi2sd %eax,%xmm0
lea    0xe72(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xe77(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Please input a number between 1 and 2166: \00"
@.str.1 = [3 x i8] c"%i\00"
@CLOCKS_PER_SEC = global i32 0
@.str.2 = [23 x i8] c"Time spent %04.2lf ms\0A\00"
@.str.3 = [58 x i8] c"Left-truncatable prime at the specified position is: %i\0D\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
store i32 0, i32* %1
br label %6
6: ; preds = %15, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %9
9: ; preds = %6
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 2166
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 1
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ true, %9 ], [ %14, %12 ]
br i1 %16, label %6, label %17
17: ; preds = %15
%18 = call i32 (...) @clock()
store i32 %18, i32* %3
%19 = load i32, i32* %2
%20 = call i32 @FindLTP(i32 %19)
store i32 %20, i32* %2
%21 = call i32 (...) @clock()
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = load i32, i32* %3
%24 = sub nsw i32 %22, %23
%25 = mul nsw i32 %24, 1000
%26 = load i32, i32* @CLOCKS_PER_SEC
%27 = sdiv i32 %25, %26
%28 = sitofp i32 %27 to double
store double %28, double* %5
%29 = load double, double* %5
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %29)
%31 = load i32, i32* %2
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i32 %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [43 x i8] c"Please input a number between 1 and 2166: \00"
@.str.1 = [3 x i8] c"%i\00"
@CLOCKS_PER_SEC = global i32 0
@.str.2 = [23 x i8] c"Time spent %04.2lf ms\0A\00"
@.str.3 = [58 x i8] c"Left-truncatable prime at the specified position is: %i\0D\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = add i32 %6, -2167
%8 = icmp ult i32 %7, -2166
br i1 %8, label %3, label %9
9: ; preds = %3
%10 = call i32 (...) @clock()
%11 = load i32, i32* %1
%12 = call i32 @FindLTP(i32 %11)
store i32 %12, i32* %1
%13 = call i32 (...) @clock()
%14 = sub nsw i32 %13, %10
%15 = mul nsw i32 %14, 1000
%16 = load i32, i32* @CLOCKS_PER_SEC
%17 = sdiv i32 %15, %16
%18 = sitofp i32 %17 to double
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %18)
%20 = load i32, i32* %1
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i32 %20)
ret i32 0
}