#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 /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ err_sys(char *, int /*<<< orphan*/);
int fcntl(int /*<<< orphan*/, int /*<<< orphan*/, int);
void del_fl(char *filename[], int flags) {
  int val;
  if ((val = fcntl(atoi(*filename), F_GETFL, 0)) < 0) {
    err_sys("fcntl error for fd %d", atoi(*filename));
  }
  val &= ~flags;
  if (fcntl(atoi(*filename), F_SETFL, val)) {
    err_sys("fcntl error for fd %d", atoi(*filename));
  }
}


x86 assembly (clang, -O0):
<del_fl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%edi
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    1183 <del_fl+0x53>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%esi
lea    0xe82(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0xc(%rbp),%eax
xor    $0xffffffff,%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%edi
mov    0x2e3c(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%edx
call   1040 <fcntl@plt>
cmp    $0x0,%eax
je     11d1 <del_fl+0xa1>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%esi
lea    0xe34(%rip),%rdi
call   1030 <err_sys@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<del_fl>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    (%rdi),%rdi
call   1050 <atoi@plt>
mov    0x2e90(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    116f <del_fl+0x3f>
mov    (%r14),%rdi
call   1050 <atoi@plt>
lea    0xe98(%rip),%rdi
mov    %eax,%esi
call   1030 <err_sys@plt>
not    %ebp
and    %ebp,%ebx
mov    (%r14),%rdi
call   1050 <atoi@plt>
mov    0x2e5e(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
mov    %ebx,%edx
call   1040 <fcntl@plt>
test   %eax,%eax
je     11ab <del_fl+0x7b>
mov    (%r14),%rdi
call   1050 <atoi@plt>
lea    0xe60(%rip),%rdi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <err_sys@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@F_GETFL = global i32 0
@.str = [22 x i8] c"fcntl error for fd %d\00"
@F_SETFL = global i32 0
define void @del_fl(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%6 = load i8**, i8*** %3
%7 = load i8*, i8** %6
%8 = call i32 @atoi(i8* %7)
%9 = load i32, i32* @F_GETFL
%10 = call i32 @fcntl(i32 %8, i32 %9, i32 0)
store i32 %10, i32* %5
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %3
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
%16 = call i32 @err_sys(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %12, %2
%18 = load i32, i32* %4
%19 = xor i32 %18, -1
%20 = load i32, i32* %5
%21 = and i32 %20, %19
store i32 %21, i32* %5
%22 = load i8**, i8*** %3
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
%25 = load i32, i32* @F_SETFL
%26 = load i32, i32* %5
%27 = call i32 @fcntl(i32 %24, i32 %25, i32 %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %17
%30 = load i8**, i8*** %3
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
%33 = call i32 @err_sys(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %29, %17
ret void
}

LLVM IR (-O2):
@F_GETFL = global i32 0
@.str = [22 x i8] c"fcntl error for fd %d\00"
@F_SETFL = global i32 0
define void @del_fl(i8** nocapture %0, i32 %1) {
%3 = load i8*, i8** %0
%4 = tail call i32 @atoi(i8* %3)
%5 = load i32, i32* @F_GETFL
%6 = tail call i32 @fcntl(i32 %4, i32 %5, i32 0)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i8*, i8** %0
%10 = tail call i32 @atoi(i8* %9)
%11 = tail call i32 @err_sys(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %8, %2
%13 = xor i32 %1, -1
%14 = and i32 %6, %13
%15 = load i8*, i8** %0
%16 = tail call i32 @atoi(i8* %15)
%17 = load i32, i32* @F_SETFL
%18 = tail call i32 @fcntl(i32 %16, i32 %17, i32 %14)
%19 = icmp eq i32 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %12
%21 = load i8*, i8** %0
%22 = tail call i32 @atoi(i8* %21)
%23 = tail call i32 @err_sys(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %20, %12
ret void
}