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

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ is_prime_number(int);
int /*<<< orphan*/ printf(char *, int, int);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  struct timeval start, end;
  srand((unsigned)time(NULL));
  for (int i = 0; i < 10; ++i) {
    gettimeofday(&start, NULL);
    for (int j = 0, rand_int; j < 9999999; ++j) {
      rand_int = rand();
      is_prime_number(rand_int);
    }
    gettimeofday(&end, NULL);
    printf("[%d]Running time: %d us\n", i,
           1000000 * (end.tv_sec - start.tv_sec) + end.tv_usec - start.tv_usec);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0xa,-0x24(%rbp)
jge    1214 <main+0xb4>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x98967f,-0x28(%rbp)
jge    11d8 <main+0x78>
mov    $0x0,%al
call   1080 <rand@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1070 <is_prime_number@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ab <main+0x4b>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%eax
sub    -0x18(%rbp),%eax
imul   $0xf4240,%eax,%edx
add    -0x1c(%rbp),%edx
sub    -0x14(%rbp),%edx
lea    0xdff(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118d <main+0x2d>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0x8(%rsp),%r14
mov    %rsp,%r15
lea    0xe77(%rip),%r12
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    $0x98967f,%ebx
nop
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%edi
call   1070 <is_prime_number@plt>
add    $0xffffffff,%ebx
jne    11a0 <main+0x40>
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    (%rsp),%eax
sub    0x8(%rsp),%eax
imul   $0xf4240,%eax,%edx
add    0x4(%rsp),%edx
sub    0xc(%rsp),%edx
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    $0xa,%ebp
jne    1190 <main+0x30>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [25 x i8] c"[%d]Running time: %d us\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %3 to i8*
%6 = bitcast %struct.timeval* %4 to i8*
%7 = tail call i64 @time(i32* null)
%8 = trunc i64 %7 to i32
%9 = tail call i32 @srand(i32 %8)
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
br label %15
14: ; preds = %18
ret i32 0
15: ; preds = %2, %18
%16 = phi i32 [ 0, %2 ], [ %29, %18 ]
%17 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
br label %31
18: ; preds = %31
%19 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%20 = load i32, i32* %10
%21 = load i32, i32* %11
%22 = sub nsw i32 %20, %21
%23 = mul nsw i32 %22, 1000000
%24 = load i32, i32* %12
%25 = add nsw i32 %23, %24
%26 = load i32, i32* %13
%27 = sub i32 %25, %26
%28 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %27)
%29 = add nuw nsw i32 %16, 1
%30 = icmp eq i32 %29, 10
br i1 %30, label %14, label %15
31: ; preds = %15, %31
%32 = phi i32 [ 0, %15 ], [ %35, %31 ]
%33 = tail call i32 (...) @rand()
%34 = tail call i32 @is_prime_number(i32 %33)
%35 = add nuw nsw i32 %32, 1
%36 = icmp eq i32 %35, 9999999
br i1 %36, label %18, label %31
}