#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 {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ do_check_file(char const *);
int errno;
scalar_t__ fork();
int getpid();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ wait(int *);
int main(int argc, char *argv[]) {
  const char *lock_file = "file.lock";
  errno = 0;
  pid_t pid = fork();
  if (pid < 0) {
    do {
      struct timeval start;
      gettimeofday(&start, NULL);
      printf("pid [%5d] : %d.%d ", getpid(), (int)start.tv_sec,
             (int)start.tv_usec);
      printf("fork faild, and errno = [%d]", errno);
      printf("\n");
    } while (0);
    return -1;
  } else if (0 == pid) {
    do {
      struct timeval start;
      gettimeofday(&start, NULL);
      printf("pid [%5d] : %d.%d ", getpid(), (int)start.tv_sec,
             (int)start.tv_usec);
      printf("child");
      printf("\n");
    } while (0);
    do {
      struct timeval start;
      gettimeofday(&start, NULL);
      printf("pid [%5d] : %d.%d ", getpid(), (int)start.tv_sec,
             (int)start.tv_usec);
      printf("lock file quickly !");
      printf("\n");
    } while (0);
    do_check_file(lock_file);
    do {
      struct timeval start;
      gettimeofday(&start, NULL);
      printf("pid [%5d] : %d.%d ", getpid(), (int)start.tv_sec,
             (int)start.tv_usec);
      printf("wait 5 seconds ...");
      printf("\n");
    } while (0);
    sleep(5);
  } else {
    do {
      struct timeval start;
      gettimeofday(&start, NULL);
      printf("pid [%5d] : %d.%d ", getpid(), (int)start.tv_sec,
             (int)start.tv_usec);
      printf("parent");
      printf("\n");
    } while (0);
    do {
      struct timeval start;
      gettimeofday(&start, NULL);
      printf("pid [%5d] : %d.%d ", getpid(), (int)start.tv_sec,
             (int)start.tv_usec);
      printf("wait 3 seconds ...");
      printf("\n");
    } while (0);
    sleep(3);
    do_check_file(lock_file);
    int status = 0;
    wait(&status);
    do {
      struct timeval start;
      gettimeofday(&start, NULL);
      printf("pid [%5d] : %d.%d ", getpid(), (int)start.tv_sec,
             (int)start.tv_usec);
      printf("status : [%d]", status);
      printf("\n");
    } while (0);
  }
  do {
    struct timeval start;
    gettimeofday(&start, NULL);
    printf("pid [%5d] : %d.%d ", getpid(), (int)start.tv_sec,
           (int)start.tv_usec);
    printf("the end ...");
    printf("\n");
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe70(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e45(%rip),%rax
movl   $0x0,(%rax)
mov    $0x0,%al
call   1080 <fork@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jge    121d <main+0xad>
jmp    11bc <main+0x4c>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x28(%rbp),%rax
mov    %eax,%edx
mov    -0x30(%rbp),%rax
mov    %eax,%ecx
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%esi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14c0 <main+0x350>
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    132f <main+0x1bf>
jmp    122e <main+0xbe>
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x38(%rbp),%rax
mov    %eax,%edx
mov    -0x40(%rbp),%rax
mov    %eax,%ecx
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    127f <main+0x10f>
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x48(%rbp),%rax
mov    %eax,%edx
mov    -0x50(%rbp),%rax
mov    %eax,%ecx
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1090 <do_check_file@plt>
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x58(%rbp),%rax
mov    %eax,%edx
mov    -0x60(%rbp),%rax
mov    %eax,%ecx
lea    0xd0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x5,%edi
call   1060 <sleep@plt>
jmp    145a <main+0x2ea>
jmp    1334 <main+0x1c4>
lea    -0x70(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x68(%rbp),%rax
mov    %eax,%edx
mov    -0x70(%rbp),%rax
mov    %eax,%ecx
lea    0xcad(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1385 <main+0x215>
lea    -0x80(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x78(%rbp),%rax
mov    %eax,%edx
mov    -0x80(%rbp),%rax
mov    %eax,%ecx
lea    0xc5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x3,%edi
call   1060 <sleep@plt>
mov    -0x18(%rbp),%rdi
call   1090 <do_check_file@plt>
movl   $0x0,-0x84(%rbp)
lea    -0x84(%rbp),%rdi
call   1070 <wait@plt>
lea    -0x98(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x90(%rbp),%rax
mov    %eax,%edx
mov    -0x98(%rbp),%rax
mov    %eax,%ecx
lea    0xbde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x84(%rbp),%esi
lea    0xc43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xbec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    145a <main+0x2ea>
jmp    145f <main+0x2ef>
jmp    1464 <main+0x2f4>
lea    -0xa8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0xa0(%rbp),%rax
mov    %eax,%edx
mov    -0xa8(%rbp),%rax
mov    %eax,%ecx
lea    0xb74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xbed(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    0x2e54(%rip),%rbx
movl   $0x0,(%rbx)
xor    %eax,%eax
call   1090 <fork@plt>
lea    0x8(%rsp),%rdi
test   %rax,%rax
js     129d <main+0x11d>
je     12e7 <main+0x167>
xor    %esi,%esi
call   1060 <gettimeofday@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    0x8(%rsp),%ecx
mov    0x10(%rsp),%edx
lea    0xe40(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    0x8(%rsp),%ecx
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x3,%edi
call   1070 <sleep@plt>
lea    0xdc2(%rip),%rdi
call   10a0 <do_check_file@plt>
movl   $0x0,0x1c(%rsp)
lea    0x1c(%rsp),%rdi
call   1080 <wait@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    0x8(%rsp),%ecx
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rsp),%esi
lea    0xdfa(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    13bc <main+0x23c>
xor    %esi,%esi
call   1060 <gettimeofday@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    0x8(%rsp),%ecx
mov    0x10(%rsp),%edx
lea    0xd50(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
lea    0xd51(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xffffffff,%ebx
jmp    1401 <main+0x281>
xor    %esi,%esi
call   1060 <gettimeofday@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    0x8(%rsp),%ecx
mov    0x10(%rsp),%edx
lea    0xd06(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd23(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    0x8(%rsp),%ecx
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xcea(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xc92(%rip),%rdi
call   10a0 <do_check_file@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    0x8(%rsp),%ecx
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xcb3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x5,%edi
call   1070 <sleep@plt>
xor    %ebx,%ebx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    0x8(%rsp),%ecx
mov    0x10(%rsp),%edx
lea    0xc2a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc9f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@.str = [10 x i8] c"file.lock\00"
@errno = global i32 0
@.str.1 = [19 x i8] c"pid [%5d] : %d.%d \00"
@.str.2 = [29 x i8] c"fork faild, and errno = [%d]\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [6 x i8] c"child\00"
@.str.5 = [20 x i8] c"lock file quickly !\00"
@.str.6 = [19 x i8] c"wait 5 seconds ...\00"
@.str.7 = [7 x i8] c"parent\00"
@.str.8 = [19 x i8] c"wait 3 seconds ...\00"
@.str.9 = [14 x i8] c"status : [%d]\00"
@.str.10 = [12 x i8] c"the end ...\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca %struct.timeval
%9 = alloca %struct.timeval
%10 = alloca %struct.timeval
%11 = alloca %struct.timeval
%12 = alloca %struct.timeval
%13 = alloca %struct.timeval
%14 = alloca i32
%15 = alloca %struct.timeval
%16 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 0, i32* @errno
%17 = call i64 (...) @fork()
store i64 %17, i64* %7
%18 = load i64, i64* %7
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %35
20: ; preds = %2
br label %21
21: ; preds = %20
%22 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%23 = call i32 (...) @getpid()
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%25 = load i64, i64* %24
%26 = trunc i64 %25 to i32
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%28 = load i64, i64* %27
%29 = trunc i64 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %26, i32 %29)
%31 = load i32, i32* @errno
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %21
store i32 -1, i32* %3
br label %141
35: ; preds = %2
%36 = load i64, i64* %7
%37 = icmp eq i64 0, %36
br i1 %37, label %38, label %81
38: ; preds = %35
br label %39
39: ; preds = %38
%40 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%41 = call i32 (...) @getpid()
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 1
%43 = load i64, i64* %42
%44 = trunc i64 %43 to i32
%45 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%46 = load i64, i64* %45
%47 = trunc i64 %46 to i32
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %41, i32 %44, i32 %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %51
51: ; preds = %39
br label %52
52: ; preds = %51
%53 = call i32 @gettimeofday(%struct.timeval* %10, i32* null)
%54 = call i32 (...) @getpid()
%55 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 1
%56 = load i64, i64* %55
%57 = trunc i64 %56 to i32
%58 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%59 = load i64, i64* %58
%60 = trunc i64 %59 to i32
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %54, i32 %57, i32 %60)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %64
64: ; preds = %52
%65 = load i8*, i8** %6
%66 = call i32 @do_check_file(i8* %65)
br label %67
67: ; preds = %64
%68 = call i32 @gettimeofday(%struct.timeval* %11, i32* null)
%69 = call i32 (...) @getpid()
%70 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
%71 = load i64, i64* %70
%72 = trunc i64 %71 to i32
%73 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
%74 = load i64, i64* %73
%75 = trunc i64 %74 to i32
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %69, i32 %72, i32 %75)
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %79
79: ; preds = %67
%80 = call i32 @sleep(i32 5)
br label %126
81: ; preds = %35
br label %82
82: ; preds = %81
%83 = call i32 @gettimeofday(%struct.timeval* %12, i32* null)
%84 = call i32 (...) @getpid()
%85 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
%86 = load i64, i64* %85
%87 = trunc i64 %86 to i32
%88 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%89 = load i64, i64* %88
%90 = trunc i64 %89 to i32
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %84, i32 %87, i32 %90)
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %94
94: ; preds = %82
br label %95
95: ; preds = %94
%96 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%97 = call i32 (...) @getpid()
%98 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%99 = load i64, i64* %98
%100 = trunc i64 %99 to i32
%101 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%102 = load i64, i64* %101
%103 = trunc i64 %102 to i32
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %97, i32 %100, i32 %103)
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %107
107: ; preds = %95
%108 = call i32 @sleep(i32 3)
%109 = load i8*, i8** %6
%110 = call i32 @do_check_file(i8* %109)
store i32 0, i32* %14
%111 = call i32 @wait(i32* %14)
br label %112
112: ; preds = %107
%113 = call i32 @gettimeofday(%struct.timeval* %15, i32* null)
%114 = call i32 (...) @getpid()
%115 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
%116 = load i64, i64* %115
%117 = trunc i64 %116 to i32
%118 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 0
%119 = load i64, i64* %118
%120 = trunc i64 %119 to i32
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %114, i32 %117, i32 %120)
%122 = load i32, i32* %14
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 %122)
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %125
125: ; preds = %112
br label %126
126: ; preds = %125, %79
br label %127
127: ; preds = %126
br label %128
128: ; preds = %127
%129 = call i32 @gettimeofday(%struct.timeval* %16, i32* null)
%130 = call i32 (...) @getpid()
%131 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 1
%132 = load i64, i64* %131
%133 = trunc i64 %132 to i32
%134 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
%135 = load i64, i64* %134
%136 = trunc i64 %135 to i32
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %130, i32 %133, i32 %136)
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %140
140: ; preds = %128
store i32 0, i32* %3
br label %141
141: ; preds = %140, %34
%142 = load i32, i32* %3
ret i32 %142
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@.str = [10 x i8] c"file.lock\00"
@errno = global i32 0
@.str.1 = [19 x i8] c"pid [%5d] : %d.%d \00"
@.str.2 = [29 x i8] c"fork faild, and errno = [%d]\00"
@.str.4 = [6 x i8] c"child\00"
@.str.5 = [20 x i8] c"lock file quickly !\00"
@.str.6 = [19 x i8] c"wait 5 seconds ...\00"
@.str.7 = [7 x i8] c"parent\00"
@.str.8 = [19 x i8] c"wait 3 seconds ...\00"
@.str.9 = [14 x i8] c"status : [%d]\00"
@.str.10 = [12 x i8] c"the end ...\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca %struct.timeval
%9 = alloca i32
%10 = alloca %struct.timeval
%11 = alloca %struct.timeval
store i32 0, i32* @errno
%12 = tail call i64 (...) @fork()
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %28
14: ; preds = %2
%15 = bitcast %struct.timeval* %3 to i8*
%16 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%17 = tail call i32 (...) @getpid()
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%19 = load i64, i64* %18
%20 = trunc i64 %19 to i32
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%22 = load i64, i64* %21
%23 = trunc i64 %22 to i32
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %20, i32 %23)
%25 = load i32, i32* @errno
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = tail call i32 @putchar(i32 10)
br label %124
28: ; preds = %2
%29 = icmp eq i64 %12, 0
br i1 %29, label %30, label %69
30: ; preds = %28
%31 = bitcast %struct.timeval* %4 to i8*
%32 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%33 = tail call i32 (...) @getpid()
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%35 = load i64, i64* %34
%36 = trunc i64 %35 to i32
%37 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%38 = load i64, i64* %37
%39 = trunc i64 %38 to i32
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %36, i32 %39)
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%42 = tail call i32 @putchar(i32 10)
%43 = bitcast %struct.timeval* %5 to i8*
%44 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%45 = tail call i32 (...) @getpid()
%46 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
%47 = load i64, i64* %46
%48 = trunc i64 %47 to i32
%49 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%50 = load i64, i64* %49
%51 = trunc i64 %50 to i32
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %45, i32 %48, i32 %51)
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%54 = tail call i32 @putchar(i32 10)
%55 = tail call i32 @do_check_file(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%56 = bitcast %struct.timeval* %6 to i8*
%57 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%58 = tail call i32 (...) @getpid()
%59 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%60 = load i64, i64* %59
%61 = trunc i64 %60 to i32
%62 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%63 = load i64, i64* %62
%64 = trunc i64 %63 to i32
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %58, i32 %61, i32 %64)
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%67 = tail call i32 @putchar(i32 10)
%68 = tail call i32 @sleep(i32 5)
br label %111
69: ; preds = %28
%70 = bitcast %struct.timeval* %7 to i8*
%71 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%72 = tail call i32 (...) @getpid()
%73 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 1
%74 = load i64, i64* %73
%75 = trunc i64 %74 to i32
%76 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 0
%77 = load i64, i64* %76
%78 = trunc i64 %77 to i32
%79 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %72, i32 %75, i32 %78)
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%81 = tail call i32 @putchar(i32 10)
%82 = bitcast %struct.timeval* %8 to i8*
%83 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%84 = tail call i32 (...) @getpid()
%85 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i64 0, i32 1
%86 = load i64, i64* %85
%87 = trunc i64 %86 to i32
%88 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i64 0, i32 0
%89 = load i64, i64* %88
%90 = trunc i64 %89 to i32
%91 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %84, i32 %87, i32 %90)
%92 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
%93 = tail call i32 @putchar(i32 10)
%94 = tail call i32 @sleep(i32 3)
%95 = tail call i32 @do_check_file(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%96 = bitcast i32* %9 to i8*
store i32 0, i32* %9
%97 = call i32 @wait(i32* %9)
%98 = bitcast %struct.timeval* %10 to i8*
%99 = call i32 @gettimeofday(%struct.timeval* %10, i32* null)
%100 = call i32 (...) @getpid()
%101 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 1
%102 = load i64, i64* %101
%103 = trunc i64 %102 to i32
%104 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i64 0, i32 0
%105 = load i64, i64* %104
%106 = trunc i64 %105 to i32
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %100, i32 %103, i32 %106)
%108 = load i32, i32* %9
%109 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i32 %108)
%110 = call i32 @putchar(i32 10)
br label %111
111: ; preds = %69, %30
%112 = bitcast %struct.timeval* %11 to i8*
%113 = call i32 @gettimeofday(%struct.timeval* %11, i32* null)
%114 = call i32 (...) @getpid()
%115 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i64 0, i32 1
%116 = load i64, i64* %115
%117 = trunc i64 %116 to i32
%118 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i64 0, i32 0
%119 = load i64, i64* %118
%120 = trunc i64 %119 to i32
%121 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %114, i32 %117, i32 %120)
%122 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%123 = call i32 @putchar(i32 10)
br label %124
124: ; preds = %111, %14
%125 = phi i32 [ -1, %14 ], [ 0, %111 ]
ret i32 %125
}