#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 inb(int);
int /*<<< orphan*/ ioperm(int, int, int);
scalar_t__ isNumber(char *);
int /*<<< orphan*/ outb(int, int);
int /*<<< orphan*/ printValue(int);
int /*<<< orphan*/ printf(char *, ...);
int stringToInt(char *);
int doXoutb(int argc, char *argv[]) {
  if (argc == 3 && isNumber(argv[1]) && isNumber(argv[2])) {
    int puerto, valor, lectura;
    puerto = stringToInt(argv[1]);
    valor = stringToInt(argv[2]);
    printf("xoutb 0x%X: ", puerto);
    printValue(valor);
    printf("\n");
    ioperm(puerto, 1, 1);
    lectura = inb(puerto);
    valor ^= lectura;
    outb(valor, puerto);
    ioperm(puerto, 1, 0);
    return 0;
  }
  printf("modo de uso: xoutb <numero da porta> <valor>\n");
  return 1;
}


x86 assembly (clang, -O0):
<doXoutb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1247 <doXoutb+0xd7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <isNumber@plt>
cmp    $0x0,%rax
je     1247 <doXoutb+0xd7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <isNumber@plt>
cmp    $0x0,%rax
je     1247 <doXoutb+0xd7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <stringToInt@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <stringToInt@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
call   1080 <printValue@plt>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1050 <ioperm@plt>
mov    -0x14(%rbp),%edi
call   1070 <inb@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
xor    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <outb@plt>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1050 <ioperm@plt>
movl   $0x0,-0x4(%rbp)
jmp    125c <doXoutb+0xec>
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doXoutb>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x3,%edi
jne    122c <doXoutb+0x9c>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1080 <isNumber@plt>
test   %rax,%rax
je     122c <doXoutb+0x9c>
mov    0x10(%rbx),%rdi
call   1080 <isNumber@plt>
test   %rax,%rax
je     122c <doXoutb+0x9c>
mov    0x8(%rbx),%rdi
call   10b0 <stringToInt@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   10b0 <stringToInt@plt>
mov    %eax,%r14d
lea    0xe26(%rip),%rdi
xor    %ebx,%ebx
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%edi
call   10a0 <printValue@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1070 <ioperm@plt>
mov    %ebp,%edi
call   1090 <inb@plt>
xor    %eax,%r14d
mov    %r14d,%edi
mov    %ebp,%esi
call   1060 <outb@plt>
mov    %ebp,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1070 <ioperm@plt>
jmp    123d <doXoutb+0xad>
lea    0xdda(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"xoutb 0x%X: \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [46 x i8] c"modo de uso: xoutb <numero da porta> <valor>\0A\00"
define i32 @doXoutb(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 3
br i1 %10, label %11, label %49
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @isNumber(i8* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %49
17: ; preds = %11
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i64 @isNumber(i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %49
23: ; preds = %17
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @stringToInt(i8* %26)
store i32 %27, i32* %6
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @stringToInt(i8* %30)
store i32 %31, i32* %7
%32 = load i32, i32* %6
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %7
%35 = call i32 @printValue(i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* %6
%38 = call i32 @ioperm(i32 %37, i32 1, i32 1)
%39 = load i32, i32* %6
%40 = call i32 @inb(i32 %39)
store i32 %40, i32* %8
%41 = load i32, i32* %8
%42 = load i32, i32* %7
%43 = xor i32 %42, %41
store i32 %43, i32* %7
%44 = load i32, i32* %7
%45 = load i32, i32* %6
%46 = call i32 @outb(i32 %44, i32 %45)
%47 = load i32, i32* %6
%48 = call i32 @ioperm(i32 %47, i32 1, i32 0)
store i32 0, i32* %3
br label %51
49: ; preds = %17, %11, %2
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %51
51: ; preds = %49, %23
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str = [13 x i8] c"xoutb 0x%X: \00"
@str = [45 x i8] c"modo de uso: xoutb <numero da porta> <valor>\00"
define i32 @doXoutb(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %27
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @isNumber(i8* %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %27, label %9
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i64 @isNumber(i8* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %27, label %14
14: ; preds = %9
%15 = load i8*, i8** %5
%16 = tail call i32 @stringToInt(i8* %15)
%17 = load i8*, i8** %10
%18 = tail call i32 @stringToInt(i8* %17)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %16)
%20 = tail call i32 @printValue(i32 %18)
%21 = tail call i32 @putchar(i32 10)
%22 = tail call i32 @ioperm(i32 %16, i32 1, i32 1)
%23 = tail call i32 @inb(i32 %16)
%24 = xor i32 %23, %18
%25 = tail call i32 @outb(i32 %24, i32 %16)
%26 = tail call i32 @ioperm(i32 %16, i32 1, i32 0)
br label %29
27: ; preds = %9, %4, %2
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
br label %29
29: ; preds = %27, %14
%30 = phi i32 [ 0, %14 ], [ 1, %27 ]
ret i32 %30
}