#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *,
                           char *);
int open(char *, int, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int Open(char *str, int flags, int mode) {
  int fd;
  assert(str != NULL);
  fd = open(str, flags, mode);
  if (fd < 0)
    do {
      fprintf(stderr, "ERROR: [%s:%d] %s: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/ystk/debian-freeipmi/refs/heads/"
              "master/ipmipower/src/wrappers.c",
              436, str, strerror(errno));
    } while (0);
  return fd;
}


x86 assembly (clang, -O0):
<Open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11ce <Open+0x8e>
jmp    1185 <Open+0x45>
mov    0x2e54(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%r8
mov    %rax,%r9
lea    0xe48(%rip),%rsi
lea    0xe58(%rip),%rdx
mov    $0x1b4,%ecx
call   1040 <fprintf@plt>
jmp    11ce <Open+0x8e>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Open>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1050 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    11a6 <Open+0x66>
mov    0x2e6c(%rip),%rax
mov    (%rax),%r14d
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe74(%rip),%rsi
lea    0xe84(%rip),%rdx
mov    %r14d,%edi
mov    $0x1b4,%ecx
mov    %rbx,%r8
mov    %rax,%r9
call   1040 <fprintf@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"ERROR: [%s:%d] %s: %s\0A\00"
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ystk/debian-freeipmi/refs/heads/master/ipmipower/src/wrappers.c\00"
@errno = global i32 0
define i32 @Open(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i8*, i8** %4
%13 = load i32, i32* %5
%14 = load i32, i32* %6
%15 = call i32 @open(i8* %12, i32 %13, i32 %14)
store i32 %15, i32* %7
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %3
br label %19
19: ; preds = %18
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %4
%22 = load i32, i32* @errno
%23 = call i8* @strerror(i32 %22)
%24 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 436, i8* %21, i8* %23)
br label %25
25: ; preds = %19
br label %26
26: ; preds = %25, %3
%27 = load i32, i32* %7
ret i32 %27
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"ERROR: [%s:%d] %s: %s\0A\00"
@.str.1 = [154 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ystk/debian-freeipmi/refs/heads/master/ipmipower/src/wrappers.c\00"
@errno = global i32 0
define i32 @Open(i8* %0, i32 %1, i32 %2) {
%4 = icmp ne i8* %0, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i32 @open(i8* %0, i32 %1, i32 %2)
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = load i32, i32* @errno
%12 = tail call i8* @strerror(i32 %11)
%13 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([154 x i8], [154 x i8]* @.str.1, i64 0, i64 0), i32 436, i8* %0, i8* %12)
br label %14
14: ; preds = %9, %3
ret i32 %7
}