#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 */
struct io_uring {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int io_uring_queue_init(unsigned int, struct io_uring *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int);
int setup_context(unsigned entries, struct io_uring *ring) {
  int ret;
  ret = io_uring_queue_init(entries, ring, 0);
  if (ret < 0) {
    fprintf(stderr, "queue_init: %s\n", strerror(-ret));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<setup_context>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1030 <io_uring_queue_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    118e <setup_context+0x5e>
mov    0x2e7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
xor    %edi,%edi
sub    -0x14(%rbp),%edi
call   1050 <strerror@plt>
mov    -0x18(%rbp),%edi
mov    %rax,%rdx
lea    0xe83(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1195 <setup_context+0x65>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_context>:
push   %rbx
xor    %ebx,%ebx
xor    %edx,%edx
call   1030 <io_uring_queue_init@plt>
test   %eax,%eax
jns    1166 <setup_context+0x36>
mov    0x2e9b(%rip),%rcx
mov    (%rcx),%ebx
neg    %eax
mov    %eax,%edi
call   1050 <strerror@plt>
lea    0xea9(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.io_uring = type { i32 }
@stderr = global i32 0
@.str = [16 x i8] c"queue_init: %s\0A\00"
define i32 @setup_context(i32 %0, %struct.io_uring* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.io_uring*
%6 = alloca i32
store i32 %0, i32* %4
store %struct.io_uring* %1, %struct.io_uring** %5
%7 = load i32, i32* %4
%8 = load %struct.io_uring*, %struct.io_uring** %5
%9 = call i32 @io_uring_queue_init(i32 %7, %struct.io_uring* %8, i32 0)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i32, i32* %6
%15 = sub nsw i32 0, %14
%16 = call i8* @strerror(i32 %15)
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 -1, i32* %3
br label %19
18: ; preds = %2
store i32 0, i32* %3
br label %19
19: ; preds = %18, %12
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
%struct.io_uring = type { i32 }
@stderr = global i32 0
@.str = [16 x i8] c"queue_init: %s\0A\00"
define i32 @setup_context(i32 %0, %struct.io_uring* %1) {
%3 = tail call i32 @io_uring_queue_init(i32 %0, %struct.io_uring* %1, i32 0)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = sub nsw i32 0, %3
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %2, %5
%11 = phi i32 [ -1, %5 ], [ 0, %2 ]
ret i32 %11
}