#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 /*<<< orphan*/ uint64_t;
typedef int /*<<< orphan*/ off_t;

/* Variables and functions */
int /*<<< orphan*/ write_msr_single_core(int, int, int /*<<< orphan*/,
                                         int /*<<< orphan*/);
void write_msr_all_cores(int socket, off_t msr, uint64_t val) {
  int j;
  for (j = 0; j < 8; j++) {
    write_msr_single_core(socket, j, msr, val);
  }
}


x86 assembly (clang, -O0):
<write_msr_all_cores>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    1151 <write_msr_all_cores+0x41>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1030 <write_msr_single_core@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1128 <write_msr_all_cores+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_msr_all_cores>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
xor    %esi,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1030 <write_msr_single_core@plt>
mov    %ebx,%edi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1030 <write_msr_single_core@plt>
mov    %ebx,%edi
mov    $0x2,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1030 <write_msr_single_core@plt>
mov    %ebx,%edi
mov    $0x3,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1030 <write_msr_single_core@plt>
mov    %ebx,%edi
mov    $0x4,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1030 <write_msr_single_core@plt>
mov    %ebx,%edi
mov    $0x5,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1030 <write_msr_single_core@plt>
mov    %ebx,%edi
mov    $0x6,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1030 <write_msr_single_core@plt>
mov    %ebx,%edi
mov    $0x7,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <write_msr_single_core@plt>

LLVM IR (-O0):
define void @write_msr_all_cores(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %17, %3
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = load i32, i32* %4
%13 = load i32, i32* %7
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = call i32 @write_msr_single_core(i32 %12, i32 %13, i32 %14, i32 %15)
br label %17
17: ; preds = %11
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 1
store i32 %19, i32* %7
br label %8
20: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @write_msr_all_cores(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @write_msr_single_core(i32 %0, i32 0, i32 %1, i32 %2)
%5 = tail call i32 @write_msr_single_core(i32 %0, i32 1, i32 %1, i32 %2)
%6 = tail call i32 @write_msr_single_core(i32 %0, i32 2, i32 %1, i32 %2)
%7 = tail call i32 @write_msr_single_core(i32 %0, i32 3, i32 %1, i32 %2)
%8 = tail call i32 @write_msr_single_core(i32 %0, i32 4, i32 %1, i32 %2)
%9 = tail call i32 @write_msr_single_core(i32 %0, i32 5, i32 %1, i32 %2)
%10 = tail call i32 @write_msr_single_core(i32 %0, i32 6, i32 %1, i32 %2)
%11 = tail call i32 @write_msr_single_core(i32 %0, i32 7, i32 %1, i32 %2)
ret void
}