#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
scalar_t__ strncmp(char *, char *, int);
void kernel(const char *File, int len) {
  FILE *f;
  char Kyo[40];
  if (len > 10 || len < 2)
    return;
  f = fopen(File, "r");
  if (!f) {
    printf("Sorry, I cannot open: %s.\n", File);
    printf("Please check your permissions with\n"
           "your supervisor. The feature may not\n"
           "be compiled and\\or enabled in your\n"
           "kernel version. Or a scsi device, eg,\n"
           "a USB drive may not be attached.\n");
    return;
  } else {
    while (feof(f) != 1) {
      fgets(Kyo, len, f);
      if (strncmp(Kyo, "((", 1) == 0)
        printf("\n-");
      if (strncmp(Kyo, "#", 1) == 0) {
        printf("\nVersion: #");
      } else {
        fprintf(stdout, "%s", Kyo);
      }
      fflush(stdout);
    }
  }
  fclose(f);
}


x86 assembly (clang, -O0):
<kernel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jg     11a3 <kernel+0x23>
cmpl   $0x2,-0xc(%rbp)
jge    11a8 <kernel+0x28>
jmp    12ac <kernel+0x12c>
mov    -0x8(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ec <kernel+0x6c>
mov    -0x8(%rbp),%rsi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12ac <kernel+0x12c>
jmp    11f1 <kernel+0x71>
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x1,%eax
je     129e <kernel+0x11e>
lea    -0x40(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1060 <fgets@plt>
lea    -0x40(%rbp),%rdi
lea    0xeb2(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1240 <kernel+0xc0>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x40(%rbp),%rdi
lea    0xe95(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1272 <kernel+0xf2>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    128b <kernel+0x10b>
mov    0x2d67(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rdx
lea    0xe5c(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
jmp    11f1 <kernel+0x71>
jmp    12a3 <kernel+0x123>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %esi,%r14d
lea    -0xb(%r14),%eax
cmp    $0xfffffff7,%eax
jb     11d6 <kernel+0x46>
mov    %rdi,%rbp
lea    0xe4c(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     11e5 <kernel+0x55>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <feof@plt>
cmp    $0x1,%eax
jne    1210 <kernel+0x80>
mov    %rbx,%rdi
call   1050 <fclose@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe16(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe35(%rip),%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>
mov    %rsp,%r15
lea    0xe03(%rip),%r12
lea    0xe0c(%rip),%rbp
mov    0x2db8(%rip),%r13
jmp    125d <kernel+0xcd>
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
lea    0xdf4(%rip),%rsi
mov    %r15,%rdx
call   1080 <fprintf@plt>
mov    0x0(%r13),%edi
call   10a0 <fflush@plt>
mov    %rbx,%rdi
call   1090 <feof@plt>
cmp    $0x1,%eax
je     11ce <kernel+0x3e>
mov    %r15,%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    128e <kernel+0xfe>
lea    0xd99(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1230 <kernel+0xa0>
lea    0xd79(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1243 <kernel+0xb3>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [27 x i8] c"Sorry, I cannot open: %s.\0A\00"
@.str.2 = [179 x i8] c"Please check your permissions with\0Ayour supervisor. The feature may not\0Abe compiled and\\or enabled in your\0Akernel version. Or a scsi device, eg,\0Aa USB drive may not be attached.\0A\00"
@.str.3 = [3 x i8] c"((\00"
@.str.4 = [3 x i8] c"\0A-\00"
@.str.5 = [2 x i8] c"#\00"
@.str.6 = [12 x i8] c"\0AVersion: #\00"
@stdout = global i32 0
@.str.7 = [3 x i8] c"%s\00"
define void @kernel(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca [40 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 10
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %9, %2
br label %54
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %5
%16 = load i32*, i32** %5
%17 = icmp ne i32* %16, null
br i1 %17, label %22, label %18
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([179 x i8], [179 x i8]* @.str.2, i64 0, i64 0))
br label %54
22: ; preds = %13
br label %23
23: ; preds = %47, %22
%24 = load i32*, i32** %5
%25 = call i32 @feof(i32* %24)
%26 = icmp ne i32 %25, 1
br i1 %26, label %27, label %50
27: ; preds = %23
%28 = getelementptr inbounds [40 x i8], [40 x i8]* %6, i64 0, i64 0
%29 = load i32, i32* %4
%30 = load i32*, i32** %5
%31 = call i32 @fgets(i8* %28, i32 %29, i32* %30)
%32 = getelementptr inbounds [40 x i8], [40 x i8]* %6, i64 0, i64 0
%33 = call i64 @strncmp(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 1)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %27
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %37
37: ; preds = %35, %27
%38 = getelementptr inbounds [40 x i8], [40 x i8]* %6, i64 0, i64 0
%39 = call i64 @strncmp(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %47
43: ; preds = %37
%44 = load i32, i32* @stdout
%45 = getelementptr inbounds [40 x i8], [40 x i8]* %6, i64 0, i64 0
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %43, %41
%48 = load i32, i32* @stdout
%49 = call i32 @fflush(i32 %48)
br label %23
50: ; preds = %23
br label %51
51: ; preds = %50
%52 = load i32*, i32** %5
%53 = call i32 @fclose(i32* %52)
br label %54
54: ; preds = %51, %18, %12
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [27 x i8] c"Sorry, I cannot open: %s.\0A\00"
@.str.3 = [3 x i8] c"((\00"
@.str.4 = [3 x i8] c"\0A-\00"
@.str.5 = [2 x i8] c"#\00"
@.str.6 = [12 x i8] c"\0AVersion: #\00"
@stdout = global i32 0
@.str.7 = [3 x i8] c"%s\00"
@str = [178 x i8] c"Please check your permissions with\0Ayour supervisor. The feature may not\0Abe compiled and\\or enabled in your\0Akernel version. Or a scsi device, eg,\0Aa USB drive may not be attached.\00"
define void @kernel(i8* %0, i32 %1) {
%3 = alloca [40 x i8]
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%5 = add i32 %1, -11
%6 = icmp ult i32 %5, -9
br i1 %6, label %37, label %7
7: ; preds = %2
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = call i32 @feof(i32* %8)
%12 = icmp eq i32 %11, 1
br i1 %12, label %35, label %16
13: ; preds = %7
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([178 x i8], [178 x i8]* @str, i64 0, i64 0))
br label %37
16: ; preds = %10, %30
%17 = call i32 @fgets(i8* %4, i32 %1, i32* %8)
%18 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 1)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %30
27: ; preds = %22
%28 = load i32, i32* @stdout
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %4)
br label %30
30: ; preds = %27, %25
%31 = load i32, i32* @stdout
%32 = call i32 @fflush(i32 %31)
%33 = call i32 @feof(i32* %8)
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %16
35: ; preds = %30, %10
%36 = call i32 @fclose(i32* %8)
br label %37
37: ; preds = %2, %35, %13
ret void
}