#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 EOF;
int O_NONBLOCK;
int O_RDWR;
int /*<<< orphan*/ _IOC(int, char, int, int);
int _IOC_READ;
int _IOC_WRITE;
int atoi(char *);
int /*<<< orphan*/ close(int);
int getopt(int, char **, char *);
int ioctl(int, int /*<<< orphan*/, char *);
int open(char *, int);
char *optarg;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  int fd;
  int i, c, res, desc_size = 0;
  char buf[256];
  int opt;
  char *device = NULL;
  while ((opt = getopt(argc, argv, "c:d:")) != EOF) {
    switch (opt) {
    case 'c':
      c = atoi(optarg);
      break;
    case 'd':
      device = (optarg);
      break;
    default:
      usage();
      return 1;
    }
  }
  if (!device) {
    usage();
    return 1;
  }
  fd = open(device, O_RDWR | O_NONBLOCK);
  if (fd < 0) {
    perror("Unable to open device");
    return 1;
  }
  switch (c) {
  case 1:
    buf[0] = 0x9;
    res = ioctl(fd, _IOC(_IOC_WRITE | _IOC_READ, 'H', 0x07, 256), buf);
    if (res < 0) {
      perror("HIDIOCGFEATURE");
    } else {
      printf("ioctl HIDIOCGFEATURE returned: %d\n", res);
      printf("Report data (not containing the report number):\n\t");
      for (i = 0; i < res; i++)
        printf("%hhx ", buf[i]);
      puts("\n");
    }
    break;
  case 2:
    buf[0] = 0x9;
    buf[1] = 0xff;
    buf[2] = 0xff;
    buf[3] = 0xff;
    res = ioctl(fd, _IOC(_IOC_WRITE | _IOC_READ, 'H', 0x06, 4), buf);
    if (res < 0)
      perror("HIDIOCSFEATURE");
    else
      printf("ioctl HIDIOCGFEATURE returned: %d\n", res);
    break;
  default:
    printf("Unknown command\n");
    break;
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x140(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe27(%rip),%rdx
call   10b0 <getopt@plt>
mov    %eax,-0x134(%rbp)
mov    0x2de5(%rip),%rcx
cmp    (%rcx),%eax
je     1266 <main+0xc6>
mov    -0x134(%rbp),%eax
mov    %eax,-0x144(%rbp)
sub    $0x63,%eax
je     1221 <main+0x81>
jmp    120d <main+0x6d>
mov    -0x144(%rbp),%eax
sub    $0x64,%eax
je     1238 <main+0x98>
jmp    124e <main+0xae>
mov    0x2dd0(%rip),%rax
mov    (%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    1261 <main+0xc1>
mov    0x2db9(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x140(%rbp)
jmp    1261 <main+0xc1>
mov    $0x0,%al
call   1080 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1478 <main+0x2d8>
jmp    11cb <main+0x2b>
cmpq   $0x0,-0x140(%rbp)
jne    1287 <main+0xe7>
mov    $0x0,%al
call   1080 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1478 <main+0x2d8>
mov    -0x140(%rbp),%rdi
mov    0x2d4b(%rip),%rax
mov    (%rax),%esi
mov    0x2d3a(%rip),%rax
or     (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12ca <main+0x12a>
lea    0xd4c(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1478 <main+0x2d8>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x148(%rbp)
sub    $0x1,%eax
je     12f5 <main+0x155>
jmp    12e1 <main+0x141>
mov    -0x148(%rbp),%eax
sub    $0x2,%eax
je     13c8 <main+0x228>
jmp    145b <main+0x2bb>
movb   $0x9,-0x130(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x14c(%rbp)
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
mov    0x2cab(%rip),%rax
or     (%rax),%edi
mov    $0x48,%esi
mov    $0x7,%edx
mov    $0x100,%ecx
call   1040 <_IOC@plt>
mov    -0x14c(%rbp),%edi
mov    %eax,%esi
lea    -0x130(%rbp),%rdx
call   1060 <ioctl@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    135d <main+0x1bd>
lea    0xcc8(%rip),%rdi
call   10a0 <perror@plt>
jmp    13c3 <main+0x223>
mov    -0x20(%rbp),%esi
lea    0xcc3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xcd8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    13b7 <main+0x217>
movslq -0x18(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%esi
ff
lea    0xcdd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1383 <main+0x1e3>
lea    0xc8d(%rip),%rdi
call   1030 <puts@plt>
jmp    1469 <main+0x2c9>
movb   $0x9,-0x130(%rbp)
movb   $0xff,-0x12f(%rbp)
movb   $0xff,-0x12e(%rbp)
movb   $0xff,-0x12d(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x150(%rbp)
mov    0x2bbc(%rip),%rax
mov    (%rax),%edi
mov    0x2bc3(%rip),%rax
or     (%rax),%edi
mov    $0x48,%esi
mov    $0x6,%edx
mov    $0x4,%ecx
call   1040 <_IOC@plt>
mov    -0x150(%rbp),%edi
mov    %eax,%esi
lea    -0x130(%rbp),%rdx
call   1060 <ioctl@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1445 <main+0x2a5>
lea    0xc4a(%rip),%rdi
call   10a0 <perror@plt>
jmp    1456 <main+0x2b6>
mov    -0x20(%rbp),%esi
lea    0xbdb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1469 <main+0x2c9>
lea    0xc32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe43(%rip),%rdx
call   10b0 <getopt@plt>
mov    0x2e07(%rip),%r13
cmp    0x0(%r13),%eax
jne    11ed <main+0x4d>
xor    %eax,%eax
call   1080 <usage@plt>
mov    $0x1,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r14d,%r14d
mov    0x2e01(%rip),%r15
lea    0xe02(%rip),%r12
jmp    1216 <main+0x76>
mov    (%r15),%r14
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   10b0 <getopt@plt>
cmp    0x0(%r13),%eax
je     122e <main+0x8e>
cmp    $0x64,%eax
je     1200 <main+0x60>
cmp    $0x63,%eax
jne    11cf <main+0x2f>
mov    (%r15),%rdi
call   10c0 <atoi@plt>
mov    %eax,0xc(%rsp)
jmp    1203 <main+0x63>
test   %r14,%r14
je     11cf <main+0x2f>
mov    0x2da6(%rip),%rax
mov    0x2d97(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %r14,%rdi
call   1090 <open@plt>
test   %eax,%eax
js     136f <main+0x1cf>
mov    %eax,%r14d
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
je     1301 <main+0x161>
cmp    $0x1,%eax
jne    1354 <main+0x1b4>
movb   $0x9,0x10(%rsp)
mov    0x2d36(%rip),%rax
mov    0x2d3f(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
mov    $0x48,%esi
mov    $0x7,%edx
mov    $0x100,%ecx
call   1040 <_IOC@plt>
lea    0x10(%rsp),%rdx
mov    %r14d,%edi
mov    %eax,%esi
call   1060 <ioctl@plt>
test   %eax,%eax
js     1380 <main+0x1e0>
mov    %eax,%ebp
lea    0xd71(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd84(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
je     12f8 <main+0x158>
mov    %ebp,%ebx
lea    0xda2(%rip),%r15
xor    %ebp,%ebp
nop
movsbl 0x10(%rsp,%rbp,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    12e0 <main+0x140>
lea    0xd4c(%rip),%rdi
jmp    135b <main+0x1bb>
movl   $0xffffff09,0x10(%rsp)
ff
mov    0x2ca0(%rip),%rax
mov    0x2ca9(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
mov    $0x48,%esi
mov    $0x6,%edx
mov    $0x4,%ecx
call   1040 <_IOC@plt>
lea    0x10(%rsp),%rdx
mov    %r14d,%edi
mov    %eax,%esi
call   1060 <ioctl@plt>
test   %eax,%eax
js     138e <main+0x1ee>
lea    0xce1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1360 <main+0x1c0>
lea    0xd39(%rip),%rdi
call   1030 <puts@plt>
mov    %r14d,%edi
call   1070 <close@plt>
xor    %eax,%eax
jmp    11db <main+0x3b>
lea    0xc8f(%rip),%rdi
call   10a0 <perror@plt>
jmp    11d6 <main+0x36>
lea    0xc94(%rip),%rdi
call   10a0 <perror@plt>
jmp    1360 <main+0x1c0>
lea    0xcf0(%rip),%rdi
call   10a0 <perror@plt>
jmp    1360 <main+0x1c0>

LLVM IR (-O0):
@.str = [5 x i8] c"c:d:\00"
@EOF = global i32 0
@optarg = global i8* null
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [22 x i8] c"Unable to open device\00"
@_IOC_WRITE = global i32 0
@_IOC_READ = global i32 0
@.str.2 = [15 x i8] c"HIDIOCGFEATURE\00"
@.str.3 = [35 x i8] c"ioctl HIDIOCGFEATURE returned: %d\0A\00"
@.str.4 = [50 x i8] c"Report data (not containing the report number):\0A\09\00"
@.str.5 = [6 x i8] c"%hhx \00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [15 x i8] c"HIDIOCSFEATURE\00"
@.str.8 = [17 x i8] c"Unknown command\0A\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 i32
%10 = alloca i32
%11 = alloca [256 x i8]
%12 = alloca i32
%13 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
store i8* null, i8** %13
br label %14
14: ; preds = %29, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %17, i32* %12
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %30
20: ; preds = %14
%21 = load i32, i32* %12
switch i32 %21, label %27 [
i32 99, label %22
i32 100, label %25
]
22: ; preds = %20
%23 = load i8*, i8** @optarg
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %8
br label %29
25: ; preds = %20
%26 = load i8*, i8** @optarg
store i8* %26, i8** %13
br label %29
27: ; preds = %20
%28 = call i32 (...) @usage()
store i32 1, i32* %3
br label %106
29: ; preds = %25, %22
br label %14
30: ; preds = %14
%31 = load i8*, i8** %13
%32 = icmp ne i8* %31, null
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = call i32 (...) @usage()
store i32 1, i32* %3
br label %106
35: ; preds = %30
%36 = load i8*, i8** %13
%37 = load i32, i32* @O_RDWR
%38 = load i32, i32* @O_NONBLOCK
%39 = or i32 %37, %38
%40 = call i32 @open(i8* %36, i32 %39)
store i32 %40, i32* %6
%41 = load i32, i32* %6
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %35
%44 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %106
45: ; preds = %35
%46 = load i32, i32* %8
switch i32 %46, label %101 [
i32 1, label %47
i32 2, label %81
]
47: ; preds = %45
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
store i8 9, i8* %48
%49 = load i32, i32* %6
%50 = load i32, i32* @_IOC_WRITE
%51 = load i32, i32* @_IOC_READ
%52 = or i32 %50, %51
%53 = call i32 @_IOC(i32 %52, i8 signext 72, i32 7, i32 256)
%54 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%55 = call i32 @ioctl(i32 %49, i32 %53, i8* %54)
store i32 %55, i32* %9
%56 = load i32, i32* %9
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %47
%59 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %80
60: ; preds = %47
%61 = load i32, i32* %9
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %61)
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %7
br label %64
64: ; preds = %75, %60
%65 = load i32, i32* %7
%66 = load i32, i32* %9
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %78
68: ; preds = %64
%69 = load i32, i32* %7
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %73)
br label %75
75: ; preds = %68
%76 = load i32, i32* %7
%77 = add nsw i32 %76, 1
store i32 %77, i32* %7
br label %64
78: ; preds = %64
%79 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %80
80: ; preds = %78, %58
br label %103
81: ; preds = %45
%82 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
store i8 9, i8* %82
%83 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 1
store i8 -1, i8* %83
%84 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 2
store i8 -1, i8* %84
%85 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 3
store i8 -1, i8* %85
%86 = load i32, i32* %6
%87 = load i32, i32* @_IOC_WRITE
%88 = load i32, i32* @_IOC_READ
%89 = or i32 %87, %88
%90 = call i32 @_IOC(i32 %89, i8 signext 72, i32 6, i32 4)
%91 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%92 = call i32 @ioctl(i32 %86, i32 %90, i8* %91)
store i32 %92, i32* %9
%93 = load i32, i32* %9
%94 = icmp slt i32 %93, 0
br i1 %94, label %95, label %97
95: ; preds = %81
%96 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %100
97: ; preds = %81
%98 = load i32, i32* %9
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %98)
br label %100
100: ; preds = %97, %95
br label %103
101: ; preds = %45
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
br label %103
103: ; preds = %101, %100, %80
%104 = load i32, i32* %6
%105 = call i32 @close(i32 %104)
store i32 0, i32* %3
br label %106
106: ; preds = %103, %43, %33, %27
%107 = load i32, i32* %3
ret i32 %107
}

LLVM IR (-O2):
@.str = [5 x i8] c"c:d:\00"
@EOF = global i32 0
@optarg = global i8* null
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [22 x i8] c"Unable to open device\00"
@_IOC_WRITE = global i32 0
@_IOC_READ = global i32 0
@.str.2 = [15 x i8] c"HIDIOCGFEATURE\00"
@.str.3 = [35 x i8] c"ioctl HIDIOCGFEATURE returned: %d\0A\00"
@.str.4 = [50 x i8] c"Report data (not containing the report number):\0A\09\00"
@.str.5 = [6 x i8] c"%hhx \00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [15 x i8] c"HIDIOCSFEATURE\00"
@str = [16 x i8] c"Unknown command\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %27, label %8
8: ; preds = %2, %19
%9 = phi i32 [ %22, %19 ], [ %5, %2 ]
%10 = phi i8* [ %21, %19 ], [ null, %2 ]
%11 = phi i32 [ %20, %19 ], [ undef, %2 ]
switch i32 %9, label %17 [
i32 99, label %12
i32 100, label %15
]
12: ; preds = %8
%13 = load i8*, i8** @optarg
%14 = tail call i32 @atoi(i8* %13)
br label %19
15: ; preds = %8
%16 = load i8*, i8** @optarg
br label %19
17: ; preds = %8
%18 = tail call i32 (...) @usage()
br label %81
19: ; preds = %15, %12
%20 = phi i32 [ %11, %15 ], [ %14, %12 ]
%21 = phi i8* [ %16, %15 ], [ %10, %12 ]
%22 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @EOF
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %8
25: ; preds = %19
%26 = icmp eq i8* %21, null
br i1 %26, label %27, label %29
27: ; preds = %2, %25
%28 = tail call i32 (...) @usage()
br label %81
29: ; preds = %25
%30 = load i32, i32* @O_RDWR
%31 = load i32, i32* @O_NONBLOCK
%32 = or i32 %31, %30
%33 = tail call i32 @open(i8* %21, i32 %32)
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %81
37: ; preds = %29
switch i32 %20, label %77 [
i32 1, label %38
i32 2, label %63
]
38: ; preds = %37
store i8 9, i8* %4
%39 = load i32, i32* @_IOC_WRITE
%40 = load i32, i32* @_IOC_READ
%41 = or i32 %40, %39
%42 = tail call i32 @_IOC(i32 %41, i8 signext 72, i32 7, i32 256)
%43 = call i32 @ioctl(i32 %33, i32 %42, i8* %4)
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %38
%46 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %79
47: ; preds = %38
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %43)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
%50 = icmp eq i32 %43, 0
br i1 %50, label %61, label %51
51: ; preds = %47
%52 = zext i32 %43 to i64
br label %53
53: ; preds = %51, %53
%54 = phi i64 [ 0, %51 ], [ %59, %53 ]
%55 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %54
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %57)
%59 = add nuw nsw i64 %54, 1
%60 = icmp eq i64 %59, %52
br i1 %60, label %61, label %53
61: ; preds = %53, %47
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %79
63: ; preds = %37
store i8 9, i8* %4
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 1
store i8 -1, i8* %64
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 2
store i8 -1, i8* %65
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 3
store i8 -1, i8* %66
%67 = load i32, i32* @_IOC_WRITE
%68 = load i32, i32* @_IOC_READ
%69 = or i32 %68, %67
%70 = tail call i32 @_IOC(i32 %69, i8 signext 72, i32 6, i32 4)
%71 = call i32 @ioctl(i32 %33, i32 %70, i8* %4)
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %63
%74 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %79
75: ; preds = %63
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %71)
br label %79
77: ; preds = %37
%78 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %79
79: ; preds = %73, %75, %45, %61, %77
%80 = call i32 @close(i32 %33)
br label %81
81: ; preds = %79, %35, %27, %17
%82 = phi i32 [ 1, %17 ], [ 1, %35 ], [ 0, %79 ], [ 1, %27 ]
ret i32 %82
}