#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 */

/* Variables and functions */
int CRYPTO_LOCK;
int CRYPTO_UNLOCK;
int CRYPTO_WRITE;
int /*<<< orphan*/ CRYPTO_lock(int, int, char const *, int);
int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
                    int line) {
  int ret;
  CRYPTO_lock(CRYPTO_LOCK | CRYPTO_WRITE, type, file, line);
  ret = *pointer + amount;
  *pointer = ret;
  CRYPTO_lock(CRYPTO_UNLOCK | CRYPTO_WRITE, type, file, line);
  return (ret);
}


x86 assembly (clang, -O0):
<CRYPTO_add_lock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    0x2eaf(%rip),%rax
mov    (%rax),%edi
mov    0x2eb6(%rip),%rax
or     (%rax),%edi
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1030 <CRYPTO_lock@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    0x2e80(%rip),%rax
or     (%rax),%edi
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1030 <CRYPTO_lock@plt>
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CRYPTO_add_lock>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %edx,%r12d
mov    %esi,%ebx
mov    %rdi,%rbp
mov    0x2eb0(%rip),%rax
mov    0x2eb9(%rip),%r13
mov    0x0(%r13),%edi
or     (%rax),%edi
mov    %edx,%esi
mov    %rcx,%rdx
mov    %r8d,%ecx
call   1030 <CRYPTO_lock@plt>
add    0x0(%rbp),%ebx
mov    %ebx,0x0(%rbp)
mov    0x2e79(%rip),%rax
mov    0x0(%r13),%edi
or     (%rax),%edi
mov    %r12d,%esi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1030 <CRYPTO_lock@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CRYPTO_LOCK = global i32 0
@CRYPTO_WRITE = global i32 0
@CRYPTO_UNLOCK = global i32 0
define i32 @CRYPTO_add_lock(i32* %0, i32 %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%12 = load i32, i32* @CRYPTO_LOCK
%13 = load i32, i32* @CRYPTO_WRITE
%14 = or i32 %12, %13
%15 = load i32, i32* %8
%16 = load i8*, i8** %9
%17 = load i32, i32* %10
%18 = call i32 @CRYPTO_lock(i32 %14, i32 %15, i8* %16, i32 %17)
%19 = load i32*, i32** %6
%20 = load i32, i32* %19
%21 = load i32, i32* %7
%22 = add nsw i32 %20, %21
store i32 %22, i32* %11
%23 = load i32, i32* %11
%24 = load i32*, i32** %6
store i32 %23, i32* %24
%25 = load i32, i32* @CRYPTO_UNLOCK
%26 = load i32, i32* @CRYPTO_WRITE
%27 = or i32 %25, %26
%28 = load i32, i32* %8
%29 = load i8*, i8** %9
%30 = load i32, i32* %10
%31 = call i32 @CRYPTO_lock(i32 %27, i32 %28, i8* %29, i32 %30)
%32 = load i32, i32* %11
ret i32 %32
}

LLVM IR (-O2):
@CRYPTO_LOCK = global i32 0
@CRYPTO_WRITE = global i32 0
@CRYPTO_UNLOCK = global i32 0
define i32 @CRYPTO_add_lock(i32* nocapture %0, i32 %1, i32 %2, i8* %3, i32 %4) {
%6 = load i32, i32* @CRYPTO_LOCK
%7 = load i32, i32* @CRYPTO_WRITE
%8 = or i32 %7, %6
%9 = tail call i32 @CRYPTO_lock(i32 %8, i32 %2, i8* %3, i32 %4)
%10 = load i32, i32* %0
%11 = add nsw i32 %10, %1
store i32 %11, i32* %0
%12 = load i32, i32* @CRYPTO_UNLOCK
%13 = load i32, i32* @CRYPTO_WRITE
%14 = or i32 %13, %12
%15 = tail call i32 @CRYPTO_lock(i32 %14, i32 %2, i8* %3, i32 %4)
ret i32 %11
}