#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int ioperm(int, int, int);
int /*<<< orphan*/ outb(unsigned char, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int i;
  int portstatus = 0;
  int vByte;
  unsigned char dados;
  vByte = atoi(argv[1]);
  dados = (unsigned char)vByte;
  printf("\nValor a ser enviado Byte:%d", dados, "\n");
  portstatus = ioperm(0x378, 3, 1);
  printf("\nestado da porta:%d", portstatus, "\n");
  printf("\n");
  if (ioperm(0x378, 3, 1) == 1) {
    printf("Erro de E/S");
    exit(1);
  }
  outb(dados, 0x378);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,-0x1d(%rbp)
movzbl -0x1d(%rbp),%esi
lea    0xe72(%rip),%rdi
lea    0xe88(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x378,%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1050 <ioperm@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe62(%rip),%rdi
lea    0xe59(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x378,%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1050 <ioperm@plt>
cmp    $0x1,%eax
jne    120e <main+0xbe>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    $0x378,%esi
movzbl -0x1d(%rbp),%edi
call   1040 <outb@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
movzbl %bl,%esi
lea    0xe87(%rip),%rdi
lea    0xe9d(%rip),%r14
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x378,%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1060 <ioperm@plt>
lea    0xe7a(%rip),%rdi
mov    %eax,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x378,%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1060 <ioperm@plt>
cmp    $0x1,%eax
je     11eb <main+0x8b>
movzbl %bl,%edi
mov    $0x378,%esi
call   1050 <outb@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe41(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"\0AValor a ser enviado Byte:%d\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [20 x i8] c"\0Aestado da porta:%d\00"
@.str.3 = [12 x i8] c"Erro de E/S\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = trunc i32 %14 to i8
store i8 %15, i8* %9
%16 = load i8, i8* %9
%17 = zext i8 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @ioperm(i32 888, i32 3, i32 1)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @ioperm(i32 888, i32 3, i32 1)
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %28
25: ; preds = %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %2
%29 = load i8, i8* %9
%30 = call i32 @outb(i8 zeroext %29, i32 888)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"\0AValor a ser enviado Byte:%d\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [20 x i8] c"\0Aestado da porta:%d\00"
@.str.3 = [12 x i8] c"Erro de E/S\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = and i32 %5, 255
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @ioperm(i32 888, i32 3, i32 1)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @putchar(i32 10)
%11 = tail call i32 @ioperm(i32 888, i32 3, i32 1)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = trunc i32 %5 to i8
%18 = tail call i32 @outb(i8 zeroext %17, i32 888)
ret i32 0
}