#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 {
  int dummy;
};
typedef int /*<<< orphan*/ pthread_mutex_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int get_current_timespec(struct timespec *);
int pthread_mutex_destroy(int /*<<< orphan*/ *);
int pthread_mutex_init(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int pthread_mutex_lock(int /*<<< orphan*/ *);
int pthread_mutex_timedlock(int /*<<< orphan*/ *, struct timespec *);
int pthread_mutex_trylock(int /*<<< orphan*/ *);
int pthread_mutex_unlock(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ timespec_add_milli(struct timespec *, int);
int test_mutex_lock_simple(void) {
  pthread_mutex_t mutex;
  struct timespec ts;
  do {
    int __my_ret__ = pthread_mutex_init(&mutex, NULL);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 67,
              "pthread_mutex_init(&mutex, NULL)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = pthread_mutex_lock(&mutex);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 68,
              "pthread_mutex_lock(&mutex)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = pthread_mutex_unlock(&mutex);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 69,
              "pthread_mutex_unlock(&mutex)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = pthread_mutex_lock(&mutex);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 70,
              "pthread_mutex_lock(&mutex)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = pthread_mutex_unlock(&mutex);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 71,
              "pthread_mutex_unlock(&mutex)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = pthread_mutex_trylock(&mutex);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 72,
              "pthread_mutex_trylock(&mutex)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = pthread_mutex_unlock(&mutex);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 73,
              "pthread_mutex_unlock(&mutex)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = get_current_timespec(&ts);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 74,
              "get_current_timespec(&ts)");
      return __my_ret__;
    }
  } while (0);
  ;
  timespec_add_milli(&ts, 50);
  do {
    int __my_ret__ = pthread_mutex_timedlock(&mutex, &ts);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 76,
              "pthread_mutex_timedlock(&mutex, &ts)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = pthread_mutex_unlock(&mutex);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 77,
              "pthread_mutex_unlock(&mutex)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = pthread_mutex_destroy(&mutex);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 78,
              "pthread_mutex_destroy(&mutex)");
      return __my_ret__;
    }
  } while (0);
  ;
  return 0;
}


