#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 close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ my_fatal(char *, char *, ...);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
void my_close(int fd) {
  {
    if (!(fd >= 0))
      my_fatal("file \"%s\", line %d, assertion \""
               "fd>=0"
               "\" failed\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/ddugovic/polyglot/refs/heads/"
               "master/pipex_posix.c",
               354);
  };
  if (close(fd) == -1)
    my_fatal("my_close(): close(): %s\n", strerror(errno));
}


x86 assembly (clang, -O0):
<my_close>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    115f <my_close+0x2f>
lea    0xeb4(%rip),%rdi
lea    0xedb(%rip),%rsi
mov    $0x162,%edx
mov    $0x0,%al
call   1040 <my_fatal@plt>
mov    -0x4(%rbp),%edi
call   1030 <close@plt>
cmp    $0xffffffff,%eax
jne    118f <my_close+0x5f>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
movslq %eax,%rsi
lea    0xf32(%rip),%rdi
mov    $0x0,%al
call   1040 <my_fatal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_close>:
push   %rbx
mov    %edi,%ebx
test   %edi,%edi
jns    1151 <my_close+0x21>
lea    0xec2(%rip),%rdi
lea    0xee9(%rip),%rsi
mov    $0x162,%edx
xor    %eax,%eax
call   1040 <my_fatal@plt>
mov    %ebx,%edi
call   1030 <close@plt>
cmp    $0xffffffff,%eax
je     115f <my_close+0x2f>
pop    %rbx
ret
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
movslq %eax,%rsi
lea    0xf43(%rip),%rdi
xor    %eax,%eax
pop    %rbx
jmp    1040 <my_fatal@plt>

LLVM IR (-O0):
@.str = [46 x i8] c"file \22%s\22, line %d, assertion \22fd>=0\22 failed\0A\00"
@.str.1 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ddugovic/polyglot/refs/heads/master/pipex_posix.c\00"
@.str.2 = [25 x i8] c"my_close(): close(): %s\0A\00"
@errno = global i32 0
define void @my_close(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sge i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 354)
br label %7
7: ; preds = %5, %1
%8 = load i32, i32* %2
%9 = call i32 @close(i32 %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = load i32, i32* @errno
%13 = call i32 @strerror(i32 %12)
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i8*
%16 = call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %11, %7
ret void
}

LLVM IR (-O2):
@.str = [46 x i8] c"file \22%s\22, line %d, assertion \22fd>=0\22 failed\0A\00"
@.str.1 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ddugovic/polyglot/refs/heads/master/pipex_posix.c\00"
@.str.2 = [25 x i8] c"my_close(): close(): %s\0A\00"
@errno = global i32 0
define void @my_close(i32 %0) {
%2 = icmp sgt i32 %0, -1
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 354)
br label %5
5: ; preds = %3, %1
%6 = tail call i32 @close(i32 %0)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %14
8: ; preds = %5
%9 = load i32, i32* @errno
%10 = tail call i32 @strerror(i32 %9)
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i8*
%13 = tail call i32 (i8*, i8*, ...) @my_fatal(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %8, %5
ret void
}