#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 time_counter_parallel(int, int, int);
void counter_3() {
  float out_count;
  int n;
  int lock_mode;
  for (int m = 0; m < 5; m++) {
    for (int n_base = 0; n_base < 7; n_base++) {
      lock_mode = pow(2, m);
      n = pow(2, n_base);
      out_count = 0;
      for (short iter = 0; iter < 3; iter++) {
        out_count += time_counter_parallel(100000, n, lock_mode) / 3;
      }
      fprintf(stderr, "%i\t%s\t%i\t%f\t%i\n", 4, "COUNTER_3", n, out_count,
              lock_mode);
    }
  }
}


x86 assembly (clang, -O0):
<counter_3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x10(%rbp)
cmpl   $0x5,-0x10(%rbp)
jge    121b <counter_3+0xeb>
movl   $0x0,-0x14(%rbp)
cmpl   $0x7,-0x14(%rbp)
jge    1208 <counter_3+0xd8>
mov    -0x10(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %eax,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movw   $0x0,-0x16(%rbp)
movswl -0x16(%rbp),%eax
cmp    $0x3,%eax
jge    11cc <counter_3+0x9c>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    $0x186a0,%edi
call   1030 <time_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_3+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   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1150 <counter_3+0x20>
jmp    120d <counter_3+0xdd>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113f <counter_3+0xf>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<counter_3>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r12d,%r12d
xchg   %ax,%ax
xor    %ebp,%ebp
lea    0xeb7(%rip),%r15
lea    0xec0(%rip),%r14
mov    $0x2,%edi
mov    %r12d,%esi
call   1050 <pow@plt>
mov    %eax,%r13d
mov    $0x2,%edi
mov    %ebp,%esi
call   1050 <pow@plt>
mov    %eax,%ebx
mov    $0x186a0,%edi
mov    %eax,%esi
mov    %r13d,%edx
call   1030 <time_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
movss  %xmm0,0x4(%rsp)
mov    $0x186a0,%edi
mov    %ebx,%esi
mov    %r13d,%edx
call   1030 <time_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  0x4(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0x186a0,%edi
mov    %ebx,%esi
mov    %r13d,%edx
call   1030 <time_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  0x4(%rsp),%xmm0
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
mov    %r15,%rsi
mov    $0x4,%edx
mov    %r14,%rcx
mov    %ebx,%r8d
mov    %r13d,%r9d
call   1040 <fprintf@plt>
add    $0x1,%ebp
cmp    $0x7,%ebp
jne    1150 <counter_3+0x20>
add    $0x1,%r12d
cmp    $0x5,%r12d
jne    1140 <counter_3+0x10>
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_3\00"
define void @counter_3() {
%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
store i32 0, i32* %5
br label %11
11: ; preds = %40, %10
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 7
br i1 %13, label %14, label %43
14: ; preds = %11
%15 = load i32, i32* %4
%16 = call i32 @pow(i32 2, i32 %15)
store i32 %16, i32* %3
%17 = load i32, i32* %5
%18 = call i32 @pow(i32 2, i32 %17)
store i32 %18, i32* %2
store float 0.000000e+00, float* %1
store i16 0, i16* %6
br label %19
19: ; preds = %31, %14
%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 @time_counter_parallel(i32 100000, 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 %11
43: ; preds = %11
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_3\00"
define void @counter_3() {
br label %1
1: ; preds = %0, %4
%2 = phi i32 [ 0, %0 ], [ %5, %4 ]
br label %7
3: ; preds = %4
ret void
4: ; preds = %7
%5 = add nuw nsw i32 %2, 1
%6 = icmp eq i32 %5, 5
br i1 %6, label %3, label %1
7: ; preds = %1, %7
%8 = phi i32 [ 0, %1 ], [ %24, %7 ]
%9 = tail call i32 @pow(i32 2, i32 %2)
%10 = tail call i32 @pow(i32 2, i32 %8)
%11 = tail call i32 @time_counter_parallel(i32 100000, i32 %10, i32 %9)
%12 = sdiv i32 %11, 3
%13 = sitofp i32 %12 to float
%14 = tail call i32 @time_counter_parallel(i32 100000, i32 %10, i32 %9)
%15 = sdiv i32 %14, 3
%16 = sitofp i32 %15 to float
%17 = fadd float %13, %16
%18 = tail call i32 @time_counter_parallel(i32 100000, i32 %10, i32 %9)
%19 = sdiv i32 %18, 3
%20 = sitofp i32 %19 to float
%21 = fadd float %17, %20
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, 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 %10, float %21, i32 %9)
%24 = add nuw nsw i32 %8, 1
%25 = icmp eq i32 %24, 7
br i1 %25, label %4, label %7
}