x86 assembly (clang, -O0):
<test_mutex_lock_simple>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <pthread_mutex_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11de <test_mutex_lock_simple+0x4e>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
mov    $0x43,%edx
lea    0xe49(%rip),%rcx
call   1060 <fprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14ef <test_mutex_lock_simple+0x35f>
jmp    11e3 <test_mutex_lock_simple+0x53>
jmp    11e8 <test_mutex_lock_simple+0x58>
lea    -0x8(%rbp),%rdi
call   10b0 <pthread_mutex_lock@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     122a <test_mutex_lock_simple+0x9a>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xdf2(%rip),%rsi
mov    $0x44,%edx
lea    0xe1e(%rip),%rcx
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14ef <test_mutex_lock_simple+0x35f>
jmp    122f <test_mutex_lock_simple+0x9f>
jmp    1234 <test_mutex_lock_simple+0xa4>
lea    -0x8(%rbp),%rdi
call   1090 <pthread_mutex_unlock@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1276 <test_mutex_lock_simple+0xe6>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
lea    0xda6(%rip),%rsi
mov    $0x45,%edx
lea    0xded(%rip),%rcx
call   1060 <fprintf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14ef <test_mutex_lock_simple+0x35f>
jmp    127b <test_mutex_lock_simple+0xeb>
jmp    1280 <test_mutex_lock_simple+0xf0>
lea    -0x8(%rbp),%rdi
call   10b0 <pthread_mutex_lock@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     12c2 <test_mutex_lock_simple+0x132>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
lea    0xd5a(%rip),%rsi
mov    $0x46,%edx
lea    0xd86(%rip),%rcx
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14ef <test_mutex_lock_simple+0x35f>
jmp    12c7 <test_mutex_lock_simple+0x137>
jmp    12cc <test_mutex_lock_simple+0x13c>
lea    -0x8(%rbp),%rdi
call   1090 <pthread_mutex_unlock@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     130e <test_mutex_lock_simple+0x17e>
mov    0x2cf7(%rip),%rax
mov    (%rax),%edi
lea    0xd0e(%rip),%rsi
mov    $0x47,%edx
lea    0xd55(%rip),%rcx
call   1060 <fprintf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14ef <test_mutex_lock_simple+0x35f>
jmp    1313 <test_mutex_lock_simple+0x183>
jmp    1318 <test_mutex_lock_simple+0x188>
lea    -0x8(%rbp),%rdi
call   1050 <pthread_mutex_trylock@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     135a <test_mutex_lock_simple+0x1ca>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
lea    0xcc2(%rip),%rsi
mov    $0x48,%edx
lea    0xd26(%rip),%rcx
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14ef <test_mutex_lock_simple+0x35f>
jmp    135f <test_mutex_lock_simple+0x1cf>
jmp    1364 <test_mutex_lock_simple+0x1d4>
lea    -0x8(%rbp),%rdi
call   1090 <pthread_mutex_unlock@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     13a6 <test_mutex_lock_simple+0x216>
mov    0x2c5f(%rip),%rax
mov    (%rax),%edi
lea    0xc76(%rip),%rsi
mov    $0x49,%edx
lea    0xcbd(%rip),%rcx
call   1060 <fprintf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14ef <test_mutex_lock_simple+0x35f>
jmp    13ab <test_mutex_lock_simple+0x21b>
jmp    13b0 <test_mutex_lock_simple+0x220>
lea    -0x10(%rbp),%rdi
call   1080 <get_current_timespec@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     13f2 <test_mutex_lock_simple+0x262>
mov    0x2c13(%rip),%rax
mov    (%rax),%edi
lea    0xc2a(%rip),%rsi
mov    $0x4a,%edx
lea    0xcac(%rip),%rcx
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14ef <test_mutex_lock_simple+0x35f>
jmp    13f7 <test_mutex_lock_simple+0x267>
lea    -0x10(%rbp),%rdi
mov    $0x32,%esi
call   1030 <timespec_add_milli@plt>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <pthread_mutex_timedlock@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     144b <test_mutex_lock_simple+0x2bb>
mov    0x2bba(%rip),%rax
mov    (%rax),%edi
lea    0xbd1(%rip),%rsi
mov    $0x4c,%edx
lea    0xc6d(%rip),%rcx
call   1060 <fprintf@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14ef <test_mutex_lock_simple+0x35f>
jmp    1450 <test_mutex_lock_simple+0x2c0>
jmp    1455 <test_mutex_lock_simple+0x2c5>
lea    -0x8(%rbp),%rdi
call   1090 <pthread_mutex_unlock@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     1497 <test_mutex_lock_simple+0x307>
mov    0x2b6e(%rip),%rax
mov    (%rax),%edi
lea    0xb85(%rip),%rsi
mov    $0x4d,%edx
lea    0xbcc(%rip),%rcx
call   1060 <fprintf@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14ef <test_mutex_lock_simple+0x35f>
jmp    149c <test_mutex_lock_simple+0x30c>
jmp    14a1 <test_mutex_lock_simple+0x311>
lea    -0x8(%rbp),%rdi
call   1040 <pthread_mutex_destroy@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     14e3 <test_mutex_lock_simple+0x353>
mov    0x2b22(%rip),%rax
mov    (%rax),%edi
lea    0xb39(%rip),%rsi
mov    $0x4e,%edx
lea    0xbfa(%rip),%rcx
call   1060 <fprintf@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14ef <test_mutex_lock_simple+0x35f>
jmp    14e8 <test_mutex_lock_simple+0x358>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_mutex_lock_simple>:
push   %rbx
sub    $0x10,%rsp
lea    0x4(%rsp),%rdi
xor    %esi,%esi
call   10a0 <pthread_mutex_init@plt>
test   %eax,%eax
je     11c8 <test_mutex_lock_simple+0x38>
mov    %eax,%ebx
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
lea    0xe59(%rip),%rcx
mov    $0x43,%edx
jmp    13bc <test_mutex_lock_simple+0x22c>
lea    0x4(%rsp),%rdi
call   10b0 <pthread_mutex_lock@plt>
test   %eax,%eax
je     11f9 <test_mutex_lock_simple+0x69>
mov    %eax,%ebx
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe18(%rip),%rsi
lea    0xe49(%rip),%rcx
mov    $0x44,%edx
jmp    13bc <test_mutex_lock_simple+0x22c>
lea    0x4(%rsp),%rdi
call   1090 <pthread_mutex_unlock@plt>
test   %eax,%eax
je     122a <test_mutex_lock_simple+0x9a>
mov    %eax,%ebx
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
lea    0xde7(%rip),%rsi
lea    0xe33(%rip),%rcx
mov    $0x45,%edx
jmp    13bc <test_mutex_lock_simple+0x22c>
lea    0x4(%rsp),%rdi
call   10b0 <pthread_mutex_lock@plt>
test   %eax,%eax
je     125b <test_mutex_lock_simple+0xcb>
mov    %eax,%ebx
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
lea    0xdb6(%rip),%rsi
lea    0xde7(%rip),%rcx
mov    $0x46,%edx
jmp    13bc <test_mutex_lock_simple+0x22c>
lea    0x4(%rsp),%rdi
call   1090 <pthread_mutex_unlock@plt>
test   %eax,%eax
je     128c <test_mutex_lock_simple+0xfc>
mov    %eax,%ebx
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xd85(%rip),%rsi
lea    0xdd1(%rip),%rcx
mov    $0x47,%edx
jmp    13bc <test_mutex_lock_simple+0x22c>
lea    0x4(%rsp),%rdi
call   1050 <pthread_mutex_trylock@plt>
test   %eax,%eax
je     12bd <test_mutex_lock_simple+0x12d>
mov    %eax,%ebx
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
lea    0xd54(%rip),%rsi
lea    0xdbd(%rip),%rcx
mov    $0x48,%edx
jmp    13bc <test_mutex_lock_simple+0x22c>
lea    0x4(%rsp),%rdi
call   1090 <pthread_mutex_unlock@plt>
test   %eax,%eax
je     12ee <test_mutex_lock_simple+0x15e>
mov    %eax,%ebx
mov    0x2d0c(%rip),%rax
mov    (%rax),%edi
lea    0xd23(%rip),%rsi
lea    0xd6f(%rip),%rcx
mov    $0x49,%edx
jmp    13bc <test_mutex_lock_simple+0x22c>
lea    0x8(%rsp),%rdi
call   1080 <get_current_timespec@plt>
test   %eax,%eax
je     131f <test_mutex_lock_simple+0x18f>
mov    %eax,%ebx
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
lea    0xcf2(%rip),%rsi
lea    0xd79(%rip),%rcx
mov    $0x4a,%edx
jmp    13bc <test_mutex_lock_simple+0x22c>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x32,%esi
call   1030 <timespec_add_milli@plt>
lea    0x4(%rsp),%rdi
mov    %rbx,%rsi
call   1070 <pthread_mutex_timedlock@plt>
test   %eax,%eax
je     1362 <test_mutex_lock_simple+0x1d2>
mov    %eax,%ebx
mov    0x2c95(%rip),%rax
mov    (%rax),%edi
lea    0xcac(%rip),%rsi
lea    0xd4d(%rip),%rcx
mov    $0x4c,%edx
jmp    13bc <test_mutex_lock_simple+0x22c>
lea    0x4(%rsp),%rdi
call   1090 <pthread_mutex_unlock@plt>
test   %eax,%eax
je     1390 <test_mutex_lock_simple+0x200>
mov    %eax,%ebx
mov    0x2c67(%rip),%rax
mov    (%rax),%edi
lea    0xc7e(%rip),%rsi
lea    0xcca(%rip),%rcx
mov    $0x4d,%edx
jmp    13bc <test_mutex_lock_simple+0x22c>
lea    0x4(%rsp),%rdi
call   1040 <pthread_mutex_destroy@plt>
test   %eax,%eax
je     13c9 <test_mutex_lock_simple+0x239>
mov    %eax,%ebx
mov    0x2c39(%rip),%rax
mov    (%rax),%edi
lea    0xc50(%rip),%rsi
lea    0xd16(%rip),%rcx
mov    $0x4e,%edx
call   1060 <fprintf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
xor    %ebx,%ebx
jmp    13c1 <test_mutex_lock_simple+0x231>

