#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 timespec {
  unsigned long tv_nsec;
  scalar_t__ tv_sec;
};
typedef int /*<<< orphan*/ pthread_mutexattr_t;
typedef int /*<<< orphan*/ pthread_mutex_t;
typedef int /*<<< orphan*/ pthread_condattr_t;
typedef int /*<<< orphan*/ pthread_cond_t;
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
int /*<<< orphan*/ CLOCK_REALTIME;
int ETIMEDOUT;
int /*<<< orphan*/ ErrorAbort(char *, int, char *, int);
scalar_t__ clock();
int clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, ...);
int pthread_cond_init(int /*<<< orphan*/ *, int /*<<< orphan*/ const *);
int pthread_cond_timedwait(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                           struct timespec *);
int pthread_mutex_init(int /*<<< orphan*/ *, int /*<<< orphan*/ const *);
int pthread_mutex_lock(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
unsigned long strtoul(int /*<<< orphan*/, char **, int /*<<< orphan*/);
int main(int ac, char **av) {
  int opt;
  unsigned long t_timeout_msec = (100);
  int rv;
  pthread_mutex_t mu;
  pthread_cond_t cv;
  struct timespec ts;
  clock_t t_start;
  clock_t t_end;
  double t_cpu_used_ms;
  unsigned long t_cpu_threshold_ms = (10 + (70 - 10) / 2);
  while (-1 != (opt = getopt(ac, av, "t:m:"))) {
    switch (opt) {
    case 't':
      t_timeout_msec = strtoul(optarg, (char **)NULL, 0);
      break;
    case 'm':
      t_cpu_threshold_ms = strtoul(optarg, (char **)NULL, 0);
      break;
    default:
      fprintf(stderr, ("Usage: cond_timedwait [-t timeout_in_ms]"
                       " [-m max_cpu_usage_ms\n"));
      return 1;
    }
  }
  if (0 != (rv = pthread_mutex_init(&mu, (pthread_mutexattr_t const *)NULL))) {
    do {
      ErrorAbort(
          "pthread_mutex_init", rv,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/CTSRD-SOAAP/chromium-42.0.2311.135/refs/"
          "heads/lind/native_client/tests/threads/cond_timedwait.c",
          64);
    } while (0);
  }
  if (0 != (rv = pthread_cond_init(&cv, (pthread_condattr_t const *)NULL))) {
    do {
      ErrorAbort(
          "pthread_cond_init", rv,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/CTSRD-SOAAP/chromium-42.0.2311.135/refs/"
          "heads/lind/native_client/tests/threads/cond_timedwait.c",
          69);
    } while (0);
  }
  if (0 != (rv = pthread_mutex_lock(&mu))) {
    do {
      ErrorAbort(
          "pthread_mutex_lock", rv,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/CTSRD-SOAAP/chromium-42.0.2311.135/refs/"
          "heads/lind/native_client/tests/threads/cond_timedwait.c",
          72);
    } while (0);
  }
  if (0 != (rv = clock_gettime(CLOCK_REALTIME, &ts))) {
    do {
      ErrorAbort(
          "clock_gettime", rv,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/CTSRD-SOAAP/chromium-42.0.2311.135/refs/"
          "heads/lind/native_client/tests/threads/cond_timedwait.c",
          75);
    } while (0);
  }
  ts.tv_sec += t_timeout_msec / 1000;
  ts.tv_nsec += (t_timeout_msec % 1000) * 1000 * 1000;
  if (ts.tv_nsec > 1000000000) {
    ts.tv_sec++;
    ts.tv_nsec -= 1000000000;
  }
  t_start = clock();
  if (ETIMEDOUT != (rv = pthread_cond_timedwait(&cv, &mu, &ts))) {
    do {
      ErrorAbort(
          "pthread_cond_timedwait", rv,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/CTSRD-SOAAP/chromium-42.0.2311.135/refs/"
          "heads/lind/native_client/tests/threads/cond_timedwait.c",
          85);
    } while (0);
  }
  t_end = clock();
  t_cpu_used_ms = 1000.0 * ((double)(t_end - t_start)) / CLOCKS_PER_SEC;
  printf("pthread_cond_timedwait: waited %lu ms\n", t_timeout_msec);
  printf("CPU seconds used by pthread_cond_timedwait: %f ms\n", t_cpu_used_ms);
  if (t_cpu_used_ms > t_cpu_threshold_ms) {
    printf("FAILED.\n");
    rv = 1;
  } else {
    printf("OK.\n");
    rv = 0;
  }
  return rv;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x64,-0x20(%rbp)
movq   $0x28,-0x60(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe4c(%rip),%rdx
call   10a0 <getopt@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
je     1280 <main+0xd0>
mov    -0x14(%rbp),%eax
mov    %eax,-0x64(%rbp)
sub    $0x6d,%eax
je     123d <main+0x8d>
jmp    120f <main+0x5f>
mov    -0x64(%rbp),%eax
sub    $0x74,%eax
jne    125a <main+0xaa>
jmp    1220 <main+0x70>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10b0 <strtoul@plt>
mov    %rax,-0x20(%rbp)
jmp    127b <main+0xcb>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10b0 <strtoul@plt>
mov    %rax,-0x60(%rbp)
jmp    127b <main+0xcb>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
lea    0xdcb(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1516 <main+0x366>
jmp    11d6 <main+0x26>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10c0 <pthread_mutex_init@plt>
mov    %eax,%ecx
mov    %ecx,-0x24(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
je     12c1 <main+0x111>
jmp    12a1 <main+0xf1>
mov    -0x24(%rbp),%esi
lea    0xdc9(%rip),%rdi
lea    0xdd5(%rip),%rdx
mov    $0x40,%ecx
call   1030 <ErrorAbort@plt>
jmp    12c1 <main+0x111>
lea    -0x2c(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <pthread_cond_init@plt>
mov    %eax,%ecx
mov    %ecx,-0x24(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
je     1302 <main+0x152>
jmp    12e2 <main+0x132>
mov    -0x24(%rbp),%esi
lea    0xe55(%rip),%rdi
lea    0xd94(%rip),%rdx
mov    $0x45,%ecx
call   1030 <ErrorAbort@plt>
jmp    1302 <main+0x152>
lea    -0x28(%rbp),%rdi
call   10d0 <pthread_mutex_lock@plt>
mov    %eax,%ecx
mov    %ecx,-0x24(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
je     133f <main+0x18f>
jmp    131f <main+0x16f>
mov    -0x24(%rbp),%esi
lea    0xe2a(%rip),%rdi
lea    0xd57(%rip),%rdx
mov    $0x48,%ecx
call   1030 <ErrorAbort@plt>
jmp    133f <main+0x18f>
mov    0x2c7a(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    %eax,%ecx
mov    %ecx,-0x24(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
je     1385 <main+0x1d5>
jmp    1365 <main+0x1b5>
mov    -0x24(%rbp),%esi
lea    0xdf7(%rip),%rdi
lea    0xd11(%rip),%rdx
mov    $0x4b,%ecx
call   1030 <ErrorAbort@plt>
jmp    1385 <main+0x1d5>
mov    -0x20(%rbp),%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
imul   $0x3e8,%rdx,%rax
imul   $0x3e8,%rax,%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x3b9aca00,-0x40(%rbp)
3b
jbe    13e7 <main+0x237>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
sub    $0x3b9aca00,%rax
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1050 <clock@plt>
mov    %rax,-0x48(%rbp)
mov    0x2bcf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
lea    -0x2c(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1090 <pthread_cond_timedwait@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%eax
mov    %ecx,-0x24(%rbp)
cmp    %ecx,%eax
je     1444 <main+0x294>
jmp    1424 <main+0x274>
mov    -0x24(%rbp),%esi
lea    0xd46(%rip),%rdi
lea    0xc52(%rip),%rdx
mov    $0x55,%ecx
call   1030 <ErrorAbort@plt>
jmp    1444 <main+0x294>
xor    %eax,%eax
mov    %al,-0x69(%rbp)
call   1050 <clock@plt>
mov    %rax,%rcx
mov    -0x69(%rbp),%al
mov    %rcx,-0x50(%rbp)
mov    -0x50(%rbp),%rcx
mov    -0x48(%rbp),%rdx
sub    %rdx,%rcx
cvtsi2sd %rcx,%xmm0
movsd  0xb90(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    0x2b65(%rip),%rcx
movsd  (%rcx),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xcf8(%rip),%rdi
call   1060 <printf@plt>
movsd  -0x58(%rbp),%xmm0
lea    0xd0e(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0x58(%rbp),%xmm0
movaps 0xb59(%rip),%xmm2
movq   -0x60(%rbp),%xmm1
punpckldq %xmm2,%xmm1
movapd 0xb58(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    14fb <main+0x34b>
lea    0xcfd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x24(%rbp)
jmp    1510 <main+0x360>
lea    0xcec(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x28,%r15d
mov    $0x64,%r14d
lea    0xe4a(%rip),%r12
mov    0x2e0b(%rip),%r13
jmp    1200 <main+0x40>
nop
mov    0x0(%r13),%edi
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <strtoul@plt>
mov    %rax,%r15
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   10b0 <getopt@plt>
cmp    $0x6d,%eax
je     11f0 <main+0x30>
cmp    $0xffffffff,%eax
je     1232 <main+0x72>
cmp    $0x74,%eax
jne    140f <main+0x24f>
mov    0x0(%r13),%edi
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <strtoul@plt>
mov    %rax,%r14
jmp    1200 <main+0x40>
lea    0x4(%rsp),%rdi
xor    %esi,%esi
call   10d0 <pthread_mutex_init@plt>
test   %eax,%eax
je     125c <main+0x9c>
lea    0xe2b(%rip),%rdi
lea    0xe37(%rip),%rdx
mov    %eax,%esi
mov    $0x40,%ecx
call   1030 <ErrorAbort@plt>
lea    0x1c(%rsp),%rdi
xor    %esi,%esi
call   1090 <pthread_cond_init@plt>
test   %eax,%eax
je     1286 <main+0xc6>
lea    0xece(%rip),%rdi
lea    0xe0d(%rip),%rdx
mov    %eax,%esi
mov    $0x45,%ecx
call   1030 <ErrorAbort@plt>
lea    0x4(%rsp),%rdi
call   10e0 <pthread_mutex_lock@plt>
test   %eax,%eax
je     12ae <main+0xee>
lea    0xeb8(%rip),%rdi
lea    0xde5(%rip),%rdx
mov    %eax,%esi
mov    $0x48,%ecx
call   1030 <ErrorAbort@plt>
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1050 <clock_gettime@plt>
test   %eax,%eax
je     12df <main+0x11f>
lea    0xe9a(%rip),%rdi
lea    0xdb4(%rip),%rdx
mov    %eax,%esi
mov    $0x4b,%ecx
call   1030 <ErrorAbort@plt>
mov    %r14,%rax
shr    $0x3,%rax
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
mul    %rcx
shr    $0x4,%rdx
imul   $0x3e8,%rdx,%rax
add    0x10(%rsp),%rdx
mov    %rdx,0x10(%rsp)
mov    %r14,%rcx
sub    %rax,%rcx
imul   $0xf4240,%rcx,%rax
add    0x8(%rsp),%rax
mov    %rax,0x8(%rsp)
cmp    $0x3b9aca01,%rax
jb     133b <main+0x17b>
add    $0x1,%rdx
mov    %rdx,0x10(%rsp)
add    $0xffffffffc4653600,%rax
mov    %rax,0x8(%rsp)
xor    %eax,%eax
call   1060 <clock@plt>
mov    %rax,%rbp
mov    0x2c7c(%rip),%rax
mov    (%rax),%ebx
lea    0x1c(%rsp),%rdi
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   10a0 <pthread_cond_timedwait@plt>
cmp    %eax,%ebx
je     1380 <main+0x1c0>
lea    0xe07(%rip),%rdi
lea    0xd13(%rip),%rdx
mov    %eax,%esi
mov    $0x55,%ecx
call   1030 <ErrorAbort@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <clock@plt>
sub    %rbp,%rax
cvtsi2sd %rax,%xmm0
mulsd  0xc67(%rip),%xmm0
mov    0x2c40(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,0x20(%rsp)
lea    0xdda(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdf0(%rip),%rdi
movsd  0x20(%rsp),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
movq   %r15,%xmm0
punpckldq 0xc34(%rip),%xmm0
subpd  0xc3c(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0x20(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jbe    142b <main+0x26b>
lea    0xde6(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
jmp    1437 <main+0x277>
mov    0x2bba(%rip),%rax
mov    (%rax),%edi
lea    0xc16(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%ebx
jmp    1437 <main+0x277>
lea    0xdb3(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
@.str = [5 x i8] c"t:m:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [63 x i8] c"Usage: cond_timedwait [-t timeout_in_ms] [-m max_cpu_usage_ms\0A\00"
@.str.2 = [19 x i8] c"pthread_mutex_init\00"
@.str.3 = [186 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/CTSRD-SOAAP/chromium-42.0.2311.135/refs/heads/lind/native_client/tests/threads/cond_timedwait.c\00"
@.str.4 = [18 x i8] c"pthread_cond_init\00"
@.str.5 = [19 x i8] c"pthread_mutex_lock\00"
@CLOCK_REALTIME = global i32 0
@.str.6 = [14 x i8] c"clock_gettime\00"
@ETIMEDOUT = global i32 0
@.str.7 = [23 x i8] c"pthread_cond_timedwait\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.8 = [39 x i8] c"pthread_cond_timedwait: waited %lu ms\0A\00"
@.str.9 = [51 x i8] c"CPU seconds used by pthread_cond_timedwait: %f ms\0A\00"
@.str.10 = [9 x i8] c"FAILED.\0A\00"
@.str.11 = [5 x i8] c"OK.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.timespec
%12 = alloca i64
%13 = alloca i64
%14 = alloca double
%15 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 100, i64* %7
store i64 40, i64* %15
br label %16
16: ; preds = %32, %2
%17 = load i32, i32* %4
%18 = load i8**, i8*** %5
%19 = call i32 @getopt(i32 %17, i8** %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %19, i32* %6
%20 = icmp ne i32 -1, %19
br i1 %20, label %21, label %33
21: ; preds = %16
%22 = load i32, i32* %6
switch i32 %22, label %29 [
i32 116, label %23
i32 109, label %26
]
23: ; preds = %21
%24 = load i32, i32* @optarg
%25 = call i64 @strtoul(i32 %24, i8** null, i32 0)
store i64 %25, i64* %7
br label %32
26: ; preds = %21
%27 = load i32, i32* @optarg
%28 = call i64 @strtoul(i32 %27, i8** null, i32 0)
store i64 %28, i64* %15
br label %32
29: ; preds = %21
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %122
32: ; preds = %26, %23
br label %16
33: ; preds = %16
%34 = call i32 @pthread_mutex_init(i32* %9, i32* null)
store i32 %34, i32* %8
%35 = icmp ne i32 0, %34
br i1 %35, label %36, label %41
36: ; preds = %33
br label %37
37: ; preds = %36
%38 = load i32, i32* %8
%39 = call i32 @ErrorAbort(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %38, i8* getelementptr inbounds ([186 x i8], [186 x i8]* @.str.3, i64 0, i64 0), i32 64)
br label %40
40: ; preds = %37
br label %41
41: ; preds = %40, %33
%42 = call i32 @pthread_cond_init(i32* %10, i32* null)
store i32 %42, i32* %8
%43 = icmp ne i32 0, %42
br i1 %43, label %44, label %49
44: ; preds = %41
br label %45
45: ; preds = %44
%46 = load i32, i32* %8
%47 = call i32 @ErrorAbort(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %46, i8* getelementptr inbounds ([186 x i8], [186 x i8]* @.str.3, i64 0, i64 0), i32 69)
br label %48
48: ; preds = %45
br label %49
49: ; preds = %48, %41
%50 = call i32 @pthread_mutex_lock(i32* %9)
store i32 %50, i32* %8
%51 = icmp ne i32 0, %50
br i1 %51, label %52, label %57
52: ; preds = %49
br label %53
53: ; preds = %52
%54 = load i32, i32* %8
%55 = call i32 @ErrorAbort(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %54, i8* getelementptr inbounds ([186 x i8], [186 x i8]* @.str.3, i64 0, i64 0), i32 72)
br label %56
56: ; preds = %53
br label %57
57: ; preds = %56, %49
%58 = load i32, i32* @CLOCK_REALTIME
%59 = call i32 @clock_gettime(i32 %58, %struct.timespec* %11)
store i32 %59, i32* %8
%60 = icmp ne i32 0, %59
br i1 %60, label %61, label %66
61: ; preds = %57
br label %62
62: ; preds = %61
%63 = load i32, i32* %8
%64 = call i32 @ErrorAbort(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %63, i8* getelementptr inbounds ([186 x i8], [186 x i8]* @.str.3, i64 0, i64 0), i32 75)
br label %65
65: ; preds = %62
br label %66
66: ; preds = %65, %57
%67 = load i64, i64* %7
%68 = udiv i64 %67, 1000
%69 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 1
%70 = load i64, i64* %69
%71 = add i64 %70, %68
store i64 %71, i64* %69
%72 = load i64, i64* %7
%73 = urem i64 %72, 1000
%74 = mul i64 %73, 1000
%75 = mul i64 %74, 1000
%76 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%77 = load i64, i64* %76
%78 = add i64 %77, %75
store i64 %78, i64* %76
%79 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%80 = load i64, i64* %79
%81 = icmp ugt i64 %80, 1000000000
br i1 %81, label %82, label %89
82: ; preds = %66
%83 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 1
%84 = load i64, i64* %83
%85 = add nsw i64 %84, 1
store i64 %85, i64* %83
%86 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%87 = load i64, i64* %86
%88 = sub i64 %87, 1000000000
store i64 %88, i64* %86
br label %89
89: ; preds = %82, %66
%90 = call i64 (...) @clock()
store i64 %90, i64* %12
%91 = load i32, i32* @ETIMEDOUT
%92 = call i32 @pthread_cond_timedwait(i32* %10, i32* %9, %struct.timespec* %11)
store i32 %92, i32* %8
%93 = icmp ne i32 %91, %92
br i1 %93, label %94, label %99
94: ; preds = %89
br label %95
95: ; preds = %94
%96 = load i32, i32* %8
%97 = call i32 @ErrorAbort(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %96, i8* getelementptr inbounds ([186 x i8], [186 x i8]* @.str.3, i64 0, i64 0), i32 85)
br label %98
98: ; preds = %95
br label %99
99: ; preds = %98, %89
%100 = call i64 (...) @clock()
store i64 %100, i64* %13
%101 = load i64, i64* %13
%102 = load i64, i64* %12
%103 = sub nsw i64 %101, %102
%104 = sitofp i64 %103 to double
%105 = fmul double 1.000000e+03, %104
%106 = load double, double* @CLOCKS_PER_SEC
%107 = fdiv double %105, %106
store double %107, double* %14
%108 = load i64, i64* %7
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i64 %108)
%110 = load double, double* %14
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0), double %110)
%112 = load double, double* %14
%113 = load i64, i64* %15
%114 = uitofp i64 %113 to double
%115 = fcmp ogt double %112, %114
br i1 %115, label %116, label %118
116: ; preds = %99
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %8
br label %120
118: ; preds = %99
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %8
br label %120
120: ; preds = %118, %116
%121 = load i32, i32* %8
store i32 %121, i32* %3
br label %122
122: ; preds = %120, %29
%123 = load i32, i32* %3
ret i32 %123
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
@.str = [5 x i8] c"t:m:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [63 x i8] c"Usage: cond_timedwait [-t timeout_in_ms] [-m max_cpu_usage_ms\0A\00"
@.str.2 = [19 x i8] c"pthread_mutex_init\00"
@.str.3 = [186 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/CTSRD-SOAAP/chromium-42.0.2311.135/refs/heads/lind/native_client/tests/threads/cond_timedwait.c\00"
@.str.4 = [18 x i8] c"pthread_cond_init\00"
@.str.5 = [19 x i8] c"pthread_mutex_lock\00"
@CLOCK_REALTIME = global i32 0
@.str.6 = [14 x i8] c"clock_gettime\00"
@ETIMEDOUT = global i32 0
@.str.7 = [23 x i8] c"pthread_cond_timedwait\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.8 = [39 x i8] c"pthread_cond_timedwait: waited %lu ms\0A\00"
@.str.9 = [51 x i8] c"CPU seconds used by pthread_cond_timedwait: %f ms\0A\00"
@str = [4 x i8] c"OK.\00"
@str.12 = [8 x i8] c"FAILED.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.timespec
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast %struct.timespec* %5 to i8*
br label %9
9: ; preds = %15, %2
%10 = phi i64 [ %17, %15 ], [ 100, %2 ]
%11 = phi i64 [ %13, %15 ], [ 40, %2 ]
br label %12
12: ; preds = %9, %18
%13 = phi i64 [ %20, %18 ], [ %11, %9 ]
%14 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %14, label %21 [
i32 -1, label %24
i32 116, label %15
i32 109, label %18
]
15: ; preds = %12
%16 = load i32, i32* @optarg
%17 = tail call i64 @strtoul(i32 %16, i8** null, i32 0)
br label %9
18: ; preds = %12
%19 = load i32, i32* @optarg
%20 = tail call i64 @strtoul(i32 %19, i8** null, i32 0)
br label %12
21: ; preds = %12
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0))
br label %81
24: ; preds = %12
%25 = call i32 @pthread_mutex_init(i32* %3, i32* null)
%26 = icmp eq i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = call i32 @ErrorAbort(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %25, i8* getelementptr inbounds ([186 x i8], [186 x i8]* @.str.3, i64 0, i64 0), i32 64)
br label %29
29: ; preds = %27, %24
%30 = call i32 @pthread_cond_init(i32* %4, i32* null)
%31 = icmp eq i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = call i32 @ErrorAbort(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %30, i8* getelementptr inbounds ([186 x i8], [186 x i8]* @.str.3, i64 0, i64 0), i32 69)
br label %34
34: ; preds = %32, %29
%35 = call i32 @pthread_mutex_lock(i32* %3)
%36 = icmp eq i32 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %34
%38 = call i32 @ErrorAbort(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %35, i8* getelementptr inbounds ([186 x i8], [186 x i8]* @.str.3, i64 0, i64 0), i32 72)
br label %39
39: ; preds = %37, %34
%40 = load i32, i32* @CLOCK_REALTIME
%41 = call i32 @clock_gettime(i32 %40, %struct.timespec* %5)
%42 = icmp eq i32 %41, 0
br i1 %42, label %45, label %43
43: ; preds = %39
%44 = call i32 @ErrorAbort(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %41, i8* getelementptr inbounds ([186 x i8], [186 x i8]* @.str.3, i64 0, i64 0), i32 75)
br label %45
45: ; preds = %43, %39
%46 = udiv i64 %10, 1000
%47 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
%48 = load i64, i64* %47
%49 = add i64 %48, %46
store i64 %49, i64* %47
%50 = urem i64 %10, 1000
%51 = mul nuw nsw i64 %50, 1000000
%52 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
%53 = load i64, i64* %52
%54 = add i64 %53, %51
store i64 %54, i64* %52
%55 = icmp ugt i64 %54, 1000000000
br i1 %55, label %56, label %59
56: ; preds = %45
%57 = add nsw i64 %49, 1
store i64 %57, i64* %47
%58 = add i64 %54, -1000000000
store i64 %58, i64* %52
br label %59
59: ; preds = %56, %45
%60 = call i64 (...) @clock()
%61 = load i32, i32* @ETIMEDOUT
%62 = call i32 @pthread_cond_timedwait(i32* %4, i32* %3, %struct.timespec* %5)
%63 = icmp eq i32 %61, %62
br i1 %63, label %66, label %64
64: ; preds = %59
%65 = call i32 @ErrorAbort(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %62, i8* getelementptr inbounds ([186 x i8], [186 x i8]* @.str.3, i64 0, i64 0), i32 85)
br label %66
66: ; preds = %64, %59
%67 = call i64 (...) @clock()
%68 = sub nsw i64 %67, %60
%69 = sitofp i64 %68 to double
%70 = fmul double %69, 1.000000e+03
%71 = load double, double* @CLOCKS_PER_SEC
%72 = fdiv double %70, %71
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i64 %10)
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0), double %72)
%75 = uitofp i64 %13 to double
%76 = fcmp ogt double %72, %75
br i1 %76, label %77, label %79
77: ; preds = %66
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.12, i64 0, i64 0))
br label %81
79: ; preds = %66
%80 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
br label %81
81: ; preds = %77, %79, %21
%82 = phi i32 [ 1, %21 ], [ 1, %77 ], [ 0, %79 ]
ret i32 %82
}