#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 */
struct rusage {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ getrusage(int /*<<< orphan*/, struct rusage *);
void benchmark_null(struct rusage *_start, struct rusage *_finish,
                    unsigned long int *_num_iterations) {
  unsigned long int i;
  *_num_iterations *= 100;
  getrusage(RUSAGE_SELF, _start);
  unsigned int x = 0;
  for (i = 0; i < *_num_iterations; i++) {
    x <<= 1;
    x |= 1;
    x &= 0xff;
    x ^= 0xff;
  }
  getrusage(RUSAGE_SELF, _finish);
}


x86 assembly (clang, -O0):
<benchmark_null>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
imul   $0x64,(%rax),%rcx
mov    %rcx,(%rax)
mov    0x2eaa(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
call   1030 <getrusage@plt>
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
jae    119a <benchmark_null+0x8a>
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
xor    $0xff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1150 <benchmark_null+0x40>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
call   1030 <getrusage@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<benchmark_null>:
push   %r14
push   %rbx
push   %rax
imul   $0x64,(%rdx),%rax
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    %rax,(%rdx)
mov    0x2eb8(%rip),%r14
mov    (%r14),%edi
call   1030 <getrusage@plt>
mov    (%r14),%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <getrusage@plt>

LLVM IR (-O0):
%struct.rusage = type { i32 }
@RUSAGE_SELF = global i32 0
define void @benchmark_null(%struct.rusage* %0, %struct.rusage* %1, i64* %2) {
%4 = alloca %struct.rusage*
%5 = alloca %struct.rusage*
%6 = alloca i64*
%7 = alloca i64
%8 = alloca i32
store %struct.rusage* %0, %struct.rusage** %4
store %struct.rusage* %1, %struct.rusage** %5
store i64* %2, i64** %6
%9 = load i64*, i64** %6
%10 = load i64, i64* %9
%11 = mul i64 %10, 100
store i64 %11, i64* %9
%12 = load i32, i32* @RUSAGE_SELF
%13 = load %struct.rusage*, %struct.rusage** %4
%14 = call i32 @getrusage(i32 %12, %struct.rusage* %13)
store i32 0, i32* %8
store i64 0, i64* %7
br label %15
15: ; preds = %29, %3
%16 = load i64, i64* %7
%17 = load i64*, i64** %6
%18 = load i64, i64* %17
%19 = icmp ult i64 %16, %18
br i1 %19, label %20, label %32
20: ; preds = %15
%21 = load i32, i32* %8
%22 = shl i32 %21, 1
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = or i32 %23, 1
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = and i32 %25, 255
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = xor i32 %27, 255
store i32 %28, i32* %8
br label %29
29: ; preds = %20
%30 = load i64, i64* %7
%31 = add i64 %30, 1
store i64 %31, i64* %7
br label %15
32: ; preds = %15
%33 = load i32, i32* @RUSAGE_SELF
%34 = load %struct.rusage*, %struct.rusage** %5
%35 = call i32 @getrusage(i32 %33, %struct.rusage* %34)
ret void
}

LLVM IR (-O2):
%struct.rusage = type { i32 }
@RUSAGE_SELF = global i32 0
define void @benchmark_null(%struct.rusage* %0, %struct.rusage* %1, i64* nocapture %2) {
%4 = load i64, i64* %2
%5 = mul i64 %4, 100
store i64 %5, i64* %2
%6 = load i32, i32* @RUSAGE_SELF
%7 = tail call i32 @getrusage(i32 %6, %struct.rusage* %0)
%8 = load i32, i32* @RUSAGE_SELF
%9 = tail call i32 @getrusage(i32 %8, %struct.rusage* %1)
ret void
}