#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 */
scalar_t__ ioperm(int, int, int);
int /*<<< orphan*/ printf(char *, int);
int init_port() {
  if (ioperm(0x80, 1, 1) < 0) {
    printf("Access denied to port 0x%X\n", 0x80);
    return (1);
  }
  if (ioperm(0x378, 3, 1) < 0) {
    printf("Access denied to port 0x%X (+3)\n", 0x378);
    return (1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<init_port>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x80,%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <ioperm@plt>
cmp    $0x0,%rax
jge    1160 <init_port+0x40>
lea    0xeb6(%rip),%rdi
mov    $0x80,%esi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a2 <init_port+0x82>
mov    $0x378,%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1040 <ioperm@plt>
cmp    $0x0,%rax
jge    119b <init_port+0x7b>
lea    0xe97(%rip),%rdi
mov    $0x378,%esi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a2 <init_port+0x82>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_port>:
push   %rbx
mov    $0x1,%ebx
mov    $0x80,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1040 <ioperm@plt>
test   %rax,%rax
js     1172 <init_port+0x52>
mov    $0x378,%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1040 <ioperm@plt>
xor    %ebx,%ebx
test   %rax,%rax
jns    1183 <init_port+0x63>
lea    0xebb(%rip),%rdi
mov    $0x378,%esi
call   1030 <printf@plt>
mov    $0x1,%ebx
jmp    1183 <init_port+0x63>
lea    0xe87(%rip),%rdi
mov    $0x80,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Access denied to port 0x%X\0A\00"
@.str.1 = [33 x i8] c"Access denied to port 0x%X (+3)\0A\00"
define i32 @init_port() {
%1 = alloca i32
%2 = call i64 @ioperm(i32 128, i32 1, i32 1)
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 128)
store i32 1, i32* %1
br label %12
6: ; preds = %0
%7 = call i64 @ioperm(i32 888, i32 3, i32 1)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 888)
store i32 1, i32* %1
br label %12
11: ; preds = %6
store i32 0, i32* %1
br label %12
12: ; preds = %11, %9, %4
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
@.str = [28 x i8] c"Access denied to port 0x%X\0A\00"
@.str.1 = [33 x i8] c"Access denied to port 0x%X (+3)\0A\00"
define i32 @init_port() {
%1 = tail call i64 @ioperm(i32 128, i32 1, i32 1)
%2 = icmp slt i64 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 128)
br label %10
5: ; preds = %0
%6 = tail call i64 @ioperm(i32 888, i32 3, i32 1)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 888)
br label %10
10: ; preds = %5, %8, %3
%11 = phi i32 [ 1, %3 ], [ 1, %8 ], [ 0, %5 ]
ret i32 %11
}