#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 double clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ chdir(char *);
int /*<<< orphan*/ cleanup();
double clock();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ initialize();
int /*<<< orphan*/ printf(char *, char *, int);
size_t run(int);
int /*<<< orphan*/ stderr;
char *strrchr(char *, char);
int main(int argc, char *argv[]) {
  (void)argc;
  char *lastslash = strrchr(argv[0], '/');
  char *progname = argv[0];
  if (lastslash) {
    *lastslash = '\0';
    if (chdir(argv[0]) < 0) {
      fprintf(stderr, "Error changing directory to %s.\n", argv[0]);
      return 1;
    }
    *lastslash = '/';
    progname = lastslash + 3;
  }
  if (!initialize()) {
    fprintf(stderr, "%s: failed to initialize\n", argv[0]);
    return 1;
  }
  size_t total_bytes = 0;
  clock_t before = clock();
  for (int i = 0; true; i++) {
    if ((i & 0xFF) == 0 && (clock() - before > CLOCKS_PER_SEC))
      break;
    size_t bytes = run(i);
    if (bytes == 0) {
      fprintf(stderr, "%s: failed.\n", argv[0]);
      return 2;
    }
    total_bytes += bytes;
  }
  double elapsed = ((double)clock() - before) / CLOCKS_PER_SEC;
  printf("%s:%d\n", progname, (int)(total_bytes / elapsed / (1 << 20)));
  cleanup();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1219 <main+0x99>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
jge    1206 <main+0x86>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe3b(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1385 <main+0x205>
mov    -0x18(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x18(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1080 <initialize@plt>
cmp    $0x0,%eax
jne    1251 <main+0xd1>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe11(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1385 <main+0x205>
movq   $0x0,-0x28(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    127b <main+0xfb>
jmp    1307 <main+0x187>
mov    -0x34(%rbp),%eax
and    $0xff,%eax
cmp    $0x0,%eax
jne    12ae <main+0x12e>
mov    $0x0,%al
call   1030 <clock@plt>
subsd  -0x30(%rbp),%xmm0
mov    0x2d49(%rip),%rax
ucomisd (%rax),%xmm0
jbe    12ae <main+0x12e>
jmp    1307 <main+0x187>
mov    -0x34(%rbp),%edi
call   1040 <run@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    12ed <main+0x16d>
mov    0x2d0c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd8f(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1385 <main+0x205>
mov    -0x40(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    126c <main+0xec>
xor    %eax,%eax
call   1030 <clock@plt>
movsd  -0x30(%rbp),%xmm1
subsd  %xmm1,%xmm0
mov    0x2cca(%rip),%rax
movsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x20(%rbp),%rsi
movaps 0xcda(%rip),%xmm1
movq   -0x28(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xcd9(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  0xc9d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
lea    0xd06(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   10a0 <cleanup@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
mov    (%rsi),%r14
mov    %r14,%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
test   %rax,%rax
je     11c6 <main+0x46>
mov    %rax,%rbp
movb   $0x0,(%rax)
mov    (%r15),%rdi
call   1050 <chdir@plt>
test   %rax,%rax
js     1255 <main+0xd5>
movb   $0x2f,0x0(%rbp)
add    $0x3,%rbp
mov    %rbp,%r14
xor    %eax,%eax
call   1080 <initialize@plt>
test   %eax,%eax
je     1240 <main+0xc0>
xor    %eax,%eax
call   1030 <clock@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x2e03(%rip),%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
test   %bpl,%bpl
jne    1205 <main+0x85>
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <clock@plt>
subsd  0x8(%rsp),%xmm0
ucomisd (%r12),%xmm0
ja     1274 <main+0xf4>
mov    %ebp,%edi
call   1040 <run@plt>
test   %rax,%rax
je     121e <main+0x9e>
add    %rax,%rbx
add    $0x1,%ebp
test   %bpl,%bpl
jne    1205 <main+0x85>
jmp    11f0 <main+0x70>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xe32(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x2,%ebp
jmp    12d0 <main+0x150>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xdf6(%rip),%rsi
jmp    1268 <main+0xe8>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xdc0(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%ebp
jmp    12d0 <main+0x150>
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <clock@plt>
subsd  0x8(%rsp),%xmm0
divsd  (%r12),%xmm0
movq   %rbx,%xmm1
punpckldq 0xd6a(%rip),%xmm1
subpd  0xd72(%rip),%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
addsd  %xmm1,%xmm2
divsd  %xmm0,%xmm2
mulsd  0xd6a(%rip),%xmm2
cvttsd2si %xmm2,%edx
lea    0xdaf(%rip),%rdi
mov    %r14,%rsi
call   1060 <printf@plt>
xor    %eax,%eax
call   10a0 <cleanup@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"Error changing directory to %s.\0A\00"
@.str.1 = [26 x i8] c"%s: failed to initialize\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.2 = [13 x i8] c"%s: failed.\0A\00"
@.str.3 = [7 x i8] c"%s:%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca double
%10 = alloca i32
%11 = alloca i64
%12 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i8* @strrchr(i8* %16, i8 signext 47)
store i8* %17, i8** %6
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
store i8* %20, i8** %7
%21 = load i8*, i8** %6
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %40
23: ; preds = %2
%24 = load i8*, i8** %6
store i8 0, i8* %24
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i64 @chdir(i8* %27)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %23
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %34)
store i32 1, i32* %3
br label %96
36: ; preds = %23
%37 = load i8*, i8** %6
store i8 47, i8* %37
%38 = load i8*, i8** %6
%39 = getelementptr inbounds i8, i8* %38, i64 3
store i8* %39, i8** %7
br label %40
40: ; preds = %36, %2
%41 = call i32 (...) @initialize()
%42 = icmp ne i32 %41, 0
br i1 %42, label %49, label %43
43: ; preds = %40
%44 = load i32, i32* @stderr
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 0
%47 = load i8*, i8** %46
%48 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %47)
store i32 1, i32* %3
br label %96
49: ; preds = %40
store i64 0, i64* %8
%50 = call double (...) @clock()
store double %50, double* %9
store i32 0, i32* %10
br label %51
51: ; preds = %78, %49
br i1 true, label %52, label %81
52: ; preds = %51
%53 = load i32, i32* %10
%54 = and i32 %53, 255
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %63
56: ; preds = %52
%57 = call double (...) @clock()
%58 = load double, double* %9
%59 = fsub double %57, %58
%60 = load double, double* @CLOCKS_PER_SEC
%61 = fcmp ogt double %59, %60
br i1 %61, label %62, label %63
62: ; preds = %56
br label %81
63: ; preds = %56, %52
%64 = load i32, i32* %10
%65 = call i64 @run(i32 %64)
store i64 %65, i64* %11
%66 = load i64, i64* %11
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %74
68: ; preds = %63
%69 = load i32, i32* @stderr
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 0
%72 = load i8*, i8** %71
%73 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %72)
store i32 2, i32* %3
br label %96
74: ; preds = %63
%75 = load i64, i64* %11
%76 = load i64, i64* %8
%77 = add i64 %76, %75
store i64 %77, i64* %8
br label %78
78: ; preds = %74
%79 = load i32, i32* %10
%80 = add nsw i32 %79, 1
store i32 %80, i32* %10
br label %51
81: ; preds = %62, %51
%82 = call double (...) @clock()
%83 = load double, double* %9
%84 = fsub double %82, %83
%85 = load double, double* @CLOCKS_PER_SEC
%86 = fdiv double %84, %85
store double %86, double* %12
%87 = load i8*, i8** %7
%88 = load i64, i64* %8
%89 = uitofp i64 %88 to double
%90 = load double, double* %12
%91 = fdiv double %89, %90
%92 = fdiv double %91, 0x4130000000000000
%93 = fptosi double %92 to i32
%94 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %87, i32 %93)
%95 = call i32 (...) @cleanup()
store i32 0, i32* %3
br label %96
96: ; preds = %81, %68, %43, %30
%97 = load i32, i32* %3
ret i32 %97
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"Error changing directory to %s.\0A\00"
@.str.1 = [26 x i8] c"%s: failed to initialize\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.2 = [13 x i8] c"%s: failed.\0A\00"
@.str.3 = [7 x i8] c"%s:%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %3, i8 signext 47)
%5 = icmp eq i8* %4, null
br i1 %5, label %16, label %6
6: ; preds = %2
store i8 0, i8* %4
%7 = load i8*, i8** %1
%8 = tail call i64 @chdir(i8* %7)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %57
14: ; preds = %6
store i8 47, i8* %4
%15 = getelementptr inbounds i8, i8* %4, i64 3
br label %16
16: ; preds = %14, %2
%17 = phi i8* [ %15, %14 ], [ %3, %2 ]
%18 = tail call i32 (...) @initialize()
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %1
%23 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %57
24: ; preds = %16
%25 = tail call double (...) @clock()
br label %26
26: ; preds = %39, %24
%27 = phi i64 [ 0, %24 ], [ %40, %39 ]
%28 = phi i32 [ 0, %24 ], [ %41, %39 ]
%29 = and i32 %28, 255
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %26
%32 = tail call double (...) @clock()
%33 = fsub double %32, %25
%34 = load double, double* @CLOCKS_PER_SEC
%35 = fcmp ogt double %33, %34
br i1 %35, label %46, label %36
36: ; preds = %31, %26
%37 = tail call i64 @run(i32 %28)
%38 = icmp eq i64 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = add i64 %37, %27
%41 = add nuw nsw i32 %28, 1
br label %26
42: ; preds = %36
%43 = load i32, i32* @stderr
%44 = load i8*, i8** %1
%45 = tail call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %44)
br label %57
46: ; preds = %31
%47 = tail call double (...) @clock()
%48 = fsub double %47, %25
%49 = load double, double* @CLOCKS_PER_SEC
%50 = fdiv double %48, %49
%51 = uitofp i64 %27 to double
%52 = fdiv double %51, %50
%53 = fmul double %52, 0x3EB0000000000000
%54 = fptosi double %53 to i32
%55 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %17, i32 %54)
%56 = tail call i32 (...) @cleanup()
br label %57
57: ; preds = %42, %46, %20, %10
%58 = phi i32 [ 1, %10 ], [ 1, %20 ], [ 0, %46 ], [ 2, %42 ]
ret i32 %58
}