#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*/ O_RDWR;
int /*<<< orphan*/ ioctl(int, int, unsigned int *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ print_usage(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
unsigned int strtoul(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  unsigned int i;
  int fd;
  unsigned int buf[2];
  unsigned int num;
  if ((argc != 3) && (argc != 4)) {
    print_usage(argv[0]);
    return -1;
  }
  fd = open("/dev/ker_rw", O_RDWR);
  if (fd < 0) {
    printf("can't open file !\n");
    return -2;
  }
  buf[0] = strtoul(argv[2], NULL, 0);
  if (argc == 4) {
    buf[1] = strtoul(argv[3], NULL, 0);
    num = buf[1];
  } else {
    num = 1;
  }
  if (strcmp(argv[1], "r8") == 0) {
    for (i = 0; i < num; i++) {
      ioctl(fd, 0, buf);
      printf("%02d. [%08x] = %02x \n", i, buf[0], (unsigned char)buf[1]);
      buf[0] += 1;
    }
  } else if (strcmp(argv[1], "r16") == 0) {
    for (i = 0; i < num; i++) {
      ioctl(fd, 1, buf);
      printf("%02d. [%08x] = %02x \n", i, buf[0], (unsigned short)buf[1]);
      buf[0] += 2;
    }
  } else if (strcmp(argv[1], "r32") == 0) {
    for (i = 0; i < num; i++) {
      ioctl(fd, 2, buf);
      printf("%02d. [%08x] = %02x \n", i, buf[0], (unsigned int)buf[1]);
      buf[0] += 4;
    }
  } else if ((strcmp(argv[1], "w8") == 0) && (argv[3] != NULL)) {
    ioctl(fd, 3, buf);
  } else if ((strcmp(argv[1], "w16") == 0) && (argv[3] != NULL)) {
    ioctl(fd, 4, buf);
  } else if ((strcmp(argv[1], "w32") == 0) && (argv[3] != NULL)) {
    ioctl(fd, 5, buf);
  } else {
    print_usage("/dev/ker_rw");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11a2 <main+0x42>
cmpl   $0x4,-0x8(%rbp)
je     11a2 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <print_usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1489 <main+0x329>
mov    0x2e3f(%rip),%rax
mov    (%rax),%esi
lea    0xe4e(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11de <main+0x7e>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1489 <main+0x329>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <strtoul@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    121f <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <strtoul@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1226 <main+0xc6>
movl   $0x1,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdea(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    129b <main+0x13b>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jae    1296 <main+0x136>
mov    -0x18(%rbp),%edi
lea    -0x20(%rbp),%rdx
xor    %esi,%esi
call   1040 <ioctl@plt>
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%eax
movzbl %al,%ecx
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    124b <main+0xeb>
jmp    1482 <main+0x322>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd8e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1313 <main+0x1b3>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jae    130e <main+0x1ae>
mov    -0x18(%rbp),%edi
lea    -0x20(%rbp),%rdx
mov    $0x1,%esi
call   1040 <ioctl@plt>
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%eax
movzwl %ax,%ecx
lea    0xd32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12c0 <main+0x160>
jmp    147d <main+0x31d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd1a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1388 <main+0x228>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jae    1383 <main+0x223>
mov    -0x18(%rbp),%edi
lea    -0x20(%rbp),%rdx
mov    $0x2,%esi
call   1040 <ioctl@plt>
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xcbd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1338 <main+0x1d8>
jmp    1478 <main+0x318>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xca9(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    13cb <main+0x26b>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     13cb <main+0x26b>
mov    -0x18(%rbp),%edi
lea    -0x20(%rbp),%rdx
mov    $0x3,%esi
call   1040 <ioctl@plt>
jmp    1473 <main+0x313>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xc69(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    140e <main+0x2ae>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     140e <main+0x2ae>
mov    -0x18(%rbp),%edi
lea    -0x20(%rbp),%rdx
mov    $0x4,%esi
call   1040 <ioctl@plt>
jmp    146e <main+0x30e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xc2a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1451 <main+0x2f1>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     1451 <main+0x2f1>
mov    -0x18(%rbp),%edi
lea    -0x20(%rbp),%rdx
mov    $0x5,%esi
call   1040 <ioctl@plt>
jmp    1469 <main+0x309>
lea    0xba8(%rip),%rdi
call   1080 <print_usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1489 <main+0x329>
jmp    146e <main+0x30e>
jmp    1473 <main+0x313>
jmp    1478 <main+0x318>
jmp    147d <main+0x31d>
jmp    1482 <main+0x322>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
lea    -0x5(%rbx),%eax
cmp    $0xfffffffd,%eax
ja     119b <main+0x2b>
mov    (%r14),%rdi
call   1090 <print_usage@plt>
mov    $0xffffffff,%r14d
jmp    13de <main+0x26e>
mov    0x2e46(%rip),%rax
mov    (%rax),%esi
lea    0xe55(%rip),%rdi
call   1070 <open@plt>
test   %eax,%eax
js     128a <main+0x11a>
mov    %eax,%r15d
mov    0x10(%r14),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <strtoul@plt>
mov    %eax,(%rsp)
mov    $0x1,%ebp
cmp    $0x4,%ebx
jne    11e8 <main+0x78>
mov    0x18(%r14),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <strtoul@plt>
mov    %eax,%ebp
mov    %eax,0x4(%rsp)
mov    0x8(%r14),%rdi
lea    0xe19(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12a1 <main+0x131>
mov    0x8(%r14),%rdi
lea    0xe19(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12f1 <main+0x181>
mov    0x8(%r14),%rdi
lea    0xe04(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1344 <main+0x1d4>
mov    0x8(%r14),%rdi
lea    0xdef(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1390 <main+0x220>
mov    0x8(%r14),%rdi
lea    0xdd9(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     13a8 <main+0x238>
mov    0x8(%r14),%rdi
lea    0xdc4(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     13c0 <main+0x250>
lea    0xd7b(%rip),%rdi
jmp    118b <main+0x1b>
lea    0xda7(%rip),%rdi
call   1030 <puts@plt>
mov    $0xfffffffe,%r14d
jmp    13de <main+0x26e>
xor    %r14d,%r14d
test   %ebp,%ebp
je     13de <main+0x26e>
mov    %rsp,%r12
lea    0xd59(%rip),%r13
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
xor    %esi,%esi
mov    %r12,%rdx
call   1050 <ioctl@plt>
mov    (%rsp),%edx
movzbl 0x4(%rsp),%ecx
mov    %r13,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
addl   $0x1,(%rsp)
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    12c0 <main+0x150>
jmp    13de <main+0x26e>
xor    %r14d,%r14d
test   %ebp,%ebp
je     13de <main+0x26e>
mov    %rsp,%r12
lea    0xd09(%rip),%r13
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    $0x1,%esi
mov    %r12,%rdx
call   1050 <ioctl@plt>
mov    (%rsp),%edx
movzwl 0x4(%rsp),%ecx
mov    %r13,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
addl   $0x2,(%rsp)
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1310 <main+0x1a0>
jmp    13de <main+0x26e>
xor    %r14d,%r14d
test   %ebp,%ebp
je     13de <main+0x26e>
mov    %rsp,%r12
lea    0xcb6(%rip),%r13
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    $0x2,%esi
mov    %r12,%rdx
call   1050 <ioctl@plt>
mov    (%rsp),%edx
mov    0x4(%rsp),%ecx
mov    %r13,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
addl   $0x4,(%rsp)
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1360 <main+0x1f0>
jmp    13de <main+0x26e>
cmpq   $0x0,0x18(%r14)
je     124c <main+0xdc>
mov    %rsp,%rdx
mov    %r15d,%edi
mov    $0x3,%esi
jmp    13d6 <main+0x266>
cmpq   $0x0,0x18(%r14)
je     1265 <main+0xf5>
mov    %rsp,%rdx
mov    %r15d,%edi
mov    $0x4,%esi
jmp    13d6 <main+0x266>
cmpq   $0x0,0x18(%r14)
je     127e <main+0x10e>
mov    %rsp,%rdx
mov    %r15d,%edi
mov    $0x5,%esi
call   1050 <ioctl@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"/dev/ker_rw\00"
@O_RDWR = global i32 0
@.str.1 = [19 x i8] c"can't open file !\0A\00"
@.str.2 = [3 x i8] c"r8\00"
@.str.3 = [22 x i8] c"%02d. [%08x] = %02x \0A\00"
@.str.4 = [4 x i8] c"r16\00"
@.str.5 = [4 x i8] c"r32\00"
@.str.6 = [3 x i8] c"w8\00"
@.str.7 = [4 x i8] c"w16\00"
@.str.8 = [4 x i8] c"w32\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 [2 x i32]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %20
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 4
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @print_usage(i8* %18)
store i32 -1, i32* %3
br label %185
20: ; preds = %12, %2
%21 = load i32, i32* @O_RDWR
%22 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %21)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
store i32 -2, i32* %3
br label %185
27: ; preds = %20
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @strtoul(i8* %30, i32* null, i32 0)
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
store i32 %31, i32* %32
%33 = load i32, i32* %4
%34 = icmp eq i32 %33, 4
br i1 %34, label %35, label %43
35: ; preds = %27
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 3
%38 = load i8*, i8** %37
%39 = call i32 @strtoul(i8* %38, i32* null, i32 0)
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
store i32 %39, i32* %40
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%42 = load i32, i32* %41
store i32 %42, i32* %9
br label %44
43: ; preds = %27
store i32 1, i32* %9
br label %44
44: ; preds = %43, %35
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %74
50: ; preds = %44
store i32 0, i32* %6
br label %51
51: ; preds = %70, %50
%52 = load i32, i32* %6
%53 = load i32, i32* %9
%54 = icmp ult i32 %52, %53
br i1 %54, label %55, label %73
55: ; preds = %51
%56 = load i32, i32* %7
%57 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%58 = call i32 @ioctl(i32 %56, i32 0, i32* %57)
%59 = load i32, i32* %6
%60 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%61 = load i32, i32* %60
%62 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%63 = load i32, i32* %62
%64 = trunc i32 %63 to i8
%65 = zext i8 %64 to i32
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %59, i32 %61, i32 %65)
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%68 = load i32, i32* %67
%69 = add i32 %68, 1
store i32 %69, i32* %67
br label %70
70: ; preds = %55
%71 = load i32, i32* %6
%72 = add i32 %71, 1
store i32 %72, i32* %6
br label %51
73: ; preds = %51
br label %184
74: ; preds = %44
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 1
%77 = load i8*, i8** %76
%78 = call i64 @strcmp(i8* %77, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %104
80: ; preds = %74
store i32 0, i32* %6
br label %81
81: ; preds = %100, %80
%82 = load i32, i32* %6
%83 = load i32, i32* %9
%84 = icmp ult i32 %82, %83
br i1 %84, label %85, label %103
85: ; preds = %81
%86 = load i32, i32* %7
%87 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%88 = call i32 @ioctl(i32 %86, i32 1, i32* %87)
%89 = load i32, i32* %6
%90 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%91 = load i32, i32* %90
%92 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%93 = load i32, i32* %92
%94 = trunc i32 %93 to i16
%95 = zext i16 %94 to i32
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %89, i32 %91, i32 %95)
%97 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%98 = load i32, i32* %97
%99 = add i32 %98, 2
store i32 %99, i32* %97
br label %100
100: ; preds = %85
%101 = load i32, i32* %6
%102 = add i32 %101, 1
store i32 %102, i32* %6
br label %81
103: ; preds = %81
br label %183
104: ; preds = %74
%105 = load i8**, i8*** %5
%106 = getelementptr inbounds i8*, i8** %105, i64 1
%107 = load i8*, i8** %106
%108 = call i64 @strcmp(i8* %107, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%109 = icmp eq i64 %108, 0
br i1 %109, label %110, label %132
110: ; preds = %104
store i32 0, i32* %6
br label %111
111: ; preds = %128, %110
%112 = load i32, i32* %6
%113 = load i32, i32* %9
%114 = icmp ult i32 %112, %113
br i1 %114, label %115, label %131
115: ; preds = %111
%116 = load i32, i32* %7
%117 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%118 = call i32 @ioctl(i32 %116, i32 2, i32* %117)
%119 = load i32, i32* %6
%120 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%121 = load i32, i32* %120
%122 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%123 = load i32, i32* %122
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %119, i32 %121, i32 %123)
%125 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%126 = load i32, i32* %125
%127 = add i32 %126, 4
store i32 %127, i32* %125
br label %128
128: ; preds = %115
%129 = load i32, i32* %6
%130 = add i32 %129, 1
store i32 %130, i32* %6
br label %111
131: ; preds = %111
br label %182
132: ; preds = %104
%133 = load i8**, i8*** %5
%134 = getelementptr inbounds i8*, i8** %133, i64 1
%135 = load i8*, i8** %134
%136 = call i64 @strcmp(i8* %135, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%137 = icmp eq i64 %136, 0
br i1 %137, label %138, label %147
138: ; preds = %132
%139 = load i8**, i8*** %5
%140 = getelementptr inbounds i8*, i8** %139, i64 3
%141 = load i8*, i8** %140
%142 = icmp ne i8* %141, null
br i1 %142, label %143, label %147
143: ; preds = %138
%144 = load i32, i32* %7
%145 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%146 = call i32 @ioctl(i32 %144, i32 3, i32* %145)
br label %181
147: ; preds = %138, %132
%148 = load i8**, i8*** %5
%149 = getelementptr inbounds i8*, i8** %148, i64 1
%150 = load i8*, i8** %149
%151 = call i64 @strcmp(i8* %150, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%152 = icmp eq i64 %151, 0
br i1 %152, label %153, label %162
153: ; preds = %147
%154 = load i8**, i8*** %5
%155 = getelementptr inbounds i8*, i8** %154, i64 3
%156 = load i8*, i8** %155
%157 = icmp ne i8* %156, null
br i1 %157, label %158, label %162
158: ; preds = %153
%159 = load i32, i32* %7
%160 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%161 = call i32 @ioctl(i32 %159, i32 4, i32* %160)
br label %180
162: ; preds = %153, %147
%163 = load i8**, i8*** %5
%164 = getelementptr inbounds i8*, i8** %163, i64 1
%165 = load i8*, i8** %164
%166 = call i64 @strcmp(i8* %165, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%167 = icmp eq i64 %166, 0
br i1 %167, label %168, label %177
168: ; preds = %162
%169 = load i8**, i8*** %5
%170 = getelementptr inbounds i8*, i8** %169, i64 3
%171 = load i8*, i8** %170
%172 = icmp ne i8* %171, null
br i1 %172, label %173, label %177
173: ; preds = %168
%174 = load i32, i32* %7
%175 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%176 = call i32 @ioctl(i32 %174, i32 5, i32* %175)
br label %179
177: ; preds = %168, %162
%178 = call i32 @print_usage(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %185
179: ; preds = %173
br label %180
180: ; preds = %179, %158
br label %181
181: ; preds = %180, %143
br label %182
182: ; preds = %181, %131
br label %183
183: ; preds = %182, %103
br label %184
184: ; preds = %183, %73
store i32 0, i32* %3
br label %185
185: ; preds = %184, %177, %25, %15
%186 = load i32, i32* %3
ret i32 %186
}

LLVM IR (-O2):
@.str = [12 x i8] c"/dev/ker_rw\00"
@O_RDWR = global i32 0
@.str.2 = [3 x i8] c"r8\00"
@.str.3 = [22 x i8] c"%02d. [%08x] = %02x \0A\00"
@.str.4 = [4 x i8] c"r16\00"
@.str.5 = [4 x i8] c"r32\00"
@.str.6 = [3 x i8] c"w8\00"
@.str.7 = [4 x i8] c"w16\00"
@.str.8 = [4 x i8] c"w32\00"
@str = [18 x i8] c"can't open file !\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32]
%4 = bitcast [2 x i32]* %3 to i8*
%5 = add i32 %0, -5
%6 = icmp ult i32 %5, -2
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 @print_usage(i8* %8)
br label %117
10: ; preds = %2
%11 = load i32, i32* @O_RDWR
%12 = tail call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %117
16: ; preds = %10
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i32 @strtoul(i8* nocapture %18, i32* null, i32 0)
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
store i32 %19, i32* %20
%21 = icmp eq i32 %0, 4
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = getelementptr inbounds i8*, i8** %1, i64 3
%24 = load i8*, i8** %23
%25 = tail call i32 @strtoul(i8* nocapture %24, i32* null, i32 0)
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
store i32 %25, i32* %26
br label %27
27: ; preds = %16, %22
%28 = phi i32 [ %25, %22 ], [ 1, %16 ]
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = load i8*, i8** %29
%31 = tail call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %48
33: ; preds = %27
%34 = icmp eq i32 %28, 0
br i1 %34, label %117, label %35
35: ; preds = %33
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
br label %37
37: ; preds = %35, %37
%38 = phi i32 [ 0, %35 ], [ %46, %37 ]
%39 = call i32 @ioctl(i32 %12, i32 0, i32* %20)
%40 = load i32, i32* %20
%41 = load i32, i32* %36
%42 = and i32 %41, 255
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %38, i32 %40, i32 %42)
%44 = load i32, i32* %20
%45 = add i32 %44, 1
store i32 %45, i32* %20
%46 = add nuw i32 %38, 1
%47 = icmp eq i32 %46, %28
br i1 %47, label %117, label %37
48: ; preds = %27
%49 = load i8*, i8** %29
%50 = tail call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %67
52: ; preds = %48
%53 = icmp eq i32 %28, 0
br i1 %53, label %117, label %54
54: ; preds = %52
%55 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
br label %56
56: ; preds = %54, %56
%57 = phi i32 [ 0, %54 ], [ %65, %56 ]
%58 = call i32 @ioctl(i32 %12, i32 1, i32* %20)
%59 = load i32, i32* %20
%60 = load i32, i32* %55
%61 = and i32 %60, 65535
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %57, i32 %59, i32 %61)
%63 = load i32, i32* %20
%64 = add i32 %63, 2
store i32 %64, i32* %20
%65 = add nuw i32 %57, 1
%66 = icmp eq i32 %65, %28
br i1 %66, label %117, label %56
67: ; preds = %48
%68 = load i8*, i8** %29
%69 = tail call i64 @strcmp(i8* %68, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %85
71: ; preds = %67
%72 = icmp eq i32 %28, 0
br i1 %72, label %117, label %73
73: ; preds = %71
%74 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
br label %75
75: ; preds = %73, %75
%76 = phi i32 [ 0, %73 ], [ %83, %75 ]
%77 = call i32 @ioctl(i32 %12, i32 2, i32* %20)
%78 = load i32, i32* %20
%79 = load i32, i32* %74
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %76, i32 %78, i32 %79)
%81 = load i32, i32* %20
%82 = add i32 %81, 4
store i32 %82, i32* %20
%83 = add nuw i32 %76, 1
%84 = icmp eq i32 %83, %28
br i1 %84, label %117, label %75
85: ; preds = %67
%86 = load i8*, i8** %29
%87 = tail call i64 @strcmp(i8* %86, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%88 = icmp eq i64 %87, 0
br i1 %88, label %89, label %95
89: ; preds = %85
%90 = getelementptr inbounds i8*, i8** %1, i64 3
%91 = load i8*, i8** %90
%92 = icmp eq i8* %91, null
br i1 %92, label %95, label %93
93: ; preds = %89
%94 = call i32 @ioctl(i32 %12, i32 3, i32* %20)
br label %117
95: ; preds = %89, %85
%96 = load i8*, i8** %29
%97 = tail call i64 @strcmp(i8* %96, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%98 = icmp eq i64 %97, 0
br i1 %98, label %99, label %105
99: ; preds = %95
%100 = getelementptr inbounds i8*, i8** %1, i64 3
%101 = load i8*, i8** %100
%102 = icmp eq i8* %101, null
br i1 %102, label %105, label %103
103: ; preds = %99
%104 = call i32 @ioctl(i32 %12, i32 4, i32* %20)
br label %117
105: ; preds = %99, %95
%106 = load i8*, i8** %29
%107 = tail call i64 @strcmp(i8* %106, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%108 = icmp eq i64 %107, 0
br i1 %108, label %109, label %115
109: ; preds = %105
%110 = getelementptr inbounds i8*, i8** %1, i64 3
%111 = load i8*, i8** %110
%112 = icmp eq i8* %111, null
br i1 %112, label %115, label %113
113: ; preds = %109
%114 = call i32 @ioctl(i32 %12, i32 5, i32* %20)
br label %117
115: ; preds = %109, %105
%116 = tail call i32 @print_usage(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %117
117: ; preds = %75, %56, %37, %71, %52, %33, %103, %113, %93, %115, %14, %7
%118 = phi i32 [ -1, %7 ], [ -2, %14 ], [ -1, %115 ], [ 0, %93 ], [ 0, %113 ], [ 0, %103 ], [ 0, %33 ], [ 0, %52 ], [ 0, %71 ], [ 0, %37 ], [ 0, %56 ], [ 0, %75 ]
ret i32 %118
}