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

/* Variables and functions */
int /*<<< orphan*/ cfg_number(char *, char const *, int const, int, int, int *);
int /*<<< orphan*/ message(int, char *, char const *, char const *, int const,
                           char const *, ...);
int /*<<< orphan*/ qprintf(char *, int, char *, char const *);
unsigned long timing(const char *driver, const char *section, const char *name,
                     const int defval, const char *unit) {
  char sec[256];
  int fuzz, val;
  qprintf(sec, sizeof(sec), "%s.Timing", section);
  cfg_number(sec, "fuzz", 100, 1, -1, &fuzz);
  cfg_number(sec, name, defval, 0, -1, &val);
  val = val * fuzz / 100;
  if (val != defval) {
    if (fuzz != 100) {
      message(1, "%s: timing: %6s = %5d %s (default %d %s, fuzz %d)", driver,
              name, val, unit, defval, unit, fuzz);
    } else {
      message(1, "%s: timing: %6s = %5d %s (default %d %s)", driver, name, val,
              unit, defval, unit);
    }
  } else {
    message(1, "%s: timing: %6s = %5d %s (default)", driver, name, defval,
            unit);
  }
  return val;
}


x86 assembly (clang, -O0):
<timing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x100,%esi
lea    0xe9b(%rip),%rdx
call   1050 <qprintf@plt>
lea    -0x130(%rbp),%rdi
lea    0xe92(%rip),%rsi
mov    $0x64,%edx
mov    $0x1,%ecx
mov    $0xffffffff,%r8d
lea    -0x134(%rbp),%r9
call   1040 <cfg_number@plt>
lea    -0x130(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
xor    %ecx,%ecx
mov    $0xffffffff,%r8d
lea    -0x138(%rbp),%r9
call   1040 <cfg_number@plt>
mov    -0x138(%rbp),%eax
imul   -0x134(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x138(%rbp)
mov    -0x138(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     126f <timing+0x13f>
cmpl   $0x64,-0x134(%rbp)
je     1233 <timing+0x103>
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x138(%rbp),%r8d
mov    -0x28(%rbp),%r9
mov    -0x1c(%rbp),%r11d
mov    -0x28(%rbp),%r10
mov    -0x134(%rbp),%eax
mov    $0x1,%edi
lea    0xdf5(%rip),%rsi
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1030 <message@plt>
jmp    126a <timing+0x13a>
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x138(%rbp),%r8d
mov    -0x28(%rbp),%r9
mov    -0x1c(%rbp),%r10d
mov    -0x28(%rbp),%rax
mov    $0x1,%edi
lea    0xde7(%rip),%rsi
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1030 <message@plt>
jmp    1292 <timing+0x162>
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
mov    -0x28(%rbp),%r9
mov    $0x1,%edi
lea    0xddf(%rip),%rsi
mov    $0x0,%al
call   1030 <message@plt>
movslq -0x138(%rbp),%rax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timing>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x110,%rsp
mov    %r8,%r14
mov    %ecx,%r13d
mov    %rdx,%r15
mov    %rsi,%rcx
mov    %rdi,%r12
lea    0xeaa(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1050 <qprintf@plt>
lea    0xe9b(%rip),%rsi
lea    0xc(%rsp),%r9
mov    %rbx,%rdi
mov    $0x64,%edx
mov    $0x1,%ecx
mov    $0xffffffff,%r8d
call   1040 <cfg_number@plt>
lea    0x8(%rsp),%r9
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
xor    %ecx,%ecx
mov    $0xffffffff,%r8d
call   1040 <cfg_number@plt>
mov    0xc(%rsp),%ebx
mov    0x8(%rsp),%eax
imul   %ebx,%eax
cltq
imul   $0x51eb851f,%rax,%r8
mov    %r8,%rax
shr    $0x3f,%rax
sar    $0x25,%r8
add    %eax,%r8d
mov    %r8d,0x8(%rsp)
cmp    %r13d,%r8d
jne    11f4 <timing+0xc4>
lea    0xe90(%rip),%rsi
mov    $0x1,%edi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r13d,%r8d
mov    %r14,%r9
xor    %eax,%eax
call   1030 <message@plt>
jmp    1248 <timing+0x118>
cmp    $0x64,%ebx
jne    121f <timing+0xef>
lea    0xe41(%rip),%rsi
mov    $0x1,%edi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r9
xor    %eax,%eax
push   %r14
push   %r13
call   1030 <message@plt>
add    $0x10,%rsp
jmp    1248 <timing+0x118>
sub    $0x8,%rsp
lea    0xde5(%rip),%rsi
mov    $0x1,%edi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r9
xor    %eax,%eax
push   %rbx
push   %r14
push   %r13
call   1030 <message@plt>
add    $0x20,%rsp
movslq 0x8(%rsp),%rax
add    $0x110,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%s.Timing\00"
@.str.1 = [5 x i8] c"fuzz\00"
@.str.2 = [50 x i8] c"%s: timing: %6s = %5d %s (default %d %s, fuzz %d)\00"
@.str.3 = [41 x i8] c"%s: timing: %6s = %5d %s (default %d %s)\00"
@.str.4 = [35 x i8] c"%s: timing: %6s = %5d %s (default)\00"
define i64 @timing(i8* %0, i8* %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca [256 x i8]
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%15 = load i8*, i8** %7
%16 = call i32 @qprintf(i8* %14, i32 256, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%18 = call i32 @cfg_number(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 100, i32 1, i32 -1, i32* %12)
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%20 = load i8*, i8** %8
%21 = load i32, i32* %9
%22 = call i32 @cfg_number(i8* %19, i8* %20, i32 %21, i32 0, i32 -1, i32* %13)
%23 = load i32, i32* %13
%24 = load i32, i32* %12
%25 = mul nsw i32 %23, %24
%26 = sdiv i32 %25, 100
store i32 %26, i32* %13
%27 = load i32, i32* %13
%28 = load i32, i32* %9
%29 = icmp ne i32 %27, %28
br i1 %29, label %30, label %51
30: ; preds = %5
%31 = load i32, i32* %12
%32 = icmp ne i32 %31, 100
br i1 %32, label %33, label %42
33: ; preds = %30
%34 = load i8*, i8** %6
%35 = load i8*, i8** %8
%36 = load i32, i32* %13
%37 = load i8*, i8** %10
%38 = load i32, i32* %9
%39 = load i8*, i8** %10
%40 = load i32, i32* %12
%41 = call i32 (i32, i8*, i8*, i8*, i32, i8*, ...) @message(i32 1, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i8* %34, i8* %35, i32 %36, i8* %37, i32 %38, i8* %39, i32 %40)
br label %50
42: ; preds = %30
%43 = load i8*, i8** %6
%44 = load i8*, i8** %8
%45 = load i32, i32* %13
%46 = load i8*, i8** %10
%47 = load i32, i32* %9
%48 = load i8*, i8** %10
%49 = call i32 (i32, i8*, i8*, i8*, i32, i8*, ...) @message(i32 1, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* %43, i8* %44, i32 %45, i8* %46, i32 %47, i8* %48)
br label %50
50: ; preds = %42, %33
br label %57
51: ; preds = %5
%52 = load i8*, i8** %6
%53 = load i8*, i8** %8
%54 = load i32, i32* %9
%55 = load i8*, i8** %10
%56 = call i32 (i32, i8*, i8*, i8*, i32, i8*, ...) @message(i32 1, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %52, i8* %53, i32 %54, i8* %55)
br label %57
57: ; preds = %51, %50
%58 = load i32, i32* %13
%59 = sext i32 %58 to i64
ret i64 %59
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s.Timing\00"
@.str.1 = [5 x i8] c"fuzz\00"
@.str.2 = [50 x i8] c"%s: timing: %6s = %5d %s (default %d %s, fuzz %d)\00"
@.str.3 = [41 x i8] c"%s: timing: %6s = %5d %s (default %d %s)\00"
@.str.4 = [35 x i8] c"%s: timing: %6s = %5d %s (default)\00"
define i64 @timing(i8* %0, i8* %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca [256 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%10 = bitcast i32* %7 to i8*
%11 = bitcast i32* %8 to i8*
%12 = call i32 @qprintf(i8* %9, i32 256, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %1)
%13 = call i32 @cfg_number(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 100, i32 1, i32 -1, i32* %7)
%14 = call i32 @cfg_number(i8* %9, i8* %2, i32 %3, i32 0, i32 -1, i32* %8)
%15 = load i32, i32* %8
%16 = load i32, i32* %7
%17 = mul nsw i32 %16, %15
%18 = sdiv i32 %17, 100
store i32 %18, i32* %8
%19 = icmp eq i32 %18, %3
br i1 %19, label %26, label %20
20: ; preds = %5
%21 = icmp eq i32 %16, 100
br i1 %21, label %24, label %22
22: ; preds = %20
%23 = call i32 (i32, i8*, i8*, i8*, i32, i8*, ...) @message(i32 1, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %2, i32 %18, i8* %4, i32 %3, i8* %4, i32 %16)
br label %28
24: ; preds = %20
%25 = call i32 (i32, i8*, i8*, i8*, i32, i8*, ...) @message(i32 1, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* %2, i32 %18, i8* %4, i32 %3, i8* %4)
br label %28
26: ; preds = %5
%27 = call i32 (i32, i8*, i8*, i8*, i32, i8*, ...) @message(i32 1, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* %2, i32 %3, i8* %4)
br label %28
28: ; preds = %22, %24, %26
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
ret i64 %30
}