#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 time_t;

/* Variables and functions */
char *ctime(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sortLoop0(int *, int);
int time(int /*<<< orphan*/ *);
void sortLoop(int *arr, int len) {
  time_t tt0 = time(NULL);
  printf("\tbefore sort:%s", ctime(&tt0));
  sortLoop0(arr, len);
  time_t tt1 = time(NULL);
  printf("\tafter sort:%s", ctime(&tt1));
  printf("\tsort the array cost %d(sec),%d(min)\n", (int)(tt1 - tt0),
         (int)((tt1 - tt0) / 60));
}


x86 assembly (clang, -O0):
<sortLoop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <sortLoop0@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%esi
sub    -0x10(%rbp),%esi
mov    -0x14(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sortLoop>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <ctime@plt>
lea    0xe9c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <sortLoop0@plt>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,(%rsp)
mov    %rsp,%rdi
call   1040 <ctime@plt>
lea    0xe7f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%eax
sub    0x4(%rsp),%eax
movslq %eax,%rsi
imul   $0xffffffff88888889,%rsi,%rdx
shr    $0x20,%rdx
add    %esi,%edx
mov    %edx,%eax
shr    $0x1f,%eax
sar    $0x5,%edx
add    %eax,%edx
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"\09before sort:%s\00"
@.str.1 = [15 x i8] c"\09after sort:%s\00"
@.str.2 = [38 x i8] c"\09sort the array cost %d(sec),%d(min)\0A\00"
define void @sortLoop(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = call i32 @time(i32* null)
store i32 %7, i32* %5
%8 = call i8* @ctime(i32* %5)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32*, i32** %3
%11 = load i32, i32* %4
%12 = call i32 @sortLoop0(i32* %10, i32 %11)
%13 = call i32 @time(i32* null)
store i32 %13, i32* %6
%14 = call i8* @ctime(i32* %6)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i32, i32* %6
%17 = load i32, i32* %5
%18 = sub nsw i32 %16, %17
%19 = load i32, i32* %6
%20 = load i32, i32* %5
%21 = sub nsw i32 %19, %20
%22 = sdiv i32 %21, 60
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %22)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"\09before sort:%s\00"
@.str.1 = [15 x i8] c"\09after sort:%s\00"
@.str.2 = [38 x i8] c"\09sort the array cost %d(sec),%d(min)\0A\00"
define void @sortLoop(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = tail call i32 @time(i32* null)
store i32 %6, i32* %3
%7 = call i8* @ctime(i32* %3)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = call i32 @sortLoop0(i32* %0, i32 %1)
%10 = bitcast i32* %4 to i8*
%11 = call i32 @time(i32* null)
store i32 %11, i32* %4
%12 = call i8* @ctime(i32* %4)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i32, i32* %4
%15 = load i32, i32* %3
%16 = sub nsw i32 %14, %15
%17 = sdiv i32 %16, 60
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %17)
ret void
}