#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int *filter;
  int *mask;
};
struct dmx_sct_filter_params {
  int flags;
  scalar_t__ timeout;
  TYPE_1__ filter;
  scalar_t__ pid;
};
typedef int /*<<< orphan*/ f;
typedef int /*<<< orphan*/ buft;

/* Variables and functions */
int DMX_CHECK_CRC;
int DMX_IMMEDIATE_START;
int /*<<< orphan*/ DMX_SET_FILTER;
scalar_t__ EOVERFLOW;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int ioctl(int, int /*<<< orphan*/, struct dmx_sct_filter_params *);
int /*<<< orphan*/ memset(struct dmx_sct_filter_params *, int /*<<< orphan*/,
                          int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int read(int, unsigned char *, int);
int get_pmt_pid(char *dmxdev, int sid) {
  int patfd, count;
  int pmt_pid = 0;
  int patread = 0;
  int section_length;
  unsigned char buft[4096];
  unsigned char *buf = buft;
  struct dmx_sct_filter_params f;
  memset(&f, 0, sizeof(f));
  f.pid = 0;
  f.filter.filter[0] = 0x00;
  f.filter.mask[0] = 0xff;
  f.timeout = 0;
  f.flags = DMX_IMMEDIATE_START | DMX_CHECK_CRC;
  if ((patfd = open(dmxdev, O_RDWR)) < 0) {
    perror("openening pat demux failed");
    return -1;
  }
  if (ioctl(patfd, DMX_SET_FILTER, &f) == -1) {
    perror("ioctl DMX_SET_FILTER failed");
    close(patfd);
    return -1;
  }
  while (!patread) {
    if (((count = read(patfd, buf, sizeof(buft))) < 0) && errno == EOVERFLOW)
      count = read(patfd, buf, sizeof(buft));
    if (count < 0) {
      perror("read_sections: read error");
      close(patfd);
      return -1;
    }
    section_length = ((buf[1] & 0x0f) << 8) | buf[2];
    if (count != section_length + 3)
      continue;
    buf += 8;
    section_length -= 8;
    patread = 1;
    while (section_length > 0) {
      int service_id = (buf[0] << 8) | buf[1];
      if (service_id == sid) {
        pmt_pid = ((buf[2] & 0x1f) << 8) | buf[3];
        section_length = 0;
      }
      buf += 4;
      section_length -= 4;
    }
  }
  close(patfd);
  return pmt_pid;
}


x86 assembly (clang, -O0):
<get_pmt_pid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1070,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x1030(%rbp),%rax
mov    %rax,-0x1038(%rbp)
lea    -0x1060(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
movq   $0x0,-0x1040(%rbp)
mov    -0x1050(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x1048(%rbp),%rax
movl   $0xff,(%rax)
movq   $0x0,-0x1058(%rbp)
mov    0x2de0(%rip),%rax
mov    (%rax),%eax
mov    0x2ddf(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x1060(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2dec(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    121f <get_pmt_pid+0xbf>
lea    0xdf2(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13e3 <get_pmt_pid+0x283>
mov    -0x18(%rbp),%edi
mov    0x2daf(%rip),%rax
mov    (%rax),%esi
lea    -0x1060(%rbp),%rdx
call   1040 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    1260 <get_pmt_pid+0x100>
lea    0xdd4(%rip),%rdi
call   1080 <perror@plt>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13e3 <get_pmt_pid+0x283>
jmp    1265 <get_pmt_pid+0x105>
cmpl   $0x0,-0x24(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    127b <get_pmt_pid+0x11b>
jmp    13d5 <get_pmt_pid+0x275>
mov    -0x18(%rbp),%edi
mov    -0x1038(%rbp),%rsi
mov    $0x1000,%edx
call   1060 <read@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    12cc <get_pmt_pid+0x16c>
mov    0x2d26(%rip),%rax
mov    (%rax),%rax
mov    0x2d44(%rip),%rcx
cmp    (%rcx),%rax
jne    12cc <get_pmt_pid+0x16c>
mov    -0x18(%rbp),%edi
mov    -0x1038(%rbp),%rsi
mov    $0x1000,%edx
call   1060 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    12f6 <get_pmt_pid+0x196>
lea    0xd5a(%rip),%rdi
call   1080 <perror@plt>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13e3 <get_pmt_pid+0x283>
mov    -0x1038(%rbp),%rax
movzbl 0x1(%rax),%eax
and    $0xf,%eax
shl    $0x8,%eax
mov    -0x1038(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x28(%rbp),%ecx
add    $0x3,%ecx
cmp    %ecx,%eax
je     132d <get_pmt_pid+0x1cd>
jmp    1265 <get_pmt_pid+0x105>
mov    -0x1038(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x1038(%rbp)
mov    -0x28(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x0,-0x28(%rbp)
jle    13d0 <get_pmt_pid+0x270>
mov    -0x1038(%rbp),%rax
movzbl (%rax),%eax
shl    $0x8,%eax
mov    -0x1038(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0x1064(%rbp)
mov    -0x1064(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    13b0 <get_pmt_pid+0x250>
mov    -0x1038(%rbp),%rax
movzbl 0x2(%rax),%eax
and    $0x1f,%eax
shl    $0x8,%eax
mov    -0x1038(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x1038(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x1038(%rbp)
mov    -0x28(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x28(%rbp)
jmp    134f <get_pmt_pid+0x1ef>
jmp    1265 <get_pmt_pid+0x105>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1070,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_pmt_pid>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1030,%rsp
mov    %esi,%r15d
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
movq   $0x0,0x28(%rsp)
mov    0x18(%rsp),%rax
movl   $0x0,(%rax)
mov    0x20(%rsp),%rax
movl   $0xff,(%rax)
mov    0x2e0c(%rip),%rax
mov    0x2e0d(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
movq   $0x0,0x10(%rsp)
mov    %ecx,0x8(%rsp)
mov    0x2e15(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1070 <open@plt>
test   %eax,%eax
js     12d7 <get_pmt_pid+0x177>
mov    %eax,%ebx
mov    0x2df2(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1040 <ioctl@plt>
cmp    $0xffffffff,%eax
je     12eb <get_pmt_pid+0x18b>
lea    0x30(%rsp),%rbp
mov    0x2dbf(%rip),%r14
mov    0x2de0(%rip),%r12
jmp    123a <get_pmt_pid+0xda>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x31(%rsp),%ecx
and    $0xf,%ecx
shl    $0x8,%ecx
movzbl 0x32(%rsp),%edx
lea    (%rcx,%rdx,1),%esi
add    $0x3,%esi
cmp    %esi,%eax
je     1275 <get_pmt_pid+0x115>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1000,%edx
call   1060 <read@plt>
test   %eax,%eax
jns    1220 <get_pmt_pid+0xc0>
mov    (%r14),%rax
cmp    (%r12),%rax
jne    1269 <get_pmt_pid+0x109>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1000,%edx
call   1060 <read@plt>
test   %eax,%eax
jns    1220 <get_pmt_pid+0xc0>
lea    0xdc7(%rip),%rdi
jmp    12f2 <get_pmt_pid+0x192>
or     %edx,%ecx
xor    %r14d,%r14d
cmp    $0x9,%ecx
jb     12bd <get_pmt_pid+0x15d>
lea    0x3b(%rsp),%rax
add    $0xfffffffc,%ecx
nopw   0x0(%rax,%rax,1)
movzwl -0x3(%rax),%edx
shl    $0x10,%edx
bswap  %edx
cmp    %r15d,%edx
je     12ac <get_pmt_pid+0x14c>
add    $0x4,%rax
add    $0xfffffffc,%ecx
cmp    $0x4,%ecx
jg     1290 <get_pmt_pid+0x130>
jmp    12bd <get_pmt_pid+0x15d>
movzbl -0x1(%rax),%ecx
and    $0x1f,%ecx
shl    $0x8,%ecx
movzbl (%rax),%r14d
or     %ecx,%r14d
mov    %ebx,%edi
call   1050 <close@plt>
mov    %r14d,%eax
add    $0x1030,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd22(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%r14d
jmp    12c4 <get_pmt_pid+0x164>
lea    0xd29(%rip),%rdi
call   1080 <perror@plt>
mov    %ebx,%edi
call   1050 <close@plt>
mov    $0xffffffff,%r14d
jmp    12c4 <get_pmt_pid+0x164>

LLVM IR (-O0):
%struct.dmx_sct_filter_params = type { i32, i64, %struct.TYPE_2__, i64 }
%struct.TYPE_2__ = type { i32*, i32* }
@DMX_IMMEDIATE_START = global i32 0
@DMX_CHECK_CRC = global i32 0
@O_RDWR = global i32 0
@.str = [27 x i8] c"openening pat demux failed\00"
@DMX_SET_FILTER = global i32 0
@.str.1 = [28 x i8] c"ioctl DMX_SET_FILTER failed\00"
@errno = global i64 0
@EOVERFLOW = global i64 0
@.str.2 = [26 x i8] c"read_sections: read error\00"
define i32 @get_pmt_pid(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [4096 x i8]
%12 = alloca i8*
%13 = alloca %struct.dmx_sct_filter_params
%14 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 0, i32* %8
store i32 0, i32* %9
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
store i8* %15, i8** %12
%16 = call i32 @memset(%struct.dmx_sct_filter_params* %13, i32 0, i32 40)
%17 = getelementptr inbounds %struct.dmx_sct_filter_params, %struct.dmx_sct_filter_params* %13, i32 0, i32 3
store i64 0, i64* %17
%18 = getelementptr inbounds %struct.dmx_sct_filter_params, %struct.dmx_sct_filter_params* %13, i32 0, i32 2
%19 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %18, i32 0, i32 0
%20 = load i32*, i32** %19
%21 = getelementptr inbounds i32, i32* %20, i64 0
store i32 0, i32* %21
%22 = getelementptr inbounds %struct.dmx_sct_filter_params, %struct.dmx_sct_filter_params* %13, i32 0, i32 2
%23 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %22, i32 0, i32 1
%24 = load i32*, i32** %23
%25 = getelementptr inbounds i32, i32* %24, i64 0
store i32 255, i32* %25
%26 = getelementptr inbounds %struct.dmx_sct_filter_params, %struct.dmx_sct_filter_params* %13, i32 0, i32 1
store i64 0, i64* %26
%27 = load i32, i32* @DMX_IMMEDIATE_START
%28 = load i32, i32* @DMX_CHECK_CRC
%29 = or i32 %27, %28
%30 = getelementptr inbounds %struct.dmx_sct_filter_params, %struct.dmx_sct_filter_params* %13, i32 0, i32 0
store i32 %29, i32* %30
%31 = load i8*, i8** %4
%32 = load i32, i32* @O_RDWR
%33 = call i32 @open(i8* %31, i32 %32)
store i32 %33, i32* %6
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %2
%36 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %132
37: ; preds = %2
%38 = load i32, i32* %6
%39 = load i32, i32* @DMX_SET_FILTER
%40 = call i32 @ioctl(i32 %38, i32 %39, %struct.dmx_sct_filter_params* %13)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %46
42: ; preds = %37
%43 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%44 = load i32, i32* %6
%45 = call i32 @close(i32 %44)
store i32 -1, i32* %3
br label %132
46: ; preds = %37
br label %47
47: ; preds = %127, %87, %46
%48 = load i32, i32* %9
%49 = icmp ne i32 %48, 0
%50 = xor i1 %49, true
br i1 %50, label %51, label %128
51: ; preds = %47
%52 = load i32, i32* %6
%53 = load i8*, i8** %12
%54 = call i32 @read(i32 %52, i8* %53, i32 4096)
store i32 %54, i32* %7
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %64
56: ; preds = %51
%57 = load i64, i64* @errno
%58 = load i64, i64* @EOVERFLOW
%59 = icmp eq i64 %57, %58
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = load i32, i32* %6
%62 = load i8*, i8** %12
%63 = call i32 @read(i32 %61, i8* %62, i32 4096)
store i32 %63, i32* %7
br label %64
64: ; preds = %60, %56, %51
%65 = load i32, i32* %7
%66 = icmp slt i32 %65, 0
br i1 %66, label %67, label %71
67: ; preds = %64
%68 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%69 = load i32, i32* %6
%70 = call i32 @close(i32 %69)
store i32 -1, i32* %3
br label %132
71: ; preds = %64
%72 = load i8*, i8** %12
%73 = getelementptr inbounds i8, i8* %72, i64 1
%74 = load i8, i8* %73
%75 = zext i8 %74 to i32
%76 = and i32 %75, 15
%77 = shl i32 %76, 8
%78 = load i8*, i8** %12
%79 = getelementptr inbounds i8, i8* %78, i64 2
%80 = load i8, i8* %79
%81 = zext i8 %80 to i32
%82 = or i32 %77, %81
store i32 %82, i32* %10
%83 = load i32, i32* %7
%84 = load i32, i32* %10
%85 = add nsw i32 %84, 3
%86 = icmp ne i32 %83, %85
br i1 %86, label %87, label %88
87: ; preds = %71
br label %47
88: ; preds = %71
%89 = load i8*, i8** %12
%90 = getelementptr inbounds i8, i8* %89, i64 8
store i8* %90, i8** %12
%91 = load i32, i32* %10
%92 = sub nsw i32 %91, 8
store i32 %92, i32* %10
store i32 1, i32* %9
br label %93
93: ; preds = %122, %88
%94 = load i32, i32* %10
%95 = icmp sgt i32 %94, 0
br i1 %95, label %96, label %127
96: ; preds = %93
%97 = load i8*, i8** %12
%98 = getelementptr inbounds i8, i8* %97, i64 0
%99 = load i8, i8* %98
%100 = zext i8 %99 to i32
%101 = shl i32 %100, 8
%102 = load i8*, i8** %12
%103 = getelementptr inbounds i8, i8* %102, i64 1
%104 = load i8, i8* %103
%105 = zext i8 %104 to i32
%106 = or i32 %101, %105
store i32 %106, i32* %14
%107 = load i32, i32* %14
%108 = load i32, i32* %5
%109 = icmp eq i32 %107, %108
br i1 %109, label %110, label %122
110: ; preds = %96
%111 = load i8*, i8** %12
%112 = getelementptr inbounds i8, i8* %111, i64 2
%113 = load i8, i8* %112
%114 = zext i8 %113 to i32
%115 = and i32 %114, 31
%116 = shl i32 %115, 8
%117 = load i8*, i8** %12
%118 = getelementptr inbounds i8, i8* %117, i64 3
%119 = load i8, i8* %118
%120 = zext i8 %119 to i32
%121 = or i32 %116, %120
store i32 %121, i32* %8
store i32 0, i32* %10
br label %122
122: ; preds = %110, %96
%123 = load i8*, i8** %12
%124 = getelementptr inbounds i8, i8* %123, i64 4
store i8* %124, i8** %12
%125 = load i32, i32* %10
%126 = sub nsw i32 %125, 4
store i32 %126, i32* %10
br label %93
127: ; preds = %93
br label %47
128: ; preds = %47
%129 = load i32, i32* %6
%130 = call i32 @close(i32 %129)
%131 = load i32, i32* %8
store i32 %131, i32* %3
br label %132
132: ; preds = %128, %67, %42, %35
%133 = load i32, i32* %3
ret i32 %133
}

LLVM IR (-O2):
%struct.dmx_sct_filter_params = type { i32, i64, %struct.TYPE_2__, i64 }
%struct.TYPE_2__ = type { i32*, i32* }
@DMX_IMMEDIATE_START = global i32 0
@DMX_CHECK_CRC = global i32 0
@O_RDWR = global i32 0
@.str = [27 x i8] c"openening pat demux failed\00"
@DMX_SET_FILTER = global i32 0
@.str.1 = [28 x i8] c"ioctl DMX_SET_FILTER failed\00"
@errno = global i64 0
@EOVERFLOW = global i64 0
@.str.2 = [26 x i8] c"read_sections: read error\00"
define i32 @get_pmt_pid(i8* nocapture %0, i32 %1) {
%3 = alloca [4096 x i8]
%4 = alloca %struct.dmx_sct_filter_params
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.dmx_sct_filter_params* %4 to i8*
%7 = call i32 @memset(%struct.dmx_sct_filter_params* %4, i32 0, i32 40)
%8 = getelementptr inbounds %struct.dmx_sct_filter_params, %struct.dmx_sct_filter_params* %4, i64 0, i32 3
store i64 0, i64* %8
%9 = getelementptr inbounds %struct.dmx_sct_filter_params, %struct.dmx_sct_filter_params* %4, i64 0, i32 2, i32 0
%10 = load i32*, i32** %9
store i32 0, i32* %10
%11 = getelementptr inbounds %struct.dmx_sct_filter_params, %struct.dmx_sct_filter_params* %4, i64 0, i32 2, i32 1
%12 = load i32*, i32** %11
store i32 255, i32* %12
%13 = getelementptr inbounds %struct.dmx_sct_filter_params, %struct.dmx_sct_filter_params* %4, i64 0, i32 1
store i64 0, i64* %13
%14 = load i32, i32* @DMX_IMMEDIATE_START
%15 = load i32, i32* @DMX_CHECK_CRC
%16 = or i32 %15, %14
%17 = getelementptr inbounds %struct.dmx_sct_filter_params, %struct.dmx_sct_filter_params* %4, i64 0, i32 0
store i32 %16, i32* %17
%18 = load i32, i32* @O_RDWR
%19 = call i32 @open(i8* %0, i32 %18)
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %90
23: ; preds = %2
%24 = load i32, i32* @DMX_SET_FILTER
%25 = call i32 @ioctl(i32 %19, i32 %24, %struct.dmx_sct_filter_params* %4)
%26 = icmp eq i32 %25, -1
br i1 %26, label %30, label %27
27: ; preds = %23
%28 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 1
%29 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 2
br label %33
30: ; preds = %23
%31 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @close(i32 %19)
br label %90
33: ; preds = %27, %46
%34 = call i32 @read(i32 %19, i8* %5, i32 4096)
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %46
36: ; preds = %33
%37 = load i64, i64* @errno
%38 = load i64, i64* @EOVERFLOW
%39 = icmp eq i64 %37, %38
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = call i32 @read(i32 %19, i8* %5, i32 4096)
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %36, %40
%44 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%45 = call i32 @close(i32 %19)
br label %90
46: ; preds = %33, %40
%47 = phi i32 [ %41, %40 ], [ %34, %33 ]
%48 = load i8, i8* %28
%49 = and i8 %48, 15
%50 = zext i8 %49 to i32
%51 = shl nuw nsw i32 %50, 8
%52 = load i8, i8* %29
%53 = zext i8 %52 to i32
%54 = or i32 %51, %53
%55 = add nuw nsw i32 %54, 3
%56 = icmp eq i32 %47, %55
br i1 %56, label %57, label %33
57: ; preds = %46
%58 = icmp ugt i32 %54, 8
br i1 %58, label %59, label %87
59: ; preds = %57
%60 = add nsw i32 %54, -8
%61 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 8
br label %62
62: ; preds = %59, %83
%63 = phi i8* [ %84, %83 ], [ %61, %59 ]
%64 = phi i32 [ %85, %83 ], [ %60, %59 ]
%65 = load i8, i8* %63
%66 = zext i8 %65 to i32
%67 = shl nuw nsw i32 %66, 8
%68 = getelementptr inbounds i8, i8* %63, i64 1
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = or i32 %67, %70
%72 = icmp eq i32 %71, %1
br i1 %72, label %73, label %83
73: ; preds = %62
%74 = getelementptr inbounds i8, i8* %63, i64 2
%75 = load i8, i8* %74
%76 = and i8 %75, 31
%77 = zext i8 %76 to i32
%78 = shl nuw nsw i32 %77, 8
%79 = getelementptr inbounds i8, i8* %63, i64 3
%80 = load i8, i8* %79
%81 = zext i8 %80 to i32
%82 = or i32 %78, %81
br label %87
83: ; preds = %62
%84 = getelementptr inbounds i8, i8* %63, i64 4
%85 = add nsw i32 %64, -4
%86 = icmp sgt i32 %64, 4
br i1 %86, label %62, label %87
87: ; preds = %83, %73, %57
%88 = phi i32 [ 0, %57 ], [ %82, %73 ], [ 0, %83 ]
%89 = call i32 @close(i32 %19)
br label %90
90: ; preds = %87, %43, %30, %21
%91 = phi i32 [ -1, %21 ], [ -1, %30 ], [ -1, %43 ], [ %88, %87 ]
ret i32 %91
}