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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ ioctl(int, unsigned long, char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sscanf(char *, char *, unsigned long *);
char *strstr(char *, char *);
int main() {
  FILE *fp_proc, *fp_dev;
  char buffer[1024], output[30];
  size_t bytes_read;
  char *match;
  int i;
  unsigned long ioctlcmd;
  fp_proc = fopen("/proc/information", "r");
  if (!fp_proc) {
    printf("/proc/information is not available\n");
    return 0;
  }
  bytes_read = fread(buffer, 1, sizeof(buffer), fp_proc);
  fclose(fp_proc);
  if (bytes_read == 0 || bytes_read == sizeof(buffer)) {
    printf("Some unexpected error in read process\n");
    return 0;
  }
  printf("--------   Procfs-IOCTL System Information   --------\n");
  printf("Enter a Number Between 1 to 6:\n");
  printf("1:SysName\t2:NodeName\n3:Release\t4:Version\n5:Machine\t6:"
         "DomainName\n\n");
  printf("Your Choice: ");
  scanf("%d", &i);
  printf("-----------------------------------------------------\n");
  switch (i) {
  case 1:
    match = strstr(buffer, "IOCTL_SYSNAME");
    if (!match) {
      printf("IOCTL_SYSNAME has not found\n");
      return 0;
    }
    sscanf(match, "IOCTL_SYSNAME, %lu", &ioctlcmd);
    break;
  case 2:
    match = strstr(buffer, "IOCTL_NODENAME");
    if (!match) {
      printf("IOCTL_NODENAME has not found\n");
      return 0;
    }
    sscanf(match, "IOCTL_NODENAME, %lu", &ioctlcmd);
    break;
  case 3:
    match = strstr(buffer, "IOCTL_RELEASE");
    if (!match) {
      printf("IOCTL_RELEASE has not found\n");
      return 0;
    }
    sscanf(match, "IOCTL_RELEASE, %lu", &ioctlcmd);
    break;
  case 4:
    match = strstr(buffer, "IOCTL_VERSION");
    if (!match) {
      printf("IOCTL_VERSION has not found\n");
      return 0;
    }
    sscanf(match, "IOCTL_VERSION, %lu", &ioctlcmd);
    break;
  case 5:
    match = strstr(buffer, "IOCTL_MACHINE");
    if (!match) {
      printf("IOCTL_MACHINE has not found\n");
      return 0;
    }
    sscanf(match, "IOCTL_MACHINE, %lu", &ioctlcmd);
    break;
  case 6:
    match = strstr(buffer, "IOCTL_DOMAINNAME");
    if (!match) {
      printf("IOCTL_DOMAINNAME has not found\n");
      return 0;
    }
    sscanf(match, "IOCTL_DOMAINNAME, %lu", &ioctlcmd);
    break;
  default:
    printf("Invalid Command\n");
    return -1;
  }
  int fd = open("/proc/information", O_RDONLY);
  ioctl(fd, ioctlcmd, output);
  close(fd);
  printf("Output: %s\n", output);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x480,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe5f(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ee <main+0x4e>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15ad <main+0x40d>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %rax,-0x448(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
cmpq   $0x0,-0x448(%rbp)
je     1237 <main+0x97>
cmpq   $0x400,-0x448(%rbp)
jne    1251 <main+0xb1>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15ad <main+0x40d>
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x471(%rbp)
call   1050 <printf@plt>
mov    -0x471(%rbp),%al
lea    0xe3c(%rip),%rdi
call   1050 <printf@plt>
mov    -0x471(%rbp),%al
lea    0xe4a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x471(%rbp),%al
lea    0xe7a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    -0x454(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x471(%rbp),%al
lea    0xe66(%rip),%rdi
call   1050 <printf@plt>
mov    -0x454(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x470(%rbp)
sub    $0x5,%eax
ja     1538 <main+0x398>
mov    -0x470(%rbp),%rax
lea    0xd17(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x420(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   10c0 <strstr@plt>
mov    %rax,-0x450(%rbp)
cmpq   $0x0,-0x450(%rbp)
jne    1334 <main+0x194>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15ad <main+0x40d>
mov    -0x450(%rbp),%rdi
lea    0xe41(%rip),%rsi
lea    -0x460(%rbp),%rdx
call   1080 <sscanf@plt>
jmp    1552 <main+0x3b2>
lea    -0x420(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   10c0 <strstr@plt>
mov    %rax,-0x450(%rbp)
cmpq   $0x0,-0x450(%rbp)
jne    1395 <main+0x1f5>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15ad <main+0x40d>
mov    -0x450(%rbp),%rdi
lea    0xe20(%rip),%rsi
lea    -0x460(%rbp),%rdx
call   1080 <sscanf@plt>
jmp    1552 <main+0x3b2>
lea    -0x420(%rbp),%rdi
lea    0xe15(%rip),%rsi
call   10c0 <strstr@plt>
mov    %rax,-0x450(%rbp)
cmpq   $0x0,-0x450(%rbp)
jne    13f6 <main+0x256>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15ad <main+0x40d>
mov    -0x450(%rbp),%rdi
lea    0xdfe(%rip),%rsi
lea    -0x460(%rbp),%rdx
call   1080 <sscanf@plt>
jmp    1552 <main+0x3b2>
lea    -0x420(%rbp),%rdi
lea    0xdf2(%rip),%rsi
call   10c0 <strstr@plt>
mov    %rax,-0x450(%rbp)
cmpq   $0x0,-0x450(%rbp)
jne    1457 <main+0x2b7>
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15ad <main+0x40d>
mov    -0x450(%rbp),%rdi
lea    0xddb(%rip),%rsi
lea    -0x460(%rbp),%rdx
call   1080 <sscanf@plt>
jmp    1552 <main+0x3b2>
lea    -0x420(%rbp),%rdi
lea    0xdcf(%rip),%rsi
call   10c0 <strstr@plt>
mov    %rax,-0x450(%rbp)
cmpq   $0x0,-0x450(%rbp)
jne    14b8 <main+0x318>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15ad <main+0x40d>
mov    -0x450(%rbp),%rdi
lea    0xdb8(%rip),%rsi
lea    -0x460(%rbp),%rdx
call   1080 <sscanf@plt>
jmp    1552 <main+0x3b2>
lea    -0x420(%rbp),%rdi
lea    0xdac(%rip),%rsi
call   10c0 <strstr@plt>
mov    %rax,-0x450(%rbp)
cmpq   $0x0,-0x450(%rbp)
jne    1519 <main+0x379>
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    15ad <main+0x40d>
mov    -0x450(%rbp),%rdi
lea    0xd9b(%rip),%rsi
lea    -0x460(%rbp),%rdx
call   1080 <sscanf@plt>
jmp    1552 <main+0x3b2>
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15ad <main+0x40d>
mov    0x2a8f(%rip),%rax
mov    (%rax),%esi
lea    0xab6(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,-0x464(%rbp)
mov    -0x464(%rbp),%edi
mov    -0x460(%rbp),%rsi
lea    -0x440(%rbp),%rdx
call   1060 <ioctl@plt>
mov    -0x464(%rbp),%edi
call   1070 <close@plt>
lea    -0x440(%rbp),%rsi
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x480,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x438,%rsp
lea    0xe57(%rip),%rdi
lea    0xe62(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1299 <main+0xe9>
mov    %rax,%rbx
lea    0x30(%rsp),%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <fclose@plt>
test   $0xfffffffffffffbff,%r14
je     12a2 <main+0xf2>
lea    0xf2b(%rip),%rdi
call   1030 <puts@plt>
lea    0xf55(%rip),%rdi
call   1030 <puts@plt>
lea    0xf68(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf9(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdf9(%rip),%rdi
lea    0xc(%rsp),%rsi
call   10a0 <scanf@plt>
lea    0xf7e(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x5,%eax
ja     12b5 <main+0x105>
lea    0xd96(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xdc3(%rip),%rsi
lea    0x30(%rsp),%rdi
call   10d0 <strstr@plt>
test   %rax,%rax
je     13d7 <main+0x227>
lea    0xdb7(%rip),%rsi
jmp    137b <main+0x1cb>
lea    0xe77(%rip),%rdi
jmp    12a9 <main+0xf9>
lea    0x1019(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    13ca <main+0x21a>
lea    0xff6(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
jmp    13ca <main+0x21a>
lea    0xd8c(%rip),%rsi
lea    0x30(%rsp),%rdi
call   10d0 <strstr@plt>
test   %rax,%rax
je     13e3 <main+0x233>
lea    0xd81(%rip),%rsi
jmp    137b <main+0x1cb>
lea    0xd89(%rip),%rsi
lea    0x30(%rsp),%rdi
call   10d0 <strstr@plt>
test   %rax,%rax
je     13ef <main+0x23f>
lea    0xd7d(%rip),%rsi
jmp    137b <main+0x1cb>
lea    0xd87(%rip),%rsi
lea    0x30(%rsp),%rdi
call   10d0 <strstr@plt>
test   %rax,%rax
je     13fb <main+0x24b>
lea    0xd7b(%rip),%rsi
jmp    137b <main+0x1cb>
lea    0xd85(%rip),%rsi
lea    0x30(%rsp),%rdi
call   10d0 <strstr@plt>
test   %rax,%rax
je     1407 <main+0x257>
lea    0xd79(%rip),%rsi
jmp    137b <main+0x1cb>
lea    0xd83(%rip),%rsi
lea    0x30(%rsp),%rdi
call   10d0 <strstr@plt>
test   %rax,%rax
je     1413 <main+0x263>
lea    0xd7a(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1090 <sscanf@plt>
mov    0x2c5b(%rip),%rax
mov    (%rax),%esi
lea    0xc82(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,%ebx
mov    (%rsp),%rsi
lea    0x10(%rsp),%r14
mov    %eax,%edi
mov    %r14,%rdx
call   1070 <ioctl@plt>
mov    %ebx,%edi
call   1080 <close@plt>
lea    0xd4d(%rip),%rdi
xor    %ebx,%ebx
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%eax
add    $0x438,%rsp
pop    %rbx
pop    %r14
ret
lea    0xeb8(%rip),%rdi
jmp    12a9 <main+0xf9>
lea    0xe8f(%rip),%rdi
jmp    12a9 <main+0xf9>
lea    0xe67(%rip),%rdi
jmp    12a9 <main+0xf9>
lea    0xe3f(%rip),%rdi
jmp    12a9 <main+0xf9>
lea    0xe17(%rip),%rdi
jmp    12a9 <main+0xf9>
lea    0xdec(%rip),%rdi
jmp    12a9 <main+0xf9>

LLVM IR (-O0):
@.str = [18 x i8] c"/proc/information\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [36 x i8] c"/proc/information is not available\0A\00"
@.str.3 = [39 x i8] c"Some unexpected error in read process\0A\00"
@.str.4 = [55 x i8] c"-------- Procfs-IOCTL System Information --------\0A\00"
@.str.5 = [32 x i8] c"Enter a Number Between 1 to 6:\0A\00"
@.str.6 = [66 x i8] c"1:SysName\092:NodeName\0A3:Release\094:Version\0A5:Machine\096:DomainName\0A\0A\00"
@.str.7 = [14 x i8] c"Your Choice: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [55 x i8] c"-----------------------------------------------------\0A\00"
@.str.10 = [14 x i8] c"IOCTL_SYSNAME\00"
@.str.11 = [29 x i8] c"IOCTL_SYSNAME has not found\0A\00"
@.str.12 = [19 x i8] c"IOCTL_SYSNAME, %lu\00"
@.str.13 = [15 x i8] c"IOCTL_NODENAME\00"
@.str.14 = [30 x i8] c"IOCTL_NODENAME has not found\0A\00"
@.str.15 = [20 x i8] c"IOCTL_NODENAME, %lu\00"
@.str.16 = [14 x i8] c"IOCTL_RELEASE\00"
@.str.17 = [29 x i8] c"IOCTL_RELEASE has not found\0A\00"
@.str.18 = [19 x i8] c"IOCTL_RELEASE, %lu\00"
@.str.19 = [14 x i8] c"IOCTL_VERSION\00"
@.str.20 = [29 x i8] c"IOCTL_VERSION has not found\0A\00"
@.str.21 = [19 x i8] c"IOCTL_VERSION, %lu\00"
@.str.22 = [14 x i8] c"IOCTL_MACHINE\00"
@.str.23 = [29 x i8] c"IOCTL_MACHINE has not found\0A\00"
@.str.24 = [19 x i8] c"IOCTL_MACHINE, %lu\00"
@.str.25 = [17 x i8] c"IOCTL_DOMAINNAME\00"
@.str.26 = [32 x i8] c"IOCTL_DOMAINNAME has not found\0A\00"
@.str.27 = [22 x i8] c"IOCTL_DOMAINNAME, %lu\00"
@.str.28 = [17 x i8] c"Invalid Command\0A\00"
@O_RDONLY = global i32 0
@.str.29 = [12 x i8] c"Output: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [1024 x i8]
%5 = alloca [30 x i8]
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
store i32 0, i32* %1
%11 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %2
%12 = load i32*, i32** %2
%13 = icmp ne i32* %12, null
br i1 %13, label %16, label %14
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %110
16: ; preds = %0
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%18 = load i32*, i32** %2
%19 = call i64 @fread(i8* %17, i32 1, i32 1024, i32* %18)
store i64 %19, i64* %6
%20 = load i32*, i32** %2
%21 = call i32 @fclose(i32* %20)
%22 = load i64, i64* %6
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %16
%25 = load i64, i64* %6
%26 = icmp eq i64 %25, 1024
br i1 %26, label %27, label %29
27: ; preds = %24, %16
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %110
29: ; preds = %24
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.6, i64 0, i64 0))
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %8)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.9, i64 0, i64 0))
%36 = load i32, i32* %8
switch i32 %36, label %97 [
i32 1, label %37
i32 2, label %47
i32 3, label %57
i32 4, label %67
i32 5, label %77
i32 6, label %87
]
37: ; preds = %29
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%39 = call i8* @strstr(i8* %38, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
store i8* %39, i8** %7
%40 = load i8*, i8** %7
%41 = icmp ne i8* %40, null
br i1 %41, label %44, label %42
42: ; preds = %37
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %1
br label %110
44: ; preds = %37
%45 = load i8*, i8** %7
%46 = call i32 @sscanf(i8* %45, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i64* %9)
br label %99
47: ; preds = %29
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%49 = call i8* @strstr(i8* %48, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0))
store i8* %49, i8** %7
%50 = load i8*, i8** %7
%51 = icmp ne i8* %50, null
br i1 %51, label %54, label %52
52: ; preds = %47
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.14, i64 0, i64 0))
store i32 0, i32* %1
br label %110
54: ; preds = %47
%55 = load i8*, i8** %7
%56 = call i32 @sscanf(i8* %55, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0), i64* %9)
br label %99
57: ; preds = %29
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%59 = call i8* @strstr(i8* %58, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0))
store i8* %59, i8** %7
%60 = load i8*, i8** %7
%61 = icmp ne i8* %60, null
br i1 %61, label %64, label %62
62: ; preds = %57
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.17, i64 0, i64 0))
store i32 0, i32* %1
br label %110
64: ; preds = %57
%65 = load i8*, i8** %7
%66 = call i32 @sscanf(i8* %65, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0), i64* %9)
br label %99
67: ; preds = %29
%68 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%69 = call i8* @strstr(i8* %68, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.19, i64 0, i64 0))
store i8* %69, i8** %7
%70 = load i8*, i8** %7
%71 = icmp ne i8* %70, null
br i1 %71, label %74, label %72
72: ; preds = %67
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.20, i64 0, i64 0))
store i32 0, i32* %1
br label %110
74: ; preds = %67
%75 = load i8*, i8** %7
%76 = call i32 @sscanf(i8* %75, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.21, i64 0, i64 0), i64* %9)
br label %99
77: ; preds = %29
%78 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%79 = call i8* @strstr(i8* %78, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.22, i64 0, i64 0))
store i8* %79, i8** %7
%80 = load i8*, i8** %7
%81 = icmp ne i8* %80, null
br i1 %81, label %84, label %82
82: ; preds = %77
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.23, i64 0, i64 0))
store i32 0, i32* %1
br label %110
84: ; preds = %77
%85 = load i8*, i8** %7
%86 = call i32 @sscanf(i8* %85, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.24, i64 0, i64 0), i64* %9)
br label %99
87: ; preds = %29
%88 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%89 = call i8* @strstr(i8* %88, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.25, i64 0, i64 0))
store i8* %89, i8** %7
%90 = load i8*, i8** %7
%91 = icmp ne i8* %90, null
br i1 %91, label %94, label %92
92: ; preds = %87
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.26, i64 0, i64 0))
store i32 0, i32* %1
br label %110
94: ; preds = %87
%95 = load i8*, i8** %7
%96 = call i32 @sscanf(i8* %95, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.27, i64 0, i64 0), i64* %9)
br label %99
97: ; preds = %29
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.28, i64 0, i64 0))
store i32 -1, i32* %1
br label %110
99: ; preds = %94, %84, %74, %64, %54, %44
%100 = load i32, i32* @O_RDONLY
%101 = call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %100)
store i32 %101, i32* %10
%102 = load i32, i32* %10
%103 = load i64, i64* %9
%104 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%105 = call i32 @ioctl(i32 %102, i64 %103, i8* %104)
%106 = load i32, i32* %10
%107 = call i32 @close(i32 %106)
%108 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.29, i64 0, i64 0), i8* %108)
store i32 0, i32* %1
br label %110
110: ; preds = %99, %97, %92, %82, %72, %62, %52, %42, %27, %14
%111 = load i32, i32* %1
ret i32 %111
}

