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


x86 assembly (clang, -O0):
<doOutb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1223 <doOutb+0xc3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <isNumber@plt>
cmp    $0x0,%rax
je     1223 <doOutb+0xc3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <isNumber@plt>
cmp    $0x0,%rax
je     1223 <doOutb+0xc3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <stringToInt@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <stringToInt@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
call   1070 <printValue@plt>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1050 <ioperm@plt>
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    1238 <doOutb+0xd8>
lea    0xde2(%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):
<doOutb>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x3,%edi
jne    1212 <doOutb+0x92>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1080 <isNumber@plt>
test   %rax,%rax
je     1212 <doOutb+0x92>
mov    0x10(%rbx),%rdi
call   1080 <isNumber@plt>
test   %rax,%rax
je     1212 <doOutb+0x92>
mov    0x8(%rbx),%rdi
call   10a0 <stringToInt@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   10a0 <stringToInt@plt>
mov    %eax,%r14d
lea    0xe36(%rip),%rdi
xor    %ebx,%ebx
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%edi
call   1090 <printValue@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1070 <ioperm@plt>
mov    %r14d,%edi
mov    %ebp,%esi
call   1060 <outb@plt>
mov    %ebp,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1070 <ioperm@plt>
jmp    1223 <doOutb+0xa3>
lea    0xdf3(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [12 x i8] c"outb 0x%X: \00"
@str = [44 x i8] c"modo de uso: outb <numero da porta> <valor>\00"
define i32 @doOutb(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %25
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 %25, 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 %25, 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 ([12 x i8], [12 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 @outb(i32 %18, i32 %16)
%24 = tail call i32 @ioperm(i32 %16, i32 1, i32 0)
br label %27
25: ; preds = %9, %4, %2
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
br label %27
27: ; preds = %25, %14
%28 = phi i32 [ 0, %14 ], [ 1, %25 ]
ret i32 %28
}