LLVM IR (-O0):
%struct.timespec = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"failed on line %d: %s\0A\00"
@.str.1 = [33 x i8] c"pthread_mutex_init(&mutex, NULL)\00"
@.str.2 = [27 x i8] c"pthread_mutex_lock(&mutex)\00"
@.str.3 = [29 x i8] c"pthread_mutex_unlock(&mutex)\00"
@.str.4 = [30 x i8] c"pthread_mutex_trylock(&mutex)\00"
@.str.5 = [26 x i8] c"get_current_timespec(&ts)\00"
@.str.6 = [37 x i8] c"pthread_mutex_timedlock(&mutex, &ts)\00"
@.str.7 = [30 x i8] c"pthread_mutex_destroy(&mutex)\00"
define i32 @test_mutex_lock_simple() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.timespec
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
br label %15
15: ; preds = %0
%16 = call i32 @pthread_mutex_init(i32* %2, i32* null)
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 67, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* %4
store i32 %22, i32* %1
br label %126
23: ; preds = %15
br label %24
24: ; preds = %23
br label %25
25: ; preds = %24
%26 = call i32 @pthread_mutex_lock(i32* %2)
store i32 %26, i32* %5
%27 = load i32, i32* %5
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 68, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%32 = load i32, i32* %5
store i32 %32, i32* %1
br label %126
33: ; preds = %25
br label %34
34: ; preds = %33
br label %35
35: ; preds = %34
%36 = call i32 @pthread_mutex_unlock(i32* %2)
store i32 %36, i32* %6
%37 = load i32, i32* %6
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = load i32, i32* @stderr
%41 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 69, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%42 = load i32, i32* %6
store i32 %42, i32* %1
br label %126
43: ; preds = %35
br label %44
44: ; preds = %43
br label %45
45: ; preds = %44
%46 = call i32 @pthread_mutex_lock(i32* %2)
store i32 %46, i32* %7
%47 = load i32, i32* %7
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %45
%50 = load i32, i32* @stderr
%51 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 70, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%52 = load i32, i32* %7
store i32 %52, i32* %1
br label %126
53: ; preds = %45
br label %54
54: ; preds = %53
br label %55
55: ; preds = %54
%56 = call i32 @pthread_mutex_unlock(i32* %2)
store i32 %56, i32* %8
%57 = load i32, i32* %8
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %55
%60 = load i32, i32* @stderr
%61 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 71, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%62 = load i32, i32* %8
store i32 %62, i32* %1
br label %126
63: ; preds = %55
br label %64
64: ; preds = %63
br label %65
65: ; preds = %64
%66 = call i32 @pthread_mutex_trylock(i32* %2)
store i32 %66, i32* %9
%67 = load i32, i32* %9
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %65
%70 = load i32, i32* @stderr
%71 = call i32 @fprintf(i32 %70, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 72, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%72 = load i32, i32* %9
store i32 %72, i32* %1
br label %126
73: ; preds = %65
br label %74
74: ; preds = %73
br label %75
75: ; preds = %74
%76 = call i32 @pthread_mutex_unlock(i32* %2)
store i32 %76, i32* %10
%77 = load i32, i32* %10
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %83
79: ; preds = %75
%80 = load i32, i32* @stderr
%81 = call i32 @fprintf(i32 %80, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 73, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%82 = load i32, i32* %10
store i32 %82, i32* %1
br label %126
83: ; preds = %75
br label %84
84: ; preds = %83
br label %85
85: ; preds = %84
%86 = call i32 @get_current_timespec(%struct.timespec* %3)
store i32 %86, i32* %11
%87 = load i32, i32* %11
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %93
89: ; preds = %85
%90 = load i32, i32* @stderr
%91 = call i32 @fprintf(i32 %90, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 74, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%92 = load i32, i32* %11
store i32 %92, i32* %1
br label %126
93: ; preds = %85
br label %94
94: ; preds = %93
%95 = call i32 @timespec_add_milli(%struct.timespec* %3, i32 50)
br label %96
96: ; preds = %94
%97 = call i32 @pthread_mutex_timedlock(i32* %2, %struct.timespec* %3)
store i32 %97, i32* %12
%98 = load i32, i32* %12
%99 = icmp ne i32 %98, 0
br i1 %99, label %100, label %104
100: ; preds = %96
%101 = load i32, i32* @stderr
%102 = call i32 @fprintf(i32 %101, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 76, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
%103 = load i32, i32* %12
store i32 %103, i32* %1
br label %126
104: ; preds = %96
br label %105
105: ; preds = %104
br label %106
106: ; preds = %105
%107 = call i32 @pthread_mutex_unlock(i32* %2)
store i32 %107, i32* %13
%108 = load i32, i32* %13
%109 = icmp ne i32 %108, 0
br i1 %109, label %110, label %114
110: ; preds = %106
%111 = load i32, i32* @stderr
%112 = call i32 @fprintf(i32 %111, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 77, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%113 = load i32, i32* %13
store i32 %113, i32* %1
br label %126
114: ; preds = %106
br label %115
115: ; preds = %114
br label %116
116: ; preds = %115
%117 = call i32 @pthread_mutex_destroy(i32* %2)
store i32 %117, i32* %14
%118 = load i32, i32* %14
%119 = icmp ne i32 %118, 0
br i1 %119, label %120, label %124
120: ; preds = %116
%121 = load i32, i32* @stderr
%122 = call i32 @fprintf(i32 %121, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 78, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%123 = load i32, i32* %14
store i32 %123, i32* %1
br label %126
124: ; preds = %116
br label %125
125: ; preds = %124
store i32 0, i32* %1
br label %126
126: ; preds = %125, %120, %110, %100, %89, %79, %69, %59, %49, %39, %29, %19
%127 = load i32, i32* %1
ret i32 %127
}

LLVM IR (-O2):
%struct.timespec = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"failed on line %d: %s\0A\00"
@.str.1 = [33 x i8] c"pthread_mutex_init(&mutex, NULL)\00"
@.str.2 = [27 x i8] c"pthread_mutex_lock(&mutex)\00"
@.str.3 = [29 x i8] c"pthread_mutex_unlock(&mutex)\00"
@.str.4 = [30 x i8] c"pthread_mutex_trylock(&mutex)\00"
@.str.5 = [26 x i8] c"get_current_timespec(&ts)\00"
@.str.6 = [37 x i8] c"pthread_mutex_timedlock(&mutex, &ts)\00"
@.str.7 = [30 x i8] c"pthread_mutex_destroy(&mutex)\00"
define i32 @test_mutex_lock_simple() {
%1 = alloca i32
%2 = alloca %struct.timespec
%3 = bitcast i32* %1 to i8*
%4 = bitcast %struct.timespec* %2 to i8*
%5 = call i32 @pthread_mutex_init(i32* %1, i32* null)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 67, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %71
10: ; preds = %0
%11 = call i32 @pthread_mutex_lock(i32* %1)
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 68, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %71
16: ; preds = %10
%17 = call i32 @pthread_mutex_unlock(i32* %1)
%18 = icmp eq i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 69, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %71
22: ; preds = %16
%23 = call i32 @pthread_mutex_lock(i32* %1)
%24 = icmp eq i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 70, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %71
28: ; preds = %22
%29 = call i32 @pthread_mutex_unlock(i32* %1)
%30 = icmp eq i32 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 71, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %71
34: ; preds = %28
%35 = call i32 @pthread_mutex_trylock(i32* %1)
%36 = icmp eq i32 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %34
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 72, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %71
40: ; preds = %34
%41 = call i32 @pthread_mutex_unlock(i32* %1)
%42 = icmp eq i32 %41, 0
br i1 %42, label %46, label %43
43: ; preds = %40
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 73, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %71
46: ; preds = %40
%47 = call i32 @get_current_timespec(%struct.timespec* %2)
%48 = icmp eq i32 %47, 0
br i1 %48, label %52, label %49
49: ; preds = %46
%50 = load i32, i32* @stderr
%51 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 74, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %71
52: ; preds = %46
%53 = call i32 @timespec_add_milli(%struct.timespec* %2, i32 50)
%54 = call i32 @pthread_mutex_timedlock(i32* %1, %struct.timespec* %2)
%55 = icmp eq i32 %54, 0
br i1 %55, label %59, label %56
56: ; preds = %52
%57 = load i32, i32* @stderr
%58 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 76, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
br label %71
59: ; preds = %52
%60 = call i32 @pthread_mutex_unlock(i32* %1)
%61 = icmp eq i32 %60, 0
br i1 %61, label %65, label %62
62: ; preds = %59
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 77, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %71
65: ; preds = %59
%66 = call i32 @pthread_mutex_destroy(i32* %1)
%67 = icmp eq i32 %66, 0
br i1 %67, label %71, label %68
68: ; preds = %65
%69 = load i32, i32* @stderr
%70 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 78, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
br label %71
71: ; preds = %68, %65, %62, %56, %49, %43, %37, %31, %25, %19, %13, %7
%72 = phi i32 [ %60, %62 ], [ %54, %56 ], [ %47, %49 ], [ %41, %43 ], [ %35, %37 ], [ %29, %31 ], [ %23, %25 ], [ %17, %19 ], [ %11, %13 ], [ %5, %7 ], [ 0, %65 ], [ %66, %68 ]
ret i32 %72
}