#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 fork();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, unsigned int);
int main() {
  struct timeval t0, t1;
  int i = 0;
  int id = -1;
  gettimeofday(&t0, NULL);
  for (i = 0; i < 100; i++) {
    id = fork();
    if (id == 0)
      return 0;
  }
  if (id != 0) {
    gettimeofday(&t1, NULL);
    unsigned int ut1 = t1.tv_sec * 1000000 + t1.tv_usec;
    unsigned int ut0 = t0.tv_sec * 1000000 + t0.tv_usec;
    printf(" %f microsegundos\n", (ut1 - ut0) / 100.0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0xffffffff,-0x20(%rbp)
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x64,-0x1c(%rbp)
jge    119e <main+0x6e>
mov    $0x0,%al
call   1050 <fork@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    118b <main+0x5b>
movl   $0x0,-0x4(%rbp)
jmp    1203 <main+0xd3>
jmp    1190 <main+0x60>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1161 <main+0x31>
cmpl   $0x0,-0x20(%rbp)
je     1203 <main+0xd3>
xor    %eax,%eax
mov    %eax,%esi
lea    -0x18(%rbp),%rdi
call   1040 <gettimeofday@plt>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   $0xf4240,%eax,%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   $0xf4240,%eax,%eax
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x28(%rbp),%ecx
sub    %ecx,%eax
cvtsi2sd %rax,%xmm0
movsd  0xe14(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,%esi
lea    0xe0a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    $0x64,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <fork@plt>
test   %eax,%eax
je     119f <main+0x6f>
add    $0xffffffff,%ebx
jne    1150 <main+0x20>
mov    %rsp,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
sub    0x8(%rsp),%eax
sub    0xc(%rsp),%ecx
imul   $0xf4240,%eax,%eax
add    %eax,%ecx
cvtsi2sd %rcx,%xmm0
divsd  0xe72(%rip),%xmm0
cvttsd2si %xmm0,%rsi
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [19 x i8] c" %f microsegundos\0A\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timeval* %2 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
br label %9
6: ; preds = %9
%7 = add nuw nsw i32 %10, 1
%8 = icmp eq i32 %7, 100
br i1 %8, label %13, label %9
9: ; preds = %0, %6
%10 = phi i32 [ 0, %0 ], [ %7, %6 ]
%11 = tail call i32 (...) @fork()
%12 = icmp eq i32 %11, 0
br i1 %12, label %31, label %6
13: ; preds = %6
%14 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%22 = load i32, i32* %21
%23 = sub i32 %16, %20
%24 = mul i32 %23, 1000000
%25 = sub i32 %18, %22
%26 = add i32 %25, %24
%27 = uitofp i32 %26 to double
%28 = fdiv double %27, 1.000000e+02
%29 = fptoui double %28 to i32
%30 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %9, %13
ret i32 0
}