#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 /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int fcntl(int, int /*<<< orphan*/, long);
int raise_socket_flags(int handle_socket, long new_socket_flags) {
  long socket_flags;
  if ((socket_flags = fcntl(handle_socket, F_GETFL, NULL)) == -1) {
    return socket_flags;
  }
  socket_flags |= new_socket_flags;
  return fcntl(handle_socket, F_SETFL, socket_flags);
}


x86 assembly (clang, -O0):
<raise_socket_flags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2eaf(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <fcntl@plt>
cltq
mov    %rax,-0x18(%rbp)
cmp    $0xffffffffffffffff,%rax
jne    1150 <raise_socket_flags+0x40>
mov    -0x18(%rbp),%rax
mov    %eax,-0x4(%rbp)
jmp    1174 <raise_socket_flags+0x64>
mov    -0x10(%rbp),%rax
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rdx
call   1030 <fcntl@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<raise_socket_flags>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
mov    0x2eb8(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
je     114b <raise_socket_flags+0x3b>
movslq %eax,%rdx
or     %r14,%rdx
mov    0x2ea5(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fcntl@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@F_GETFL = global i32 0
@F_SETFL = global i32 0
define i32 @raise_socket_flags(i32 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
store i32 %0, i32* %4
store i64 %1, i64* %5
%7 = load i32, i32* %4
%8 = load i32, i32* @F_GETFL
%9 = call i32 @fcntl(i32 %7, i32 %8, i64 0)
%10 = sext i32 %9 to i64
store i64 %10, i64* %6
%11 = icmp eq i64 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i64, i64* %6
%14 = trunc i64 %13 to i32
store i32 %14, i32* %3
br label %23
15: ; preds = %2
%16 = load i64, i64* %5
%17 = load i64, i64* %6
%18 = or i64 %17, %16
store i64 %18, i64* %6
%19 = load i32, i32* %4
%20 = load i32, i32* @F_SETFL
%21 = load i64, i64* %6
%22 = call i32 @fcntl(i32 %19, i32 %20, i64 %21)
store i32 %22, i32* %3
br label %23
23: ; preds = %15, %12
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@F_GETFL = global i32 0
@F_SETFL = global i32 0
define i32 @raise_socket_flags(i32 %0, i64 %1) {
%3 = load i32, i32* @F_GETFL
%4 = tail call i32 @fcntl(i32 %0, i32 %3, i64 0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = sext i32 %4 to i64
%8 = or i64 %7, %1
%9 = load i32, i32* @F_SETFL
%10 = tail call i32 @fcntl(i32 %0, i32 %9, i64 %8)
br label %11
11: ; preds = %2, %6
%12 = phi i32 [ %10, %6 ], [ -1, %2 ]
ret i32 %12
}