#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 timeval {
  long long tv_sec;
  int tv_usec;
};

/* Variables and functions */
int clacks_new_id(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, long long);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  char id[1024];
  int ret, i;
  long long ms_pre, ms_post, time_total;
  struct timeval tv;
  gettimeofday(&tv, NULL);
  ms_pre = tv.tv_sec * 1000LL + tv.tv_usec / 1000;
  for (i = 0; i < 100000; i++) {
    ret = clacks_new_id(id);
  }
  gettimeofday(&tv, NULL);
  ms_post = tv.tv_sec * 1000LL + tv.tv_usec / 1000;
  time_total = ms_post - ms_pre;
  fprintf(stdout, "Time: %lld\n", time_total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x440(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
imul   $0x3e8,-0x440(%rbp),%rax
mov    %rax,-0x448(%rbp)
mov    -0x438(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x448(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x420(%rbp)
movl   $0x0,-0x418(%rbp)
cmpl   $0x186a0,-0x418(%rbp)
jge    11cf <main+0x9f>
lea    -0x410(%rbp),%rdi
call   1050 <clacks_new_id@plt>
mov    %eax,-0x414(%rbp)
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
jmp    1199 <main+0x69>
lea    -0x440(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
imul   $0x3e8,-0x440(%rbp),%rax
mov    %rax,-0x450(%rbp)
mov    -0x438(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x450(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x428(%rbp)
mov    -0x428(%rbp),%rax
sub    -0x420(%rbp),%rax
mov    %rax,-0x430(%rbp)
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
mov    -0x430(%rbp),%rdx
lea    0xdbf(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x418,%rsp
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    (%rsp),%r14
mov    $0x186a0,%ebp
mov    0x8(%rsp),%r15d
lea    0x10(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <clacks_new_id@plt>
add    $0xffffffff,%ebp
jne    1160 <main+0x30>
movslq %r15d,%rax
imul   $0xffffffffef9db22d,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x26,%rbx
add    %eax,%ebx
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    (%rsp),%rax
sub    %r14,%rax
movslq 0x8(%rsp),%rcx
imul   $0x10624dd3,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
add    %ebx,%ecx
imul   $0x3e8,%rax,%rax
movslq %ecx,%rdx
add    %rax,%rdx
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xe33(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i32 }
@stdout = global i32 0
@.str = [12 x i8] c"Time: %lld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32 @gettimeofday(%struct.timeval* %12, i32* null)
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%15 = load i64, i64* %14
%16 = mul nsw i64 %15, 1000
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
%18 = load i32, i32* %17
%19 = sdiv i32 %18, 1000
%20 = sext i32 %19 to i64
%21 = add nsw i64 %16, %20
store i64 %21, i64* %9
store i32 0, i32* %8
br label %22
22: ; preds = %28, %2
%23 = load i32, i32* %8
%24 = icmp slt i32 %23, 100000
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%27 = call i32 @clacks_new_id(i8* %26)
store i32 %27, i32* %7
br label %28
28: ; preds = %25
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %22
31: ; preds = %22
%32 = call i32 @gettimeofday(%struct.timeval* %12, i32* null)
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%34 = load i64, i64* %33
%35 = mul nsw i64 %34, 1000
%36 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
%37 = load i32, i32* %36
%38 = sdiv i32 %37, 1000
%39 = sext i32 %38 to i64
%40 = add nsw i64 %35, %39
store i64 %40, i64* %10
%41 = load i64, i64* %10
%42 = load i64, i64* %9
%43 = sub nsw i64 %41, %42
store i64 %43, i64* %11
%44 = load i32, i32* @stdout
%45 = load i64, i64* %11
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64 %45)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i64, i32 }
@stdout = global i32 0
@.str = [12 x i8] c"Time: %lld\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = alloca %struct.timeval
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.timeval* %4 to i8*
%7 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%9 = load i64, i64* %8
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%11 = load i32, i32* %10
br label %12
12: ; preds = %2, %12
%13 = phi i32 [ 0, %2 ], [ %15, %12 ]
%14 = call i32 @clacks_new_id(i8* %5)
%15 = add nuw nsw i32 %13, 1
%16 = icmp eq i32 %15, 100000
br i1 %16, label %17, label %12
17: ; preds = %12
%18 = sdiv i32 %11, -1000
%19 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%20 = load i64, i64* %8
%21 = load i32, i32* %10
%22 = sdiv i32 %21, 1000
%23 = sub i64 %20, %9
%24 = mul i64 %23, 1000
%25 = add nsw i32 %22, %18
%26 = sext i32 %25 to i64
%27 = add i64 %24, %26
%28 = load i32, i32* @stdout
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64 %27)
ret i32 0
}