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

/* Variables and functions */
int /*<<< orphan*/ PTHREAD_MUTEX_INITIALIZER;
int /*<<< orphan*/ alarm(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ lock_twice(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  alarm(3);
  {
    pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
    printf("Non-recursive mutex.\n");
    fflush(stdout);
    lock_twice(&m);
  }
  printf("Done.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x3,%edi
call   1040 <alarm@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    -0x14(%rbp),%rdi
call   1060 <lock_twice@plt>
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x3,%edi
call   1040 <alarm@plt>
mov    0x2e8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    0x4(%rsp),%rdi
call   1060 <lock_twice@plt>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@PTHREAD_MUTEX_INITIALIZER = global i32 0
@.str = [22 x i8] c"Non-recursive mutex.\0A\00"
@stdout = global i32 0
@.str.1 = [7 x i8] c"Done.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @alarm(i32 3)
%8 = load i32, i32* @PTHREAD_MUTEX_INITIALIZER
store i32 %8, i32* %6
%9 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stdout
%11 = call i32 @fflush(i32 %10)
%12 = call i32 @lock_twice(i32* %6)
%13 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@PTHREAD_MUTEX_INITIALIZER = global i32 0
@stdout = global i32 0
@str = [21 x i8] c"Non-recursive mutex.\00"
@str.2 = [6 x i8] c"Done.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = tail call i32 @alarm(i32 3)
%5 = bitcast i32* %3 to i8*
%6 = load i32, i32* @PTHREAD_MUTEX_INITIALIZER
store i32 %6, i32* %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%8 = load i32, i32* @stdout
%9 = tail call i32 @fflush(i32 %8)
%10 = call i32 @lock_twice(i32* %3)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.2, i64 0, i64 0))
ret i32 0
}