#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*/ close(int);
int ioctl(int, unsigned int, ...);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
unsigned int strtoul(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int read;
  if (argc == 3)
    read = 1;
  else if (argc == 4)
    read = 0;
  else {
    printf("Usage: %s device ioctl [param]\n", argv[0]);
    return 1;
  }
  unsigned int encoded_ioctl = strtoul(argv[2], NULL, 0);
  unsigned char ioctl_number = encoded_ioctl & 0xff;
  unsigned char ioctl_type = (encoded_ioctl >> 8) & 0xff;
  unsigned short ioctl_size = (encoded_ioctl >> 16) & 0x3fff;
  unsigned char ioctl_direction = (encoded_ioctl >> 30) & 0x03;
  if (ioctl_direction & 0x01)
    printf("write ioctl %d.%d %d bytes\n", ioctl_type, ioctl_number,
           ioctl_size);
  else if (ioctl_direction & 0x02)
    printf("read ioctl %d.%d %d bytes\n", ioctl_type, ioctl_number, ioctl_size);
  else
    printf("ioctl %d.%d %d bytes\n", ioctl_type, ioctl_number, ioctl_size);
  unsigned int param = 0xA5A5;
  int fd = open(argv[1], O_RDWR);
  if (fd < 0) {
    perror(argv[1]);
    return 1;
  }
  int ret;
  if (read) {
    ret = ioctl(fd, encoded_ioctl, &param);
    if (ret < 0) {
      perror("IOCTL_read");
      return 1;
    }
    printf("0x%0X\n", param);
  } else {
    if (argv[3][0] == 'p') {
      printf("writing as pointer\n");
      param = strtoul(argv[3] + 1, NULL, 0);
      ret = ioctl(fd, encoded_ioctl, &param);
    } else {
      param = strtoul(argv[3], NULL, 0);
      ret = ioctl(fd, encoded_ioctl, param);
    }
    if (ret < 0) {
      perror("IOCTL_write");
      return 1;
    }
  }
  close(fd);
  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)
