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

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, int);
void stopClock(int zaeler) {
  static clock_t t0, t1;
  static int flag;
  static int start, stop;
  double zeitspanne;
  if (!flag) {
    flag = !flag;
    start = zaeler;
    t0 = clock();
  } else {
    flag = !flag;
    stop = zaeler;
    t1 = clock();
    zeitspanne = (double)(t1 - t0) / CLOCKS_PER_SEC;
    printf(" Zeitspanne:    %lf sec \n", zeitspanne);
    printf(" Ereignisse/sec %lf     \n", (stop - start) / zeitspanne);
  }
}


x86 assembly (clang, -O0):
<stopClock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,0x2f16(%rip)
jne    116b <stopClock+0x4b>
cmpl   $0x0,0x2f09(%rip)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,0x2ef9(%rip)
mov    -0x4(%rbp),%eax
mov    %eax,0x2ef4(%rip)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,0x2ed2(%rip)
jmp    11f2 <stopClock+0xd2>
cmpl   $0x0,0x2ed6(%rip)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,0x2ec6(%rip)
mov    -0x4(%rbp),%eax
mov    %eax,0x2ec5(%rip)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,0x2ea7(%rip)
mov    0x2ea0(%rip),%rax
sub    0x2e91(%rip),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e35(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x10(%rbp)
cvttsd2si -0x10(%rbp),%esi
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e7d(%rip),%eax
sub    0x2e73(%rip),%eax
cvtsi2sd %eax,%xmm0
divsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%esi
lea    0xe2d(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stopClock>:
push   %rax
cmpb   $0x0,0x2f18(%rip)
je     1193 <stopClock+0x73>
movb   $0x0,0x2f0f(%rip)
mov    %edi,0x2f11(%rip)
xor    %eax,%eax
call   1030 <clock@plt>
sub    0x2ef3(%rip),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e97(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,(%rsp)
cvttsd2si %xmm0,%esi
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
mov    0x2ed8(%rip),%eax
sub    0x2ece(%rip),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  (%rsp),%xmm0
cvttsd2si %xmm0,%esi
lea    0xe8d(%rip),%rdi
pop    %rax
jmp    1040 <printf@plt>
movb   $0x1,0x2ea6(%rip)
mov    %edi,0x2ea4(%rip)
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,0x2e8a(%rip)
pop    %rax
ret

LLVM IR (-O0):
@stopClock.t0 = internal global i64 0
@stopClock.t1 = internal global i64 0
@stopClock.flag = internal global i32 0
@stopClock.start = internal global i32 0
@stopClock.stop = internal global i32 0
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [26 x i8] c" Zeitspanne: %lf sec \0A\00"
@.str.1 = [26 x i8] c" Ereignisse/sec %lf \0A\00"
define void @stopClock(i32 %0) {
%2 = alloca i32
%3 = alloca double
store i32 %0, i32* %2
%4 = load i32, i32* @stopClock.flag
%5 = icmp ne i32 %4, 0
br i1 %5, label %13, label %6
6: ; preds = %1
%7 = load i32, i32* @stopClock.flag
%8 = icmp ne i32 %7, 0
%9 = xor i1 %8, true
%10 = zext i1 %9 to i32
store i32 %10, i32* @stopClock.flag
%11 = load i32, i32* %2
store i32 %11, i32* @stopClock.start
%12 = call i64 (...) @clock()
store i64 %12, i64* @stopClock.t0
br label %37
13: ; preds = %1
%14 = load i32, i32* @stopClock.flag
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
%17 = zext i1 %16 to i32
store i32 %17, i32* @stopClock.flag
%18 = load i32, i32* %2
store i32 %18, i32* @stopClock.stop
%19 = call i64 (...) @clock()
store i64 %19, i64* @stopClock.t1
%20 = load i64, i64* @stopClock.t1
%21 = load i64, i64* @stopClock.t0
%22 = sub nsw i64 %20, %21
%23 = sitofp i64 %22 to double
%24 = load double, double* @CLOCKS_PER_SEC
%25 = fdiv double %23, %24
store double %25, double* %3
%26 = load double, double* %3
%27 = fptosi double %26 to i32
%28 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = load i32, i32* @stopClock.stop
%30 = load i32, i32* @stopClock.start
%31 = sub nsw i32 %29, %30
%32 = sitofp i32 %31 to double
%33 = load double, double* %3
%34 = fdiv double %32, %33
%35 = fptosi double %34 to i32
%36 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %13, %6
ret void
}

LLVM IR (-O2):
@stopClock.t0 = internal unnamed_addr global i64 0
@stopClock.flag = internal unnamed_addr global i1 false
@stopClock.start = internal unnamed_addr global i32 0
@stopClock.stop = internal unnamed_addr global i32 0
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str = [26 x i8] c" Zeitspanne: %lf sec \0A\00"
@.str.1 = [26 x i8] c" Ereignisse/sec %lf \0A\00"
define void @stopClock(i32 %0) {
%2 = load i1, i1* @stopClock.flag
br i1 %2, label %5, label %3
3: ; preds = %1
store i1 true, i1* @stopClock.flag
store i32 %0, i32* @stopClock.start
%4 = tail call i64 (...) @clock()
store i64 %4, i64* @stopClock.t0
br label %21
5: ; preds = %1
store i1 false, i1* @stopClock.flag
store i32 %0, i32* @stopClock.stop
%6 = tail call i64 (...) @clock()
%7 = load i64, i64* @stopClock.t0
%8 = sub nsw i64 %6, %7
%9 = sitofp i64 %8 to double
%10 = load double, double* @CLOCKS_PER_SEC
%11 = fdiv double %9, %10
%12 = fptosi double %11 to i32
%13 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @stopClock.stop
%15 = load i32, i32* @stopClock.start
%16 = sub nsw i32 %14, %15
%17 = sitofp i32 %16 to double
%18 = fdiv double %17, %11
%19 = fptosi double %18 to i32
%20 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %5, %3
ret void
}