LLVM IR (-O2):
@.str = [18 x i8] c"/proc/information\00"
@.str.1 = [2 x i8] c"r\00"
@.str.7 = [14 x i8] c"Your Choice: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.10 = [14 x i8] c"IOCTL_SYSNAME\00"
@.str.12 = [19 x i8] c"IOCTL_SYSNAME, %lu\00"
@.str.13 = [15 x i8] c"IOCTL_NODENAME\00"
@.str.15 = [20 x i8] c"IOCTL_NODENAME, %lu\00"
@.str.16 = [14 x i8] c"IOCTL_RELEASE\00"
@.str.18 = [19 x i8] c"IOCTL_RELEASE, %lu\00"
@.str.19 = [14 x i8] c"IOCTL_VERSION\00"
@.str.21 = [19 x i8] c"IOCTL_VERSION, %lu\00"
@.str.22 = [14 x i8] c"IOCTL_MACHINE\00"
@.str.24 = [19 x i8] c"IOCTL_MACHINE, %lu\00"
@.str.25 = [17 x i8] c"IOCTL_DOMAINNAME\00"
@.str.27 = [22 x i8] c"IOCTL_DOMAINNAME, %lu\00"
@O_RDONLY = global i32 0
@.str.29 = [12 x i8] c"Output: %s\0A\00"
@str = [35 x i8] c"/proc/information is not available\00"
@str.30 = [54 x i8] c"-------- Procfs-IOCTL System Information --------\00"
@str.31 = [31 x i8] c"Enter a Number Between 1 to 6:\00"
@str.32 = [65 x i8] c"1:SysName\092:NodeName\0A3:Release\094:Version\0A5:Machine\096:DomainName\0A\00"
@str.33 = [54 x i8] c"-----------------------------------------------------\00"
@str.34 = [31 x i8] c"IOCTL_DOMAINNAME has not found\00"
@str.35 = [28 x i8] c"IOCTL_MACHINE has not found\00"
@str.36 = [28 x i8] c"IOCTL_VERSION has not found\00"
@str.37 = [28 x i8] c"IOCTL_RELEASE has not found\00"
@str.38 = [29 x i8] c"IOCTL_NODENAME has not found\00"
@str.39 = [28 x i8] c"IOCTL_SYSNAME has not found\00"
@str.40 = [16 x i8] c"Invalid Command\00"
@str.41 = [38 x i8] c"Some unexpected error in read process\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [30 x i8]
%3 = alloca i32
%4 = alloca i64
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%7 = bitcast i32* %3 to i8*
%8 = bitcast i64* %4 to i8*
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %79
13: ; preds = %0
%14 = call i64 @fread(i8* %5, i32 1, i32 1024, i32* %9)
%15 = tail call i32 @fclose(i32* %9)
%16 = and i64 %14, -1025
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.41, i64 0, i64 0))
br label %79
20: ; preds = %13
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.30, i64 0, i64 0))
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.31, i64 0, i64 0))
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str.32, i64 0, i64 0))
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %3)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.33, i64 0, i64 0))
%27 = load i32, i32* %3
switch i32 %27, label %70 [
i32 1, label %28
i32 2, label %35
i32 3, label %42
i32 4, label %49
i32 5, label %56
i32 6, label %63
]
28: ; preds = %20
%29 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.39, i64 0, i64 0))
br label %79
33: ; preds = %28
%34 = call i32 @sscanf(i8* %29, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i64* %4)
br label %72
35: ; preds = %20
%36 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0))
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.38, i64 0, i64 0))
br label %79
40: ; preds = %35
%41 = call i32 @sscanf(i8* %36, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0), i64* %4)
br label %72
42: ; preds = %20
%43 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0))
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.37, i64 0, i64 0))
br label %79
47: ; preds = %42
%48 = call i32 @sscanf(i8* %43, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0), i64* %4)
br label %72
49: ; preds = %20
%50 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.19, i64 0, i64 0))
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.36, i64 0, i64 0))
br label %79
54: ; preds = %49
%55 = call i32 @sscanf(i8* %50, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.21, i64 0, i64 0), i64* %4)
br label %72
56: ; preds = %20
%57 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.22, i64 0, i64 0))
%58 = icmp eq i8* %57, null
br i1 %58, label %59, label %61
59: ; preds = %56
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.35, i64 0, i64 0))
br label %79
61: ; preds = %56
%62 = call i32 @sscanf(i8* %57, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.24, i64 0, i64 0), i64* %4)
br label %72
63: ; preds = %20
%64 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.25, i64 0, i64 0))
%65 = icmp eq i8* %64, null
br i1 %65, label %66, label %68
66: ; preds = %63
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.34, i64 0, i64 0))
br label %79
68: ; preds = %63
%69 = call i32 @sscanf(i8* %64, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.27, i64 0, i64 0), i64* %4)
br label %72
70: ; preds = %20
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.40, i64 0, i64 0))
br label %79
72: ; preds = %68, %61, %54, %47, %40, %33
%73 = load i32, i32* @O_RDONLY
%74 = call i32 @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %73)
%75 = load i64, i64* %4
%76 = call i32 @ioctl(i32 %74, i64 %75, i8* %6)
%77 = call i32 @close(i32 %74)
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.29, i64 0, i64 0), i8* %6)
br label %79
79: ; preds = %72, %70, %66, %59, %52, %45, %38, %31, %18, %11
%80 = phi i32 [ 0, %18 ], [ -1, %70 ], [ 0, %72 ], [ 0, %66 ], [ 0, %59 ], [ 0, %52 ], [ 0, %45 ], [ 0, %38 ], [ 0, %31 ], [ 0, %11 ]
ret i32 %80
}