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


x86 assembly (clang, -O0):
<doVinb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x4(%rbp)
jne    1209 <doVinb+0x99>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <isNumber@plt>
cmp    $0x0,%rax
je     1209 <doVinb+0x99>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <stringToInt@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <ioperm@plt>
mov    -0x14(%rbp),%edi
call   1060 <inb@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <ioperm@plt>
mov    -0x14(%rbp),%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
call   1070 <printValue@plt>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<doVinb>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1206 <doVinb+0x76>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1070 <isNumber@plt>
test   %rax,%rax
je     1206 <doVinb+0x76>
mov    0x8(%rbx),%rdi
call   10a0 <stringToInt@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1060 <ioperm@plt>
mov    %ebx,%edi
call   1080 <inb@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1060 <ioperm@plt>
lea    0xe1d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
call   1090 <printValue@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xdff(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

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

LLVM IR (-O2):
@.str = [12 x i8] c"vinb 0x%X: \00"
@str = [36 x i8] c"modo de uso: vinb <numero da porta>\00"
define i32 @doVinb(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %18
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 %18, label %9
9: ; preds = %4
%10 = load i8*, i8** %5
%11 = tail call i32 @stringToInt(i8* %10)
%12 = tail call i32 @ioperm(i32 %11, i32 1, i32 1)
%13 = tail call i32 @inb(i32 %11)
%14 = tail call i32 @ioperm(i32 %11, i32 1, i32 0)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %11)
%16 = tail call i32 @printValue(i32 %13)
%17 = tail call i32 @putchar(i32 10)
ret i32 %13
18: ; preds = %4, %2
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%20 = tail call i32 @exit(i32 1)
unreachable
}