#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 */
struct timeval {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ check_results(int, unsigned char *, unsigned char *);
int /*<<< orphan*/ convert1(unsigned char *, unsigned char *, int, int);
int /*<<< orphan*/ convert2(unsigned char *, unsigned char *, int, int);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
long random();
double time_diff(struct timeval, struct timeval);
int main(void) {
  int ii, jj;
  long *rawptr;
  unsigned char *rawdata;
  unsigned char *gooddata;
  unsigned char *data;
  struct timeval t1, t2;
  rawdata = (unsigned char *)malloc(32000000);
  gooddata = (unsigned char *)malloc(256000000);
  data = (unsigned char *)malloc(256000000);
  rawptr = (long *)rawdata;
  for (ii = 0; ii < 32000000 / 4; ii++)
    rawptr[ii] = random();
  printf("Increasing freqs...\n");
  for (ii = 0, jj = 0; ii < 32000000 / 32; ii += 32, jj += 256)
    convert1(rawdata + ii, gooddata + jj, 256, 0);
  for (ii = 0, jj = 0; ii < 32000000 / 32; ii += 32, jj += 256)
    convert1(rawdata + ii, data + jj, 256, 0);
  gettimeofday(&t1, 0);
  for (ii = 0, jj = 0; ii < 32000000 / 32; ii += 32, jj += 256)
    convert1(rawdata + ii, data + jj, 256, 0);
  gettimeofday(&t2, 0);
  check_results(256000000, gooddata, data);
  printf("     Standard Time = %.4f s\n", time_diff(t2, t1));
  gettimeofday(&t1, 0);
  for (ii = 0, jj = 0; ii < 32000000 / 32; ii += 32, jj += 256)
    convert2(rawdata + ii, data + jj, 256, 0);
  gettimeofday(&t2, 0);
  check_results(256000000, gooddata, data);
  printf("   New Method Time = %.4f s\n", time_diff(t2, t1));
  printf("Decreasing freqs...\n");
  for (ii = 0, jj = 0; ii < 32000000 / 32; ii += 32, jj += 256)
    convert1(rawdata + ii, gooddata + jj, 256, 1);
  for (ii = 0, jj = 0; ii < 32000000 / 32; ii += 32, jj += 256)
    convert1(rawdata + ii, data + jj, 256, 1);
  gettimeofday(&t1, 0);
  for (ii = 0, jj = 0; ii < 32000000 / 32; ii += 32, jj += 256)
    convert1(rawdata + ii, data + jj, 256, 1);
  gettimeofday(&t2, 0);
  check_results(256000000, gooddata, data);
  printf("     Standard Time = %.4f s\n", time_diff(t2, t1));
  gettimeofday(&t1, 0);
  for (ii = 0, jj = 0; ii < 32000000 / 32; ii += 32, jj += 256)
    convert2(rawdata + ii, data + jj, 256, 1);
  gettimeofday(&t2, 0);
  check_results(256000000, gooddata, data);
  printf("   New Method Time = %.4f s\n", time_diff(t2, t1));
  free(rawdata);
  free(gooddata);
  free(data);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1e84800,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0xf424000,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0xf424000,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x7a1200,-0x8(%rbp)
jge    1209 <main+0x79>
mov    $0x0,%al
call   1070 <random@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d8 <main+0x48>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jge    126d <main+0xdd>
mov    -0x20(%rbp),%rdi
movslq -0x8(%rbp),%rax
add    %rax,%rdi
mov    -0x28(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1050 <convert1@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0xc(%rbp)
jmp    1225 <main+0x95>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jge    12c3 <main+0x133>
mov    -0x20(%rbp),%rdi
movslq -0x8(%rbp),%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1050 <convert1@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0xc(%rbp)
jmp    127b <main+0xeb>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jge    1324 <main+0x194>
mov    -0x20(%rbp),%rdi
movslq -0x8(%rbp),%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1050 <convert1@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0xc(%rbp)
jmp    12dc <main+0x14c>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    $0xf424000,%edi
call   10b0 <check_results@plt>
mov    -0x40(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1090 <time_diff@plt>
lea    0xcc2(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jge    13bb <main+0x22b>
mov    -0x20(%rbp),%rdi
movslq -0x8(%rbp),%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   10a0 <convert2@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0xc(%rbp)
jmp    1373 <main+0x1e3>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    $0xf424000,%edi
call   10b0 <check_results@plt>
mov    -0x40(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1090 <time_diff@plt>
lea    0xc48(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xc57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jge    1458 <main+0x2c8>
mov    -0x20(%rbp),%rdi
movslq -0x8(%rbp),%rax
add    %rax,%rdi
mov    -0x28(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
mov    $0x100,%edx
mov    $0x1,%ecx
call   1050 <convert1@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0xc(%rbp)
jmp    140d <main+0x27d>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jge    14b1 <main+0x321>
mov    -0x20(%rbp),%rdi
movslq -0x8(%rbp),%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
mov    $0x100,%edx
mov    $0x1,%ecx
call   1050 <convert1@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0xc(%rbp)
jmp    1466 <main+0x2d6>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jge    1515 <main+0x385>
mov    -0x20(%rbp),%rdi
movslq -0x8(%rbp),%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
mov    $0x100,%edx
mov    $0x1,%ecx
call   1050 <convert1@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0xc(%rbp)
jmp    14ca <main+0x33a>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    $0xf424000,%edi
call   10b0 <check_results@plt>
mov    -0x40(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1090 <time_diff@plt>
lea    0xad1(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xf4240,-0x8(%rbp)
jge    15af <main+0x41f>
mov    -0x20(%rbp),%rdi
movslq -0x8(%rbp),%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
mov    $0x100,%edx
mov    $0x1,%ecx
call   10a0 <convert2@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0xc(%rbp)
jmp    1564 <main+0x3d4>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    $0xf424000,%edi
call   10b0 <check_results@plt>
mov    -0x40(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1090 <time_diff@plt>
lea    0xa54(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    $0x1e84800,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
mov    $0xf424000,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    $0xf424000,%edi
call   1090 <malloc@plt>
mov    %rax,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <random@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    $0x7a1200,%rbx
jne    11e0 <main+0x40>
lea    0xe3b(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffffffffffe0,%rbx
mov    %r14,%r13
xchg   %ax,%ax
lea    (%r12,%rbx,1),%rdi
add    $0x20,%rdi
mov    %r13,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1060 <convert1@plt>
add    $0x100,%r13
add    $0x20,%rbx
cmp    $0xf4220,%rbx
jb     1210 <main+0x70>
mov    $0xffffffffffffffe0,%rbx
mov    %r15,%r13
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r12,%rbx,1),%rdi
add    $0x20,%rdi
mov    %r13,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1060 <convert1@plt>
add    $0x100,%r13
add    $0x20,%rbx
cmp    $0xf4220,%rbx
jb     1250 <main+0xb0>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    $0xffffffffffffffe0,%rbx
mov    %r15,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%r12,%rbx,1),%rdi
add    $0x20,%rdi
mov    %r13,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1060 <convert1@plt>
add    $0x100,%r13
add    $0x20,%rbx
cmp    $0xf4220,%rbx
jb     12a0 <main+0x100>
mov    %rsp,%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    $0xf424000,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   10c0 <check_results@plt>
mov    (%rsp),%edi
mov    0x8(%rsp),%esi
call   10a0 <time_diff@plt>
lea    0xd08(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    $0xffffffffffffffe0,%rbx
mov    %r15,%r13
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r12,%rbx,1),%rdi
add    $0x20,%rdi
mov    %r13,%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   10b0 <convert2@plt>
add    $0x100,%r13
add    $0x20,%rbx
cmp    $0xf4220,%rbx
jb     1320 <main+0x180>
mov    %rsp,%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    $0xf424000,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   10c0 <check_results@plt>
mov    (%rsp),%edi
mov    0x8(%rsp),%esi
call   10a0 <time_diff@plt>
lea    0xca5(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xcc8(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffffffffffe0,%rbx
mov    %r14,%r13
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r12,%rbx,1),%rdi
add    $0x20,%rdi
mov    %r13,%rsi
mov    $0x100,%edx
mov    $0x1,%ecx
call   1060 <convert1@plt>
add    $0x100,%r13
add    $0x20,%rbx
cmp    $0xf4220,%rbx
jb     13a0 <main+0x200>
mov    $0xffffffffffffffe0,%rbx
mov    %r15,%r13
nopl   0x0(%rax,%rax,1)
lea    (%r12,%rbx,1),%rdi
add    $0x20,%rdi
mov    %r13,%rsi
mov    $0x100,%edx
mov    $0x1,%ecx
call   1060 <convert1@plt>
add    $0x100,%r13
add    $0x20,%rbx
cmp    $0xf4220,%rbx
jb     13e0 <main+0x240>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    $0xffffffffffffffe0,%rbx
mov    %r15,%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%r12,%rbx,1),%rdi
add    $0x20,%rdi
mov    %r13,%rsi
mov    $0x100,%edx
mov    $0x1,%ecx
call   1060 <convert1@plt>
add    $0x100,%r13
add    $0x20,%rbx
cmp    $0xf4220,%rbx
jb     1430 <main+0x290>
mov    %rsp,%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    $0xf424000,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   10c0 <check_results@plt>
mov    (%rsp),%edi
mov    0x8(%rsp),%esi
call   10a0 <time_diff@plt>
lea    0xb75(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    $0xffffffffffffffe0,%rbx
mov    %r15,%r13
nopl   0x0(%rax,%rax,1)
lea    (%r12,%rbx,1),%rdi
add    $0x20,%rdi
mov    %r13,%rsi
mov    $0x100,%edx
mov    $0x1,%ecx
call   10b0 <convert2@plt>
add    $0x100,%r13
add    $0x20,%rbx
cmp    $0xf4220,%rbx
jb     14b0 <main+0x310>
mov    %rsp,%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    $0xf424000,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   10c0 <check_results@plt>
mov    (%rsp),%edi
mov    0x8(%rsp),%esi
call   10a0 <time_diff@plt>
lea    0xb12(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [21 x i8] c"Increasing freqs...\0A\00"
@.str.1 = [29 x i8] c" Standard Time = %.4f s\0A\00"
@.str.2 = [29 x i8] c" New Method Time = %.4f s\0A\00"
@.str.3 = [21 x i8] c"Decreasing freqs...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.timeval
%9 = alloca %struct.timeval
store i32 0, i32* %1
%10 = call i64 @malloc(i32 32000000)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %5
%12 = call i64 @malloc(i32 256000000)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %6
%14 = call i64 @malloc(i32 256000000)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %7
%16 = load i8*, i8** %5
%17 = bitcast i8* %16 to i64*
store i64* %17, i64** %4
store i32 0, i32* %2
br label %18
18: ; preds = %27, %0
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 8000000
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = call i64 (...) @random()
%23 = load i64*, i64** %4
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i64, i64* %23, i64 %25
store i64 %22, i64* %26
br label %27
27: ; preds = %21
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %18
30: ; preds = %18
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
store i32 0, i32* %3
br label %32
32: ; preds = %45, %30
%33 = load i32, i32* %2
%34 = icmp slt i32 %33, 1000000
br i1 %34, label %35, label %50
35: ; preds = %32
%36 = load i8*, i8** %5
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8*, i8** %6
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = call i32 @convert1(i8* %39, i8* %43, i32 256, i32 0)
br label %45
45: ; preds = %35
%46 = load i32, i32* %2
%47 = add nsw i32 %46, 32
store i32 %47, i32* %2
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 256
store i32 %49, i32* %3
br label %32
50: ; preds = %32
store i32 0, i32* %2
store i32 0, i32* %3
br label %51
51: ; preds = %64, %50
%52 = load i32, i32* %2
%53 = icmp slt i32 %52, 1000000
br i1 %53, label %54, label %69
54: ; preds = %51
%55 = load i8*, i8** %5
%56 = load i32, i32* %2
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
%59 = load i8*, i8** %7
%60 = load i32, i32* %3
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
%63 = call i32 @convert1(i8* %58, i8* %62, i32 256, i32 0)
br label %64
64: ; preds = %54
%65 = load i32, i32* %2
%66 = add nsw i32 %65, 32
store i32 %66, i32* %2
%67 = load i32, i32* %3
%68 = add nsw i32 %67, 256
store i32 %68, i32* %3
br label %51
69: ; preds = %51
%70 = call i32 @gettimeofday(%struct.timeval* %8, i32 0)
store i32 0, i32* %2
store i32 0, i32* %3
br label %71
71: ; preds = %84, %69
%72 = load i32, i32* %2
%73 = icmp slt i32 %72, 1000000
br i1 %73, label %74, label %89
74: ; preds = %71
%75 = load i8*, i8** %5
%76 = load i32, i32* %2
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8, i8* %75, i64 %77
%79 = load i8*, i8** %7
%80 = load i32, i32* %3
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %79, i64 %81
%83 = call i32 @convert1(i8* %78, i8* %82, i32 256, i32 0)
br label %84
84: ; preds = %74
%85 = load i32, i32* %2
%86 = add nsw i32 %85, 32
store i32 %86, i32* %2
%87 = load i32, i32* %3
%88 = add nsw i32 %87, 256
store i32 %88, i32* %3
br label %71
89: ; preds = %71
%90 = call i32 @gettimeofday(%struct.timeval* %9, i32 0)
%91 = load i8*, i8** %6
%92 = load i8*, i8** %7
%93 = call i32 @check_results(i32 256000000, i8* %91, i8* %92)
%94 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%95 = load i32, i32* %94
%96 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%97 = load i32, i32* %96
%98 = call double @time_diff(i32 %95, i32 %97)
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), double %98)
%100 = call i32 @gettimeofday(%struct.timeval* %8, i32 0)
store i32 0, i32* %2
store i32 0, i32* %3
br label %101
101: ; preds = %114, %89
%102 = load i32, i32* %2
%103 = icmp slt i32 %102, 1000000
br i1 %103, label %104, label %119
104: ; preds = %101
%105 = load i8*, i8** %5
%106 = load i32, i32* %2
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds i8, i8* %105, i64 %107
%109 = load i8*, i8** %7
%110 = load i32, i32* %3
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8, i8* %109, i64 %111
%113 = call i32 @convert2(i8* %108, i8* %112, i32 256, i32 0)
br label %114
114: ; preds = %104
%115 = load i32, i32* %2
%116 = add nsw i32 %115, 32
store i32 %116, i32* %2
%117 = load i32, i32* %3
%118 = add nsw i32 %117, 256
store i32 %118, i32* %3
br label %101
119: ; preds = %101
%120 = call i32 @gettimeofday(%struct.timeval* %9, i32 0)
%121 = load i8*, i8** %6
%122 = load i8*, i8** %7
%123 = call i32 @check_results(i32 256000000, i8* %121, i8* %122)
%124 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%125 = load i32, i32* %124
%126 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%127 = load i32, i32* %126
%128 = call double @time_diff(i32 %125, i32 %127)
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), double %128)
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
store i32 0, i32* %3
br label %131
131: ; preds = %144, %119
%132 = load i32, i32* %2
%133 = icmp slt i32 %132, 1000000
br i1 %133, label %134, label %149
134: ; preds = %131
%135 = load i8*, i8** %5
%136 = load i32, i32* %2
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds i8, i8* %135, i64 %137
%139 = load i8*, i8** %6
%140 = load i32, i32* %3
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds i8, i8* %139, i64 %141
%143 = call i32 @convert1(i8* %138, i8* %142, i32 256, i32 1)
br label %144
144: ; preds = %134
%145 = load i32, i32* %2
%146 = add nsw i32 %145, 32
store i32 %146, i32* %2
%147 = load i32, i32* %3
%148 = add nsw i32 %147, 256
store i32 %148, i32* %3
br label %131
149: ; preds = %131
store i32 0, i32* %2
store i32 0, i32* %3
br label %150
150: ; preds = %163, %149
%151 = load i32, i32* %2
%152 = icmp slt i32 %151, 1000000
br i1 %152, label %153, label %168
153: ; preds = %150
%154 = load i8*, i8** %5
%155 = load i32, i32* %2
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds i8, i8* %154, i64 %156
%158 = load i8*, i8** %7
%159 = load i32, i32* %3
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds i8, i8* %158, i64 %160
%162 = call i32 @convert1(i8* %157, i8* %161, i32 256, i32 1)
br label %163
163: ; preds = %153
%164 = load i32, i32* %2
%165 = add nsw i32 %164, 32
store i32 %165, i32* %2
%166 = load i32, i32* %3
%167 = add nsw i32 %166, 256
store i32 %167, i32* %3
br label %150
168: ; preds = %150
%169 = call i32 @gettimeofday(%struct.timeval* %8, i32 0)
store i32 0, i32* %2
store i32 0, i32* %3
br label %170
170: ; preds = %183, %168
%171 = load i32, i32* %2
%172 = icmp slt i32 %171, 1000000
br i1 %172, label %173, label %188
173: ; preds = %170
%174 = load i8*, i8** %5
%175 = load i32, i32* %2
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds i8, i8* %174, i64 %176
%178 = load i8*, i8** %7
%179 = load i32, i32* %3
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds i8, i8* %178, i64 %180
%182 = call i32 @convert1(i8* %177, i8* %181, i32 256, i32 1)
br label %183
183: ; preds = %173
%184 = load i32, i32* %2
%185 = add nsw i32 %184, 32
store i32 %185, i32* %2
%186 = load i32, i32* %3
%187 = add nsw i32 %186, 256
store i32 %187, i32* %3
br label %170
188: ; preds = %170
%189 = call i32 @gettimeofday(%struct.timeval* %9, i32 0)
%190 = load i8*, i8** %6
%191 = load i8*, i8** %7
%192 = call i32 @check_results(i32 256000000, i8* %190, i8* %191)
%193 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%194 = load i32, i32* %193
%195 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%196 = load i32, i32* %195
%197 = call double @time_diff(i32 %194, i32 %196)
%198 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), double %197)
%199 = call i32 @gettimeofday(%struct.timeval* %8, i32 0)
store i32 0, i32* %2
store i32 0, i32* %3
br label %200
200: ; preds = %213, %188
%201 = load i32, i32* %2
%202 = icmp slt i32 %201, 1000000
br i1 %202, label %203, label %218
203: ; preds = %200
%204 = load i8*, i8** %5
%205 = load i32, i32* %2
%206 = sext i32 %205 to i64
%207 = getelementptr inbounds i8, i8* %204, i64 %206
%208 = load i8*, i8** %7
%209 = load i32, i32* %3
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds i8, i8* %208, i64 %210
%212 = call i32 @convert2(i8* %207, i8* %211, i32 256, i32 1)
br label %213
213: ; preds = %203
%214 = load i32, i32* %2
%215 = add nsw i32 %214, 32
store i32 %215, i32* %2
%216 = load i32, i32* %3
%217 = add nsw i32 %216, 256
store i32 %217, i32* %3
br label %200
218: ; preds = %200
%219 = call i32 @gettimeofday(%struct.timeval* %9, i32 0)
%220 = load i8*, i8** %6
%221 = load i8*, i8** %7
%222 = call i32 @check_results(i32 256000000, i8* %220, i8* %221)
%223 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%224 = load i32, i32* %223
%225 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%226 = load i32, i32* %225
%227 = call double @time_diff(i32 %224, i32 %226)
%228 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), double %227)
%229 = load i8*, i8** %5
%230 = call i32 @free(i8* %229)
%231 = load i8*, i8** %6
%232 = call i32 @free(i8* %231)
%233 = load i8*, i8** %7
%234 = call i32 @free(i8* %233)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str.1 = [29 x i8] c" Standard Time = %.4f s\0A\00"
@.str.2 = [29 x i8] c" New Method Time = %.4f s\0A\00"
@str = [20 x i8] c"Increasing freqs...\00"
@str.4 = [20 x i8] c"Decreasing freqs...\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timeval* %2 to i8*
%5 = tail call i64 @malloc(i32 32000000)
%6 = tail call i64 @malloc(i32 256000000)
%7 = tail call i64 @malloc(i32 256000000)
%8 = inttoptr i64 %5 to i64*
br label %9
9: ; preds = %0, %9
%10 = phi i64 [ 0, %0 ], [ %13, %9 ]
%11 = tail call i64 (...) @random()
%12 = getelementptr inbounds i64, i64* %8, i64 %10
store i64 %11, i64* %12
%13 = add nuw nsw i64 %10, 1
%14 = icmp eq i64 %13, 8000000
br i1 %14, label %15, label %9
15: ; preds = %9
%16 = inttoptr i64 %5 to i8*
%17 = inttoptr i64 %6 to i8*
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %19
19: ; preds = %15, %19
%20 = phi i64 [ 0, %15 ], [ %26, %19 ]
%21 = phi i64 [ 0, %15 ], [ %25, %19 ]
%22 = getelementptr inbounds i8, i8* %16, i64 %21
%23 = getelementptr inbounds i8, i8* %17, i64 %20
%24 = tail call i32 @convert1(i8* %22, i8* %23, i32 256, i32 0)
%25 = add nuw nsw i64 %21, 32
%26 = add nuw nsw i64 %20, 256
%27 = icmp ult i64 %21, 999968
br i1 %27, label %19, label %28
28: ; preds = %19
%29 = inttoptr i64 %7 to i8*
br label %30
30: ; preds = %28, %30
%31 = phi i64 [ 0, %28 ], [ %37, %30 ]
%32 = phi i64 [ 0, %28 ], [ %36, %30 ]
%33 = getelementptr inbounds i8, i8* %16, i64 %32
%34 = getelementptr inbounds i8, i8* %29, i64 %31
%35 = tail call i32 @convert1(i8* %33, i8* %34, i32 256, i32 0)
%36 = add nuw nsw i64 %32, 32
%37 = add nuw nsw i64 %31, 256
%38 = icmp ult i64 %32, 999968
br i1 %38, label %30, label %39
39: ; preds = %30
%40 = call i32 @gettimeofday(%struct.timeval* %1, i32 0)
br label %41
41: ; preds = %39, %41
%42 = phi i64 [ 0, %39 ], [ %48, %41 ]
%43 = phi i64 [ 0, %39 ], [ %47, %41 ]
%44 = getelementptr inbounds i8, i8* %16, i64 %43
%45 = getelementptr inbounds i8, i8* %29, i64 %42
%46 = call i32 @convert1(i8* %44, i8* %45, i32 256, i32 0)
%47 = add nuw nsw i64 %43, 32
%48 = add nuw nsw i64 %42, 256
%49 = icmp ult i64 %43, 999968
br i1 %49, label %41, label %50
50: ; preds = %41
%51 = call i32 @gettimeofday(%struct.timeval* %2, i32 0)
%52 = call i32 @check_results(i32 256000000, i8* %17, i8* %29)
%53 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%54 = load i32, i32* %53
%55 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%56 = load i32, i32* %55
%57 = call double @time_diff(i32 %54, i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), double %57)
%59 = call i32 @gettimeofday(%struct.timeval* %1, i32 0)
br label %60
60: ; preds = %50, %60
%61 = phi i64 [ 0, %50 ], [ %67, %60 ]
%62 = phi i64 [ 0, %50 ], [ %66, %60 ]
%63 = getelementptr inbounds i8, i8* %16, i64 %62
%64 = getelementptr inbounds i8, i8* %29, i64 %61
%65 = call i32 @convert2(i8* %63, i8* %64, i32 256, i32 0)
%66 = add nuw nsw i64 %62, 32
%67 = add nuw nsw i64 %61, 256
%68 = icmp ult i64 %62, 999968
br i1 %68, label %60, label %69
69: ; preds = %60
%70 = call i32 @gettimeofday(%struct.timeval* %2, i32 0)
%71 = call i32 @check_results(i32 256000000, i8* %17, i8* %29)
%72 = load i32, i32* %53
%73 = load i32, i32* %55
%74 = call double @time_diff(i32 %72, i32 %73)
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), double %74)
%76 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.4, i64 0, i64 0))
br label %77
77: ; preds = %69, %77
%78 = phi i64 [ 0, %69 ], [ %84, %77 ]
%79 = phi i64 [ 0, %69 ], [ %83, %77 ]
%80 = getelementptr inbounds i8, i8* %16, i64 %79
%81 = getelementptr inbounds i8, i8* %17, i64 %78
%82 = call i32 @convert1(i8* %80, i8* %81, i32 256, i32 1)
%83 = add nuw nsw i64 %79, 32
%84 = add nuw nsw i64 %78, 256
%85 = icmp ult i64 %79, 999968
br i1 %85, label %77, label %86
86: ; preds = %77, %86
%87 = phi i64 [ %93, %86 ], [ 0, %77 ]
%88 = phi i64 [ %92, %86 ], [ 0, %77 ]
%89 = getelementptr inbounds i8, i8* %16, i64 %88
%90 = getelementptr inbounds i8, i8* %29, i64 %87
%91 = call i32 @convert1(i8* %89, i8* %90, i32 256, i32 1)
%92 = add nuw nsw i64 %88, 32
%93 = add nuw nsw i64 %87, 256
%94 = icmp ult i64 %88, 999968
br i1 %94, label %86, label %95
95: ; preds = %86
%96 = call i32 @gettimeofday(%struct.timeval* %1, i32 0)
br label %97
97: ; preds = %95, %97
%98 = phi i64 [ 0, %95 ], [ %104, %97 ]
%99 = phi i64 [ 0, %95 ], [ %103, %97 ]
%100 = getelementptr inbounds i8, i8* %16, i64 %99
%101 = getelementptr inbounds i8, i8* %29, i64 %98
%102 = call i32 @convert1(i8* %100, i8* %101, i32 256, i32 1)
%103 = add nuw nsw i64 %99, 32
%104 = add nuw nsw i64 %98, 256
%105 = icmp ult i64 %99, 999968
br i1 %105, label %97, label %106
106: ; preds = %97
%107 = call i32 @gettimeofday(%struct.timeval* %2, i32 0)
%108 = call i32 @check_results(i32 256000000, i8* %17, i8* %29)
%109 = load i32, i32* %53
%110 = load i32, i32* %55
%111 = call double @time_diff(i32 %109, i32 %110)
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), double %111)
%113 = call i32 @gettimeofday(%struct.timeval* %1, i32 0)
br label %114
114: ; preds = %106, %114
%115 = phi i64 [ 0, %106 ], [ %121, %114 ]
%116 = phi i64 [ 0, %106 ], [ %120, %114 ]
%117 = getelementptr inbounds i8, i8* %16, i64 %116
%118 = getelementptr inbounds i8, i8* %29, i64 %115
%119 = call i32 @convert2(i8* %117, i8* %118, i32 256, i32 1)
%120 = add nuw nsw i64 %116, 32
%121 = add nuw nsw i64 %115, 256
%122 = icmp ult i64 %116, 999968
br i1 %122, label %114, label %123
123: ; preds = %114
%124 = call i32 @gettimeofday(%struct.timeval* %2, i32 0)
%125 = call i32 @check_results(i32 256000000, i8* %17, i8* %29)
%126 = load i32, i32* %53
%127 = load i32, i32* %55
%128 = call double @time_diff(i32 %126, i32 %127)
%129 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), double %128)
%130 = call i32 @free(i8* %16)
%131 = call i32 @free(i8* %17)
%132 = call i32 @free(i8* %29)
ret i32 0
}