jne    118c <main+0x2c>
movl   $0x1,-0x14(%rbp)
jmp    11c8 <main+0x68>
cmpl   $0x4,-0x8(%rbp)
jne    11a2 <main+0x42>
movl   $0x0,-0x14(%rbp)
jmp    11c3 <main+0x63>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13dc <main+0x27c>
jmp    11c8 <main+0x68>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtoul@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %al,-0x1a(%rbp)
mov    -0x18(%rbp),%eax
shr    $0x10,%eax
and    $0x3fff,%eax
mov    %ax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
shr    $0x1e,%eax
and    $0x3,%eax
mov    %al,-0x1d(%rbp)
movzbl -0x1d(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1241 <main+0xe1>
movzbl -0x1a(%rbp),%esi
movzbl -0x19(%rbp),%edx
movzwl -0x1c(%rbp),%ecx
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128f <main+0x12f>
movzbl -0x1d(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1270 <main+0x110>
movzbl -0x1a(%rbp),%esi
movzbl -0x19(%rbp),%edx
movzwl -0x1c(%rbp),%ecx
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128a <main+0x12a>
movzbl -0x1a(%rbp),%esi
movzbl -0x19(%rbp),%edx
movzwl -0x1c(%rbp),%ecx
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128f <main+0x12f>
movl   $0xa5a5,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d43(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    12d2 <main+0x172>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13dc <main+0x27c>
cmpl   $0x0,-0x14(%rbp)
je     1328 <main+0x1c8>
mov    -0x28(%rbp),%edi
mov    -0x18(%rbp),%esi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1040 <ioctl@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1312 <main+0x1b2>
lea    0xd56(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13dc <main+0x27c>
mov    -0x24(%rbp),%esi
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13cd <main+0x26d>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movsbl (%rax),%eax
cmp    $0x70,%eax
jne    137d <main+0x21d>
lea    0xd26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtoul@plt>
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x18(%rbp),%esi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1040 <ioctl@plt>
mov    %eax,-0x2c(%rbp)
jmp    13a6 <main+0x246>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtoul@plt>
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    $0x0,%al
call   1040 <ioctl@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    13c8 <main+0x268>
lea    0xcc6(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13dc <main+0x27c>
jmp    13cd <main+0x26d>
mov    -0x28(%rbp),%edi
call   1050 <close@plt>
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   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r15d
lea    -0x3(%r15),%eax
cmp    $0x2,%eax
jae    11c1 <main+0x51>
mov    0x10(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtoul@plt>
mov    %eax,%ebp
mov    %eax,%ecx
shr    $0x8,%ecx
shr    $0x10,%eax
and    $0x3fff,%eax
movzbl %cl,%esi
movzbl %bpl,%edx
movzwl %ax,%ecx
test   $0x40000000,%ebp
jne    11dc <main+0x6c>
test   %ebp,%ebp
js     11e5 <main+0x75>
lea    0xe82(%rip),%rdi
jmp    11ec <main+0x7c>
mov    (%rbx),%rsi
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
jmp    12b1 <main+0x141>
lea    0xe3d(%rip),%rdi
jmp    11ec <main+0x7c>
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0xa5a5,0x4(%rsp)
mov    0x8(%rbx),%rdi
mov    0x2de2(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
test   %eax,%eax
js     12bc <main+0x14c>
mov    %eax,%r14d
cmp    $0x3,%r15d
jne    124b <main+0xdb>
lea    0x4(%rsp),%rdx
mov    %r14d,%edi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <ioctl@plt>
test   %eax,%eax
js     12c2 <main+0x152>
mov    0x4(%rsp),%esi
lea    0xe20(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12a7 <main+0x137>
mov    0x18(%rbx),%rdi
cmpb   $0x70,(%rdi)
jne    1288 <main+0x118>
lea    0xe1a(%rip),%rdi
call   1030 <puts@plt>
mov    0x18(%rbx),%rdi
add    $0x1,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtoul@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdx
mov    %r14d,%edi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <ioctl@plt>
jmp    12a3 <main+0x133>
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtoul@plt>
mov    %eax,0x4(%rsp)
mov    %r14d,%edi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <ioctl@plt>
test   %eax,%eax
js     12cb <main+0x15b>
mov    %r14d,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rbx),%rdi
jmp    12d2 <main+0x162>
lea    0xd8e(%rip),%rdi
jmp    12d2 <main+0x162>
lea    0xd97(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%eax
jmp    12b1 <main+0x141>

LLVM IR (-O0):
@.str = [32 x i8] c"Usage: %s device ioctl [param]\0A\00"
@.str.1 = [28 x i8] c"write ioctl %d.%d %d bytes\0A\00"
@.str.2 = [27 x i8] c"read ioctl %d.%d %d bytes\0A\00"
@.str.3 = [22 x i8] c"ioctl %d.%d %d bytes\0A\00"
@O_RDWR = global i32 0
@.str.4 = [11 x i8] c"IOCTL_read\00"
@.str.5 = [7 x i8] c"0x%0X\0A\00"
@.str.6 = [20 x i8] c"writing as pointer\0A\00"
@.str.7 = [12 x i8] c"IOCTL_write\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 i8
%9 = alloca i8
%10 = alloca i16
%11 = alloca i8
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 3
br i1 %16, label %17, label %18
17: ; preds = %2
store i32 1, i32* %6
br label %28
18: ; preds = %2
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 4
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 0, i32* %6
br label %27
22: ; preds = %18
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %25)
store i32 1, i32* %3
br label %145
27: ; preds = %21
br label %28
28: ; preds = %27, %17
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @strtoul(i8* %31, i32* null, i32 0)
store i32 %32, i32* %7
%33 = load i32, i32* %7
%34 = and i32 %33, 255
%35 = trunc i32 %34 to i8
store i8 %35, i8* %8
%36 = load i32, i32* %7
%37 = lshr i32 %36, 8
%38 = and i32 %37, 255
%39 = trunc i32 %38 to i8
store i8 %39, i8* %9
%40 = load i32, i32* %7
%41 = lshr i32 %40, 16
%42 = and i32 %41, 16383
%43 = trunc i32 %42 to i16
store i16 %43, i16* %10
%44 = load i32, i32* %7
%45 = lshr i32 %44, 30
%46 = and i32 %45, 3
%47 = trunc i32 %46 to i8
store i8 %47, i8* %11
%48 = load i8, i8* %11
%49 = zext i8 %48 to i32
%50 = and i32 %49, 1
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %60
52: ; preds = %28
%53 = load i8, i8* %9
%54 = zext i8 %53 to i32
%55 = load i8, i8* %8
%56 = zext i8 %55 to i32
%57 = load i16, i16* %10
%58 = zext i16 %57 to i32
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %54, i32 %56, i32 %58)
br label %82
60: ; preds = %28
%61 = load i8, i8* %11
%62 = zext i8 %61 to i32
%63 = and i32 %62, 2
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %73
65: ; preds = %60
%66 = load i8, i8* %9
%67 = zext i8 %66 to i32
%68 = load i8, i8* %8
%69 = zext i8 %68 to i32
%70 = load i16, i16* %10
%71 = zext i16 %70 to i32
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %67, i32 %69, i32 %71)
br label %81
73: ; preds = %60
%74 = load i8, i8* %9
%75 = zext i8 %74 to i32
%76 = load i8, i8* %8
%77 = zext i8 %76 to i32
%78 = load i16, i16* %10
%79 = zext i16 %78 to i32
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %75, i32 %77, i32 %79)
br label %81
81: ; preds = %73, %65
br label %82
82: ; preds = %81, %52
store i32 42405, i32* %12
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 1
%85 = load i8*, i8** %84
%86 = load i32, i32* @O_RDWR
%87 = call i32 @open(i8* %85, i32 %86)
store i32 %87, i32* %13
%88 = load i32, i32* %13
%89 = icmp slt i32 %88, 0
br i1 %89, label %90, label %95
90: ; preds = %82
%91 = load i8**, i8*** %5
%92 = getelementptr inbounds i8*, i8** %91, i64 1
%93 = load i8*, i8** %92
%94 = call i32 @perror(i8* %93)
store i32 1, i32* %3
br label %145
95: ; preds = %82
%96 = load i32, i32* %6
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %109
98: ; preds = %95
%99 = load i32, i32* %13
%100 = load i32, i32* %7
%101 = call i32 (i32, i32, ...) @ioctl(i32 %99, i32 %100, i32* %12)
store i32 %101, i32* %14
%102 = load i32, i32* %14
%103 = icmp slt i32 %102, 0
br i1 %103, label %104, label %106
104: ; preds = %98
%105 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %145
106: ; preds = %98
%107 = load i32, i32* %12
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %107)
br label %142
109: ; preds = %95
%110 = load i8**, i8*** %5
%111 = getelementptr inbounds i8*, i8** %110, i64 3
%112 = load i8*, i8** %111
%113 = getelementptr inbounds i8, i8* %112, i64 0
%114 = load i8, i8* %113
%115 = sext i8 %114 to i32
%116 = icmp eq i32 %115, 112
br i1 %116, label %117, label %127
117: ; preds = %109
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%119 = load i8**, i8*** %5
%120 = getelementptr inbounds i8*, i8** %119, i64 3
%121 = load i8*, i8** %120
%122 = getelementptr inbounds i8, i8* %121, i64 1
%123 = call i32 @strtoul(i8* %122, i32* null, i32 0)
store i32 %123, i32* %12
%124 = load i32, i32* %13
%125 = load i32, i32* %7
%126 = call i32 (i32, i32, ...) @ioctl(i32 %124, i32 %125, i32* %12)
store i32 %126, i32* %14
br label %136
127: ; preds = %109
%128 = load i8**, i8*** %5
%129 = getelementptr inbounds i8*, i8** %128, i64 3
%130 = load i8*, i8** %129
%131 = call i32 @strtoul(i8* %130, i32* null, i32 0)
store i32 %131, i32* %12
%132 = load i32, i32* %13
%133 = load i32, i32* %7
%134 = load i32, i32* %12
%135 = call i32 (i32, i32, ...) @ioctl(i32 %132, i32 %133, i32 %134)
store i32 %135, i32* %14
br label %136
136: ; preds = %127, %117
%137 = load i32, i32* %14
%138 = icmp slt i32 %137, 0
br i1 %138, label %139, label %141
139: ; preds = %136
%140 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %145
141: ; preds = %136
br label %142
142: ; preds = %141, %106
%143 = load i32, i32* %13
%144 = call i32 @close(i32 %143)
store i32 0, i32* %3
br label %145
145: ; preds = %142, %139, %104, %90, %22
%146 = load i32, i32* %3
ret i32 %146
}

LLVM IR (-O2):
@.str = [32 x i8] c"Usage: %s device ioctl [param]\0A\00"
@.str.1 = [28 x i8] c"write ioctl %d.%d %d bytes\0A\00"
@.str.2 = [27 x i8] c"read ioctl %d.%d %d bytes\0A\00"
@.str.3 = [22 x i8] c"ioctl %d.%d %d bytes\0A\00"
@O_RDWR = global i32 0
@.str.4 = [11 x i8] c"IOCTL_read\00"
@.str.5 = [7 x i8] c"0x%0X\0A\00"
@.str.7 = [12 x i8] c"IOCTL_write\00"
@str = [19 x i8] c"writing as pointer\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp eq i32 %0, 3
%5 = add i32 %0, -3
%6 = icmp ult i32 %5, 2
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %76
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32 @strtoul(i8* nocapture %12, i32* null, i32 0)
%14 = lshr i32 %13, 8
%15 = lshr i32 %13, 16
%16 = trunc i32 %15 to i16
%17 = and i16 %16, 16383
%18 = and i32 %13, 1073741824
%19 = icmp eq i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %10
%21 = and i32 %14, 255
%22 = and i32 %13, 255
%23 = zext i16 %17 to i32
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %22, i32 %23)
br label %34
25: ; preds = %10
%26 = icmp sgt i32 %13, -1
%27 = and i32 %14, 255
%28 = and i32 %13, 255
%29 = zext i16 %17 to i32
br i1 %26, label %32, label %30
30: ; preds = %25
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %28, i32 %29)
br label %34
32: ; preds = %25
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %28, i32 %29)
br label %34
34: ; preds = %30, %32, %20
%35 = bitcast i32* %3 to i8*
store i32 42405, i32* %3
%36 = getelementptr inbounds i8*, i8** %1, i64 1
%37 = load i8*, i8** %36
%38 = load i32, i32* @O_RDWR
%39 = tail call i32 @open(i8* %37, i32 %38)
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %34
%42 = load i8*, i8** %36
%43 = tail call i32 @perror(i8* %42)
br label %74
44: ; preds = %34
br i1 %4, label %45, label %53
45: ; preds = %44
%46 = call i32 (i32, i32, ...) @ioctl(i32 %39, i32 %13, i32* %3)
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %74
50: ; preds = %45
%51 = load i32, i32* %3
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %51)
br label %72
53: ; preds = %44
%54 = getelementptr inbounds i8*, i8** %1, i64 3
%55 = load i8*, i8** %54
%56 = load i8, i8* %55
%57 = icmp eq i8 %56, 112
br i1 %57, label %58, label %64
58: ; preds = %53
%59 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%60 = load i8*, i8** %54
%61 = getelementptr inbounds i8, i8* %60, i64 1
%62 = tail call i32 @strtoul(i8* nocapture %61, i32* null, i32 0)
store i32 %62, i32* %3
%63 = call i32 (i32, i32, ...) @ioctl(i32 %39, i32 %13, i32* %3)
br label %67
64: ; preds = %53
%65 = tail call i32 @strtoul(i8* nocapture %55, i32* null, i32 0)
store i32 %65, i32* %3
%66 = tail call i32 (i32, i32, ...) @ioctl(i32 %39, i32 %13, i32 %65)
br label %67
67: ; preds = %64, %58
%68 = phi i32 [ %63, %58 ], [ %66, %64 ]
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %67
%71 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %74
72: ; preds = %67, %50
%73 = call i32 @close(i32 %39)
br label %74
74: ; preds = %48, %70, %72, %41
%75 = phi i32 [ 1, %41 ], [ 1, %48 ], [ 0, %72 ], [ 1, %70 ]
br label %76
76: ; preds = %74, %7
%77 = phi i32 [ %75, %74 ], [ 1, %7 ]
ret i32 %77
}