#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*/ int32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ run_memory_benchmark32(int /*<<< orphan*/);
int /*<<< orphan*/ run_memory_benchmark8(int /*<<< orphan*/);
int /*<<< orphan*/ run_memory_benchmark_asm(int /*<<< orphan*/);
void memset_benchmark(int32_t reps) {
  printf("8-bit memset\n");
  run_memory_benchmark8(reps);
  printf("32-bit memset\n");
  run_memory_benchmark32(reps);
  printf("Assembly 64-bit copy\n");
  run_memory_benchmark_asm(reps);
}


x86 assembly (clang, -O0):
<memset_benchmark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xeae(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
call   1040 <run_memory_benchmark8@plt>
lea    0xea8(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
call   1030 <run_memory_benchmark32@plt>
lea    0xea3(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
call   1060 <run_memory_benchmark_asm@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memset_benchmark>:
push   %rbx
mov    %edi,%ebx
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1050 <run_memory_benchmark8@plt>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1040 <run_memory_benchmark32@plt>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
pop    %rbx
jmp    1060 <run_memory_benchmark_asm@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"8-bit memset\0A\00"
@.str.1 = [15 x i8] c"32-bit memset\0A\00"
@.str.2 = [22 x i8] c"Assembly 64-bit copy\0A\00"
define void @memset_benchmark(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
%5 = call i32 @run_memory_benchmark8(i32 %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* %2
%8 = call i32 @run_memory_benchmark32(i32 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* %2
%11 = call i32 @run_memory_benchmark_asm(i32 %10)
ret void
}

LLVM IR (-O2):
@str = [13 x i8] c"8-bit memset\00"
@str.3 = [14 x i8] c"32-bit memset\00"
@str.4 = [21 x i8] c"Assembly 64-bit copy\00"
define void @memset_benchmark(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @run_memory_benchmark8(i32 %0)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.3, i64 0, i64 0))
%5 = tail call i32 @run_memory_benchmark32(i32 %0)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.4, i64 0, i64 0))
%7 = tail call i32 @run_memory_benchmark_asm(i32 %0)
ret void
}