#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*/ fprintf(int /*<<< orphan*/, char *, int, char *, int, float,
                           int);
int pow(int, int);
int /*<<< orphan*/ stderr;
int work_counter_parallel(int, int, int);
void counter_4() {
  float out_time;
  int n;
  int lock_mode;
  for (int m = 0; m < 5; m++) {
    lock_mode = pow(2, m);
    out_time = 0;
    for (int n_base = 0; n_base < 7; n_base++) {
      n = pow(2, n_base);
      for (short iter = 0; iter < 3; iter++) {
        out_time += work_counter_parallel(1000000, n, lock_mode) / 3;
      }
      fprintf(stderr, "%i\t%s\t%i\t%f\t%i\n", 4, "COUNTER_4", n, out_time,
              lock_mode);
    }
  }
}


x86 assembly (clang, -O0):
<counter_4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x10(%rbp)
cmpl   $0x5,-0x10(%rbp)
jge    121b <counter_4+0xeb>
mov    -0x10(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %eax,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x7,-0x14(%rbp)
jge    1208 <counter_4+0xd8>
mov    -0x14(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %eax,-0x8(%rbp)
movw   $0x0,-0x16(%rbp)
movswl -0x16(%rbp),%eax
cmp    $0x3,%eax
jge    11cc <counter_4+0x9c>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    $0xf4240,%edi
call   1040 <work_counter_parallel@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
mov    -0x16(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x16(%rbp)
jmp    1188 <counter_4+0x58>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%r8d
movss  -0x4(%rbp),%xmm0
mov    -0xc(%rbp),%r9d
lea    0xe17(%rip),%rsi
mov    $0x4,%edx
lea    0xe1b(%rip),%rcx
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1168 <counter_4+0x38>
jmp    120d <counter_4+0xdd>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113f <counter_4+0xf>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<counter_4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %esi,%esi
mov    0x2e9c(%rip),%r14
lea    0xeb5(%rip),%r15
lea    0xebe(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x2,%edi
mov    %esi,0x4(%rsp)
call   1050 <pow@plt>
mov    %eax,%r13d
xorps  %xmm0,%xmm0
movss  %xmm0,(%rsp)
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    $0x2,%edi
mov    %ebp,%esi
call   1050 <pow@plt>
mov    %eax,%ebx
mov    $0xf4240,%edi
mov    %eax,%esi
mov    %r13d,%edx
call   1040 <work_counter_parallel@plt>
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  (%rsp),%xmm0
movss  %xmm0,(%rsp)
mov    $0xf4240,%edi
mov    %ebx,%esi
mov    %r13d,%edx
call   1040 <work_counter_parallel@plt>
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  (%rsp),%xmm0
movss  %xmm0,(%rsp)
mov    $0xf4240,%edi
mov    %ebx,%esi
mov    %r13d,%edx
call   1040 <work_counter_parallel@plt>
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  (%rsp),%xmm0
mov    (%r14),%edi
mov    %r15,%rsi
mov    $0x4,%edx
mov    %r12,%rcx
mov    %ebx,%r8d
movss  %xmm0,(%rsp)
mov    %r13d,%r9d
call   1030 <fprintf@plt>
add    $0x1,%ebp
cmp    $0x7,%ebp
jne    1180 <counter_4+0x50>
mov    0x4(%rsp),%esi
add    $0x1,%esi
cmp    $0x5,%esi
jne    1160 <counter_4+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"%i\09%s\09%i\09%f\09%i\0A\00"
@.str.1 = [10 x i8] c"COUNTER_4\00"
define void @counter_4() {
%1 = alloca float
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i16
store i32 0, i32* %4
br label %7
7: ; preds = %44, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 5
br i1 %9, label %10, label %47
10: ; preds = %7
%11 = load i32, i32* %4
%12 = call i32 @pow(i32 2, i32 %11)
store i32 %12, i32* %3
store float 0.000000e+00, float* %1
store i32 0, i32* %5
br label %13
13: ; preds = %40, %10
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 7
br i1 %15, label %16, label %43
16: ; preds = %13
%17 = load i32, i32* %5
%18 = call i32 @pow(i32 2, i32 %17)
store i32 %18, i32* %2
store i16 0, i16* %6
br label %19
19: ; preds = %31, %16
%20 = load i16, i16* %6
%21 = sext i16 %20 to i32
%22 = icmp slt i32 %21, 3
br i1 %22, label %23, label %34
23: ; preds = %19
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 @work_counter_parallel(i32 1000000, i32 %24, i32 %25)
%27 = sdiv i32 %26, 3
%28 = sitofp i32 %27 to float
%29 = load float, float* %1
%30 = fadd float %29, %28
store float %30, float* %1
br label %31
31: ; preds = %23
%32 = load i16, i16* %6
%33 = add i16 %32, 1
store i16 %33, i16* %6
br label %19
34: ; preds = %19
%35 = load i32, i32* @stderr
%36 = load i32, i32* %2
%37 = load float, float* %1
%38 = load i32, i32* %3
%39 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %36, float %37, i32 %38)
br label %40
40: ; preds = %34
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %13
43: ; preds = %13
br label %44
44: ; preds = %43
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %7
47: ; preds = %7
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"%i\09%s\09%i\09%f\09%i\0A\00"
@.str.1 = [10 x i8] c"COUNTER_4\00"
define void @counter_4() {
br label %2
1: ; preds = %5
ret void
2: ; preds = %0, %5
%3 = phi i32 [ 0, %0 ], [ %6, %5 ]
%4 = tail call i32 @pow(i32 2, i32 %3)
br label %8
5: ; preds = %8
%6 = add nuw nsw i32 %3, 1
%7 = icmp eq i32 %6, 5
br i1 %7, label %1, label %2
8: ; preds = %2, %8
%9 = phi i32 [ 0, %2 ], [ %26, %8 ]
%10 = phi float [ 0.000000e+00, %2 ], [ %23, %8 ]
%11 = tail call i32 @pow(i32 2, i32 %9)
%12 = tail call i32 @work_counter_parallel(i32 1000000, i32 %11, i32 %4)
%13 = sdiv i32 %12, 3
%14 = sitofp i32 %13 to float
%15 = fadd float %10, %14
%16 = tail call i32 @work_counter_parallel(i32 1000000, i32 %11, i32 %4)
%17 = sdiv i32 %16, 3
%18 = sitofp i32 %17 to float
%19 = fadd float %15, %18
%20 = tail call i32 @work_counter_parallel(i32 1000000, i32 %11, i32 %4)
%21 = sdiv i32 %20, 3
%22 = sitofp i32 %21 to float
%23 = fadd float %19, %22
%24 = load i32, i32* @stderr
%25 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %11, float %23, i32 %4)
%26 = add nuw nsw i32 %9, 1
%27 = icmp eq i32 %26, 7
br i1 %27, label %5, label %8
}