#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 *, double);
int /*<<< orphan*/ pthread_exit(void *);
void *BusyWork(void *null) {
  int i;
  double result = 0.0;
  for (i = 0; i < 1000000; i++) {
    result = result + 10;
  }
  printf("result = %e\n", result);
  pthread_exit((void *)0);
}


x86 assembly (clang, -O0):
<BusyWork>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xf4240,-0x14(%rbp)
jge    1168 <BusyWork+0x48>
movsd  0xeb0(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113b <BusyWork+0x1b>
movsd  -0x20(%rbp),%xmm0
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <pthread_exit@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BusyWork>:
push   %rax
xorpd  %xmm0,%xmm0
mov    $0xf4240,%eax
movsd  0xece(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
add    $0xfffffff6,%eax
jne    1140 <BusyWork+0x20>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
pop    %rax
jmp    1040 <pthread_exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"result = %e\0A\00"
define i8* @BusyWork(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca double
store i8* %0, i8** %3
store double 0.000000e+00, double* %5
store i32 0, i32* %4
br label %6
6: ; preds = %12, %1
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 1000000
br i1 %8, label %9, label %15
9: ; preds = %6
%10 = load double, double* %5
%11 = fadd double %10, 1.000000e+01
store double %11, double* %5
br label %12
12: ; preds = %9
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 1
store i32 %14, i32* %4
br label %6
15: ; preds = %6
%16 = load double, double* %5
%17 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %16)
%18 = call i32 @pthread_exit(i8* null)
%19 = load i8*, i8** %2
ret i8* %19
}

LLVM IR (-O2):
@.str = [13 x i8] c"result = %e\0A\00"
define noalias i8* @BusyWork(i8* nocapture readnone %0) {
br label %2
2: ; preds = %2, %1
%3 = phi double [ 0.000000e+00, %1 ], [ %14, %2 ]
%4 = phi i32 [ 0, %1 ], [ %15, %2 ]
%5 = fadd double %3, 1.000000e+01
%6 = fadd double %5, 1.000000e+01
%7 = fadd double %6, 1.000000e+01
%8 = fadd double %7, 1.000000e+01
%9 = fadd double %8, 1.000000e+01
%10 = fadd double %9, 1.000000e+01
%11 = fadd double %10, 1.000000e+01
%12 = fadd double %11, 1.000000e+01
%13 = fadd double %12, 1.000000e+01
%14 = fadd double %13, 1.000000e+01
%15 = add nuw nsw i32 %4, 10
%16 = icmp eq i32 %15, 1000000
br i1 %16, label %17, label %2
17: ; preds = %2
%18 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %14)
%19 = tail call i32 @pthread_exit(i8* null)
ret i8* undef
}