#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 scalar_t__ clock_t;

/* Variables and functions */
float CLOCKS_PER_SEC;
int atoi(char *);
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, unsigned int);
void computation_timed_fibonacci(char *arg1) {
  int time = atoi(arg1);
  0;
  unsigned int a = 0;
  unsigned int b = 1;
  unsigned int c = 0;
  clock_t start = clock();
  clock_t end;
  float elapsed_seconds = 0.0;
  unsigned int i = 2;
  while (1) {
    if (i % 100 == 0) {
      end = clock();
      elapsed_seconds = (float)(end - start) / CLOCKS_PER_SEC;
      if (elapsed_seconds > ((float)time)) {
        break;
      }
    }
    c = a + b;
    a = b;
    b = c;
    i++;
  }
  printf("Final number is %u.", c);
}


x86 assembly (clang, -O0):
<computation_timed_fibonacci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x20(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movl   $0x2,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
cmp    $0x0,%edx
jne    11d1 <computation_timed_fibonacci+0xa1>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2ss %rax,%xmm0
mov    0x2e3d(%rip),%rax
divss  (%rax),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jbe    11cc <computation_timed_fibonacci+0x9c>
jmp    11f4 <computation_timed_fibonacci+0xc4>
jmp    11d1 <computation_timed_fibonacci+0xa1>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1177 <computation_timed_fibonacci+0x47>
mov    -0x18(%rbp),%esi
lea    0xe02(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<computation_timed_fibonacci>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
call   1050 <atoi@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <clock@plt>
cvtsi2ss %ebx,%xmm0
movss  %xmm0,0x4(%rsp)
mov    %rax,%r14
mov    $0x2,%r13d
mov    $0x1,%eax
mov    $0xfffffffe,%ebp
xor    %r15d,%r15d
xor    %ebx,%ebx
jmp    1182 <computation_timed_fibonacci+0x52>
nopl   (%rax)
add    %r12d,%ebx
add    $0x1,%r13d
add    $0xffffffff,%ebp
mov    %ebx,%r15d
mov    %ebx,%eax
mov    %r12d,%ebx
mov    %eax,%r12d
mov    %r13d,%eax
imul   $0x51eb851f,%rax,%rax
shr    $0x25,%rax
imul   $0x64,%eax,%eax
add    %ebp,%eax
jne    1170 <computation_timed_fibonacci+0x40>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r14,%rax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mov    0x2e35(%rip),%rax
divss  (%rax),%xmm0
ucomiss 0x4(%rsp),%xmm0
jbe    1170 <computation_timed_fibonacci+0x40>
lea    0xe3b(%rip),%rdi
mov    %r15d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str = [20 x i8] c"Final number is %u.\00"
define void @computation_timed_fibonacci(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca float
%10 = alloca i32
store i8* %0, i8** %2
%11 = load i8*, i8** %2
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %3
store i32 0, i32* %4
store i32 1, i32* %5
store i32 0, i32* %6
%13 = call i64 (...) @clock()
store i64 %13, i64* %7
store float 0.000000e+00, float* %9
store i32 2, i32* %10
br label %14
14: ; preds = %1, %32
%15 = load i32, i32* %10
%16 = urem i32 %15, 100
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %32
18: ; preds = %14
%19 = call i64 (...) @clock()
store i64 %19, i64* %8
%20 = load i64, i64* %8
%21 = load i64, i64* %7
%22 = sub nsw i64 %20, %21
%23 = sitofp i64 %22 to float
%24 = load float, float* @CLOCKS_PER_SEC
%25 = fdiv float %23, %24
store float %25, float* %9
%26 = load float, float* %9
%27 = load i32, i32* %3
%28 = sitofp i32 %27 to float
%29 = fcmp ogt float %26, %28
br i1 %29, label %30, label %31
30: ; preds = %18
br label %40
31: ; preds = %18
br label %32
32: ; preds = %31, %14
%33 = load i32, i32* %4
%34 = load i32, i32* %5
%35 = add i32 %33, %34
store i32 %35, i32* %6
%36 = load i32, i32* %5
store i32 %36, i32* %4
%37 = load i32, i32* %6
store i32 %37, i32* %5
%38 = load i32, i32* %10
%39 = add i32 %38, 1
store i32 %39, i32* %10
br label %14
40: ; preds = %30
%41 = load i32, i32* %6
%42 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %41)
ret void
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str = [20 x i8] c"Final number is %u.\00"
define void @computation_timed_fibonacci(i8* nocapture %0) {
%2 = tail call i32 @atoi(i8* %0)
%3 = tail call i64 (...) @clock()
%4 = sitofp i32 %2 to float
br label %5
5: ; preds = %19, %1
%6 = phi i32 [ 0, %1 ], [ %20, %19 ]
%7 = phi i32 [ 1, %1 ], [ %20, %19 ]
%8 = phi i32 [ 0, %1 ], [ %7, %19 ]
%9 = phi i32 [ 2, %1 ], [ %21, %19 ]
%10 = urem i32 %9, 100
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %5
%13 = tail call i64 (...) @clock()
%14 = sub nsw i64 %13, %3
%15 = sitofp i64 %14 to float
%16 = load float, float* @CLOCKS_PER_SEC
%17 = fdiv float %15, %16
%18 = fcmp ogt float %17, %4
br i1 %18, label %22, label %19
19: ; preds = %12, %5
%20 = add i32 %8, %7
%21 = add i32 %9, 1
br label %5
22: ; preds = %12
%23 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %6)
ret void
}