#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*/ assert(int);
unsigned char keyboard_get_keyport(int);
void check_keyports(unsigned char *expected_keyports) {
  int i;
  for (i = 0; i < 8; i++) {
    assert(keyboard_get_keyport(i) == expected_keyports[i]);
  }
}


x86 assembly (clang, -O0):
<check_keyports>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    1171 <check_keyports+0x51>
mov    -0xc(%rbp),%edi
call   1040 <keyboard_get_keyport@plt>
movzbl %al,%eax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <check_keyports+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_keyports>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
call   1040 <keyboard_get_keyport@plt>
xor    %edi,%edi
cmp    (%rbx),%al
sete   %dil
call   1030 <assert@plt>
mov    $0x1,%edi
call   1040 <keyboard_get_keyport@plt>
xor    %edi,%edi
cmp    0x1(%rbx),%al
sete   %dil
call   1030 <assert@plt>
mov    $0x2,%edi
call   1040 <keyboard_get_keyport@plt>
xor    %edi,%edi
cmp    0x2(%rbx),%al
sete   %dil
call   1030 <assert@plt>
mov    $0x3,%edi
call   1040 <keyboard_get_keyport@plt>
xor    %edi,%edi
cmp    0x3(%rbx),%al
sete   %dil
call   1030 <assert@plt>
mov    $0x4,%edi
call   1040 <keyboard_get_keyport@plt>
xor    %edi,%edi
cmp    0x4(%rbx),%al
sete   %dil
call   1030 <assert@plt>
mov    $0x5,%edi
call   1040 <keyboard_get_keyport@plt>
xor    %edi,%edi
cmp    0x5(%rbx),%al
sete   %dil
call   1030 <assert@plt>
mov    $0x6,%edi
call   1040 <keyboard_get_keyport@plt>
xor    %edi,%edi
cmp    0x6(%rbx),%al
sete   %dil
call   1030 <assert@plt>
mov    $0x7,%edi
call   1040 <keyboard_get_keyport@plt>
xor    %edi,%edi
cmp    0x7(%rbx),%al
sete   %dil
pop    %rbx
jmp    1030 <assert@plt>

LLVM IR (-O0):
define void @check_keyports(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %20, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 8
br i1 %6, label %7, label %23
7: ; preds = %4
%8 = load i32, i32* %3
%9 = call zeroext i8 @keyboard_get_keyport(i32 %8)
%10 = zext i8 %9 to i32
%11 = load i8*, i8** %2
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = icmp eq i32 %10, %16
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
br label %20
20: ; preds = %7
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %4
23: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @check_keyports(i8* nocapture %0) {
%2 = tail call zeroext i8 @keyboard_get_keyport(i32 0)
%3 = load i8, i8* %0
%4 = icmp eq i8 %2, %3
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call zeroext i8 @keyboard_get_keyport(i32 1)
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %7, %9
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call zeroext i8 @keyboard_get_keyport(i32 2)
%14 = getelementptr inbounds i8, i8* %0, i64 2
%15 = load i8, i8* %14
%16 = icmp eq i8 %13, %15
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
%19 = tail call zeroext i8 @keyboard_get_keyport(i32 3)
%20 = getelementptr inbounds i8, i8* %0, i64 3
%21 = load i8, i8* %20
%22 = icmp eq i8 %19, %21
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
%25 = tail call zeroext i8 @keyboard_get_keyport(i32 4)
%26 = getelementptr inbounds i8, i8* %0, i64 4
%27 = load i8, i8* %26
%28 = icmp eq i8 %25, %27
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
%31 = tail call zeroext i8 @keyboard_get_keyport(i32 5)
%32 = getelementptr inbounds i8, i8* %0, i64 5
%33 = load i8, i8* %32
%34 = icmp eq i8 %31, %33
%35 = zext i1 %34 to i32
%36 = tail call i32 @assert(i32 %35)
%37 = tail call zeroext i8 @keyboard_get_keyport(i32 6)
%38 = getelementptr inbounds i8, i8* %0, i64 6
%39 = load i8, i8* %38
%40 = icmp eq i8 %37, %39
%41 = zext i1 %40 to i32
%42 = tail call i32 @assert(i32 %41)
%43 = tail call zeroext i8 @keyboard_get_keyport(i32 7)
%44 = getelementptr inbounds i8, i8* %0, i64 7
%45 = load i8, i8* %44
%46 = icmp eq i8 %43, %45
%47 = zext i1 %46 to i32
%48 = tail call i32 @assert(i32 %47)
ret void
}