#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 /*<<< orphan*/ printf(char *, float);
float timeit();
int main(int argc, char *argv[]) {
  float start = timeit();
  long long high_num = 0;
  for (long long canidate = 3, high = 0, count = 0; canidate < 1000000;
       canidate += 2, count = 0) {
    for (long long collatz = canidate; collatz != 1; count++)
      collatz = collatz % 2 == 0 ? collatz / 2 : (collatz * 3) + 1;
    if (count > high) {
      high = count;
      high_num = canidate;
    }
  }
  float stop = timeit();
  printf("Answer: %lld\n", high_num);
  printf("Time: %f\n", stop - start);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <timeit@plt>
movss  %xmm0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x3,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0xf4240,-0x28(%rbp)
jge    1214 <main+0xf4>
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x1,-0x40(%rbp)
je     11d8 <main+0xb8>
mov    -0x40(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    11b2 <main+0x92>
mov    -0x40(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x50(%rbp)
jmp    11bf <main+0x9f>
imul   $0x3,-0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1178 <main+0x58>
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jle    11f6 <main+0xd6>
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11fb <main+0xdb>
mov    -0x28(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
jmp    1162 <main+0x42>
mov    $0x0,%al
call   1040 <timeit@plt>
movss  %xmm0,-0x44(%rbp)
cvtsi2ssq -0x20(%rbp),%xmm0
lea    0xdd3(%rip),%rdi
call   1030 <printf@plt>
movss  -0x44(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
lea    0xdcb(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <timeit@plt>
movss  %xmm0,0x4(%rsp)
mov    $0x3,%eax
xor    %r14d,%r14d
jmp    115e <main+0x3e>
nopl   (%rax)
lea    0x1(%rcx),%rdx
cmp    %rbx,%rcx
cmovge %rax,%r14
cmovge %rdx,%rbx
lea    0x2(%rax),%rcx
cmp    $0xf423e,%rax
mov    %rcx,%rax
jae    1199 <main+0x79>
mov    $0xffffffffffffffff,%rcx
mov    %rax,%rdx
jmp    1182 <main+0x62>
nopw   0x0(%rax,%rax,1)
lea    (%rdx,%rdx,2),%rdx
add    $0x1,%rdx
add    $0x1,%rcx
cmp    $0x1,%rdx
je     1140 <main+0x20>
test   $0x1,%dl
jne    1170 <main+0x50>
mov    %rdx,%rsi
shr    $0x3f,%rsi
add    %rdx,%rsi
sar    %rsi
mov    %rsi,%rdx
jmp    1178 <main+0x58>
xor    %eax,%eax
call   1040 <timeit@plt>
movss  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %r14,%xmm0
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
movss  (%rsp),%xmm0
subss  0x4(%rsp),%xmm0
lea    0xe43(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Answer: %lld\0A\00"
@.str.1 = [10 x i8] c"Time: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call float (...) @timeit()
store float %13, float* %6
store i64 0, i64* %7
store i64 3, i64* %8
store i64 0, i64* %9
store i64 0, i64* %10
br label %14
14: ; preds = %46, %2
%15 = load i64, i64* %8
%16 = icmp slt i64 %15, 1000000
br i1 %16, label %17, label %49
17: ; preds = %14
%18 = load i64, i64* %8
store i64 %18, i64* %11
br label %19
19: ; preds = %35, %17
%20 = load i64, i64* %11
%21 = icmp ne i64 %20, 1
br i1 %21, label %22, label %38
22: ; preds = %19
%23 = load i64, i64* %11
%24 = srem i64 %23, 2
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i64, i64* %11
%28 = sdiv i64 %27, 2
br label %33
29: ; preds = %22
%30 = load i64, i64* %11
%31 = mul nsw i64 %30, 3
%32 = add nsw i64 %31, 1
br label %33
33: ; preds = %29, %26
%34 = phi i64 [ %28, %26 ], [ %32, %29 ]
store i64 %34, i64* %11
br label %35
35: ; preds = %33
%36 = load i64, i64* %10
%37 = add nsw i64 %36, 1
store i64 %37, i64* %10
br label %19
38: ; preds = %19
%39 = load i64, i64* %10
%40 = load i64, i64* %9
%41 = icmp sgt i64 %39, %40
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i64, i64* %10
store i64 %43, i64* %9
%44 = load i64, i64* %8
store i64 %44, i64* %7
br label %45
45: ; preds = %42, %38
br label %46
46: ; preds = %45
%47 = load i64, i64* %8
%48 = add nsw i64 %47, 2
store i64 %48, i64* %8
store i64 0, i64* %10
br label %14
49: ; preds = %14
%50 = call float (...) @timeit()
store float %50, float* %12
%51 = load i64, i64* %7
%52 = sitofp i64 %51 to float
%53 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), float %52)
%54 = load float, float* %12
%55 = load float, float* %6
%56 = fsub float %54, %55
%57 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), float %56)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"Answer: %lld\0A\00"
@.str.1 = [10 x i8] c"Time: %f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call float (...) @timeit()
br label %4
4: ; preds = %2, %14
%5 = phi i64 [ 0, %2 ], [ %17, %14 ]
%6 = phi i64 [ 3, %2 ], [ %18, %14 ]
%7 = phi i64 [ 0, %2 ], [ %16, %14 ]
br label %20
8: ; preds = %14
%9 = tail call float (...) @timeit()
%10 = sitofp i64 %16 to float
%11 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), float %10)
%12 = fsub float %9, %3
%13 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), float %12)
ret i32 0
14: ; preds = %30
%15 = icmp slt i64 %22, %5
%16 = select i1 %15, i64 %7, i64 %6
%17 = select i1 %15, i64 %5, i64 %32
%18 = add nuw nsw i64 %6, 2
%19 = icmp ult i64 %6, 999998
br i1 %19, label %4, label %8
20: ; preds = %4, %30
%21 = phi i64 [ %6, %4 ], [ %31, %30 ]
%22 = phi i64 [ 0, %4 ], [ %32, %30 ]
%23 = and i64 %21, 1
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = sdiv i64 %21, 2
br label %30
27: ; preds = %20
%28 = mul nsw i64 %21, 3
%29 = add nsw i64 %28, 1
br label %30
30: ; preds = %27, %25
%31 = phi i64 [ %26, %25 ], [ %29, %27 ]
%32 = add nuw nsw i64 %22, 1
%33 = icmp eq i64 %31, 1
br i1 %33, label %14, label %20
}