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

/* Variables and functions */
int FILENAME_MAX;
scalar_t__ close(int const);
int errno;
scalar_t__ getpid();
scalar_t__ remove(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned long);
int ipacl_close(const int reqport) {
  char fname[FILENAME_MAX];
  if (close(reqport) < 0)
    return errno;
  snprintf(fname, sizeof(fname), "/tmp/ipacl-request.%lu",
           (unsigned long)getpid());
  if (remove(fname) < 0)
    return errno;
  return 0;
}


x86 assembly (clang, -O0):
<ipacl_close>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x30(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
cmp    $0x0,%rax
jge    11a5 <ipacl_close+0x65>
mov    0x2e44(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x1c(%rbp)
jmp    1202 <ipacl_close+0xc2>
mov    -0x30(%rbp),%rax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x34(%rbp),%esi
mov    -0x28(%rbp),%rdi
mov    %rax,%rcx
lea    0xe3c(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <remove@plt>
cmp    $0x0,%rax
jge    11f4 <ipacl_close+0xb4>
mov    0x2df5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x1c(%rbp)
jmp    1202 <ipacl_close+0xc2>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipacl_close>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    0x2e9a(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%rbx
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
call   1060 <close@plt>
test   %rax,%rax
js     119f <ipacl_close+0x5f>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe86(%rip),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %rax,%rcx
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <remove@plt>
mov    0x2e41(%rip),%rcx
sar    $0x3f,%rax
and    (%rcx),%eax
jmp    11a8 <ipacl_close+0x68>
mov    0x2e32(%rip),%rax
mov    (%rax),%eax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@FILENAME_MAX = global i32 0
@errno = global i32 0
@.str = [23 x i8] c"/tmp/ipacl-request.%lu\00"
define i32 @ipacl_close(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i32 %0, i32* %3
%7 = load i32, i32* @FILENAME_MAX
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %4
%10 = alloca i8, i64 %8
store i64 %8, i64* %5
%11 = load i32, i32* %3
%12 = call i64 @close(i32 %11)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = load i32, i32* @errno
store i32 %15, i32* %2
store i32 1, i32* %6
br label %25
16: ; preds = %1
%17 = trunc i64 %8 to i32
%18 = call i64 (...) @getpid()
%19 = call i32 @snprintf(i8* %10, i32 %17, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 %18)
%20 = call i64 @remove(i8* %10)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = load i32, i32* @errno
store i32 %23, i32* %2
store i32 1, i32* %6
br label %25
24: ; preds = %16
store i32 0, i32* %2
store i32 1, i32* %6
br label %25
25: ; preds = %24, %22, %14
%26 = load i8*, i8** %4
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
@FILENAME_MAX = global i32 0
@errno = global i32 0
@.str = [23 x i8] c"/tmp/ipacl-request.%lu\00"
define i32 @ipacl_close(i32 %0) {
%2 = load i32, i32* @FILENAME_MAX
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = tail call i64 @close(i32 %0)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load i32, i32* @errno
br label %16
9: ; preds = %1
%10 = tail call i64 (...) @getpid()
%11 = call i32 @snprintf(i8* %4, i32 %2, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 %10)
%12 = call i64 @remove(i8* %4)
%13 = icmp slt i64 %12, 0
%14 = load i32, i32* @errno
%15 = select i1 %13, i32 %14, i32 0
br label %16
16: ; preds = %9, %7
%17 = phi i32 [ %8, %7 ], [ %15, %9 ]
ret i32 %17
}