#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 BUFSIZ;
long UINT_MAX;
int /*<<< orphan*/ input_close_fd(int);
int input_open_fd(char *);
int input_read_fd(int, unsigned char *, unsigned int);
unsigned char *memchr(unsigned char *, char, size_t);
int /*<<< orphan*/ memcmp(char *, unsigned char *, int);
int /*<<< orphan*/ memcpy(char *, unsigned char *, int);
int /*<<< orphan*/ memmove(unsigned char *, unsigned char *, size_t);
long strtol(char *, int /*<<< orphan*/ *, int);
int input_read_mp4_padding(char *filename, unsigned *start, unsigned *end) {
  unsigned char buffer[BUFSIZ];
  int fd = input_open_fd(filename);
  int bytes_read, bytes_read_new;
  if (fd < 0) {
    *start = *end = 0;
    return 1;
  }
  while ((bytes_read = input_read_fd(fd, buffer, BUFSIZ)) > 0) {
    unsigned char *match_maybe = memchr(buffer, 'i', (size_t)bytes_read);
    while (match_maybe) {
      size_t good_bytes = (size_t)(buffer + bytes_read - match_maybe);
      memmove(buffer, match_maybe, good_bytes);
      bytes_read_new = input_read_fd(fd, buffer + good_bytes,
                                     (unsigned int)(BUFSIZ - good_bytes));
      if (bytes_read_new < 0)
        break;
      bytes_read = (int)good_bytes + bytes_read_new;
      if (bytes_read >= 256 && !memcmp("iTunSMPB", buffer, 8)) {
        unsigned char *space = memchr(buffer, ' ', 128);
        char gap_data[44];
        int i;
        long dummy;
        if (!space)
          break;
        memcpy(gap_data, space + 1, 44);
        for (i = 0; i < 43; ++i)
          if (gap_data[i] == ' ')
            gap_data[i] = '\0';
        gap_data[43] = '\0';
        dummy = strtol(gap_data + 9, NULL, 16);
        *start = dummy > 0 && dummy <= UINT_MAX ? (unsigned)dummy : 0;
        dummy = strtol(gap_data + 18, NULL, 16);
        *end = dummy > 0 && dummy <= UINT_MAX ? (unsigned)dummy : 0;
        input_close_fd(fd);
        return 0;
      }
      match_maybe = memchr(buffer + 1, 'i', (size_t)(bytes_read - 1));
    }
  }
  input_close_fd(fd);
  return 1;
}


x86 assembly (clang, -O0):
<input_read_mp4_padding>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0x2e3a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <input_open_fd@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1203 <input_read_mp4_padding+0x83>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x40(%rbp)
jmp    14c1 <input_read_mp4_padding+0x341>
jmp    1208 <input_read_mp4_padding+0x88>
mov    -0xa8(%rbp),%rsi
mov    -0x34(%rbp),%edi
mov    0x2dbf(%rip),%rax
mov    (%rax),%edx
call   10a0 <input_read_fd@plt>
mov    %eax,-0x38(%rbp)
cmp    $0x0,%eax
jle    14ab <input_read_mp4_padding+0x32b>
mov    -0xa8(%rbp),%rdi
movslq -0x38(%rbp),%rdx
mov    $0x69,%esi
call   1030 <memchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     14a6 <input_read_mp4_padding+0x326>
mov    -0xa8(%rbp),%rdi
movslq -0x38(%rbp),%rcx
mov    %rdi,%rax
add    %rcx,%rax
mov    -0x48(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rsi
mov    -0x50(%rbp),%rdx
call   1090 <memmove@plt>
mov    -0xa8(%rbp),%rsi
mov    -0x34(%rbp),%edi
add    -0x50(%rbp),%rsi
mov    0x2d4a(%rip),%rax
movslq (%rax),%rax
sub    -0x50(%rbp),%rax
mov    %eax,%edx
call   10a0 <input_read_fd@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    12ae <input_read_mp4_padding+0x12e>
jmp    14a6 <input_read_mp4_padding+0x326>
mov    -0x50(%rbp),%rax
add    -0x3c(%rbp),%eax
mov    %eax,-0x38(%rbp)
cmpl   $0x100,-0x38(%rbp)
jl     147f <input_read_mp4_padding+0x2ff>
mov    -0xa8(%rbp),%rsi
lea    0xd2d(%rip),%rdi
mov    $0x8,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%eax
jne    147f <input_read_mp4_padding+0x2ff>
mov    -0xa8(%rbp),%rdi
mov    $0x20,%esi
mov    $0x80,%edx
call   1030 <memchr@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1310 <input_read_mp4_padding+0x190>
jmp    14a6 <input_read_mp4_padding+0x326>
lea    -0x90(%rbp),%rdi
mov    -0x58(%rbp),%rsi
add    $0x1,%rsi
mov    $0x2c,%edx
call   1070 <memcpy@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0x2b,-0x94(%rbp)
jge    1380 <input_read_mp4_padding+0x200>
movslq -0x94(%rbp),%rax
movsbl -0x90(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    1367 <input_read_mp4_padding+0x1e7>
movslq -0x94(%rbp),%rax
movb   $0x0,-0x90(%rbp,%rax,1)
jmp    136c <input_read_mp4_padding+0x1ec>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1333 <input_read_mp4_padding+0x1b3>
movb   $0x0,-0x65(%rbp)
lea    -0x90(%rbp),%rdi
add    $0x9,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1060 <strtol@plt>
mov    %rax,-0xa0(%rbp)
cmpq   $0x0,-0xa0(%rbp)
jle    13db <input_read_mp4_padding+0x25b>
mov    -0xa0(%rbp),%rax
mov    0x2c28(%rip),%rcx
cmp    (%rcx),%rax
jg     13db <input_read_mp4_padding+0x25b>
mov    -0xa0(%rbp),%rax
mov    %eax,-0xac(%rbp)
jmp    13e8 <input_read_mp4_padding+0x268>
xor    %eax,%eax
mov    %eax,-0xac(%rbp)
jmp    13e8 <input_read_mp4_padding+0x268>
mov    -0xac(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x90(%rbp),%rdi
add    $0x12,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1060 <strtol@plt>
mov    %rax,-0xa0(%rbp)
cmpq   $0x0,-0xa0(%rbp)
jle    144b <input_read_mp4_padding+0x2cb>
mov    -0xa0(%rbp),%rax
mov    0x2bb8(%rip),%rcx
cmp    (%rcx),%rax
jg     144b <input_read_mp4_padding+0x2cb>
mov    -0xa0(%rbp),%rax
mov    %eax,-0xb0(%rbp)
jmp    1458 <input_read_mp4_padding+0x2d8>
xor    %eax,%eax
mov    %eax,-0xb0(%rbp)
jmp    1458 <input_read_mp4_padding+0x2d8>
mov    -0xb0(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x34(%rbp),%edi
call   1050 <input_close_fd@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x40(%rbp)
jmp    14c1 <input_read_mp4_padding+0x341>
mov    -0xa8(%rbp),%rdi
add    $0x1,%rdi
mov    -0x38(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rdx
mov    $0x69,%esi
call   1030 <memchr@plt>
mov    %rax,-0x48(%rbp)
jmp    1245 <input_read_mp4_padding+0xc5>
jmp    1208 <input_read_mp4_padding+0x88>
mov    -0x34(%rbp),%edi
call   1050 <input_close_fd@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x40(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<input_read_mp4_padding>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    0x2e3a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
call   1080 <input_open_fd@plt>
mov    %eax,-0x2c(%rbp)
test   %eax,%eax
js     1495 <input_read_mp4_padding+0x315>
mov    %r15,-0x68(%rbp)
mov    %r14,-0x70(%rbp)
lea    0x1(%rbx),%rax
mov    %rax,-0x78(%rbp)
xor    %r15d,%r15d
jmp    11ea <input_read_mp4_padding+0x6a>
cs nopw 0x0(%rax,%rax,1)
xor    %ecx,%ecx
test   %ecx,%ecx
jne    14b3 <input_read_mp4_padding+0x333>
mov    0x2de7(%rip),%rax
mov    (%rax),%edx
mov    -0x2c(%rbp),%edi
mov    %rbx,%rsi
call   10a0 <input_read_fd@plt>
test   %eax,%eax
jle    14a5 <input_read_mp4_padding+0x325>
mov    %eax,%r14d
mov    %eax,%edx
mov    %rbx,%rdi
mov    $0x69,%esi
call   1030 <memchr@plt>
mov    %rax,%r13
nopl   0x0(%rax,%rax,1)
test   %r13,%r13
je     11e0 <input_read_mp4_padding+0x60>
movslq %r14d,%r12
add    %rbx,%r12
sub    %r13,%r12
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1090 <memmove@plt>
lea    (%rbx,%r12,1),%rsi
mov    0x2d91(%rip),%rax
mov    (%rax),%edx
sub    %r12d,%edx
mov    -0x2c(%rbp),%edi
call   10a0 <input_read_fd@plt>
test   %eax,%eax
js     11e0 <input_read_mp4_padding+0x60>
mov    %eax,%r14d
add    %r12d,%r14d
cmp    $0x100,%r14d
jl     127f <input_read_mp4_padding+0xff>
lea    0xdb2(%rip),%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1040 <memcmp@plt>
test   %eax,%eax
je     12a2 <input_read_mp4_padding+0x122>
lea    -0x1(%r14),%eax
movslq %eax,%rdx
mov    -0x78(%rbp),%rdi
mov    $0x69,%esi
call   1030 <memchr@plt>
mov    %rax,%r13
xor    %eax,%eax
test   %eax,%eax
je     1220 <input_read_mp4_padding+0xa0>
jmp    1480 <input_read_mp4_padding+0x300>
mov    $0x80,%edx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1030 <memchr@plt>
test   %rax,%rax
je     1475 <input_read_mp4_padding+0x2f5>
add    $0x1,%rax
lea    -0x60(%rbp),%rdi
mov    %rax,%rsi
mov    $0x2c,%edx
call   1070 <memcpy@plt>
xor    %eax,%eax
movdqa 0xd24(%rip),%xmm3
movdqa 0xd2c(%rip),%xmm4
jmp    12fe <input_read_mp4_padding+0x17e>
cs nopw 0x0(%rax,%rax,1)
add    $0x8,%rax
cmp    $0x28,%rax
je     13c0 <input_read_mp4_padding+0x240>
movq   -0x60(%rbp,%rax,1),%xmm1
movdqa %xmm1,%xmm0
pcmpeqb %xmm3,%xmm0
movd   %xmm0,%ecx
test   $0x1,%cl
je     131a <input_read_mp4_padding+0x19a>
movb   $0x0,-0x60(%rbp,%rax,1)
movdqa %xmm0,%xmm2
pslld  $0x8,%xmm2
movd   %xmm2,%ecx
shr    $0x10,%ecx
test   $0x1,%cl
je     1334 <input_read_mp4_padding+0x1b4>
movb   $0x0,-0x5f(%rbp,%rax,1)
pshuflw $0x55,%xmm1,%xmm2
pcmpeqb %xmm3,%xmm2
pextrw $0x2,%xmm2,%ecx
test   $0x1,%cl
je     134c <input_read_mp4_padding+0x1cc>
movb   $0x0,-0x5e(%rbp,%rax,1)
movdqa %xmm0,%xmm2
psllq  $0x18,%xmm2
pextrw $0x3,%xmm2,%ecx
test   $0x1,%cl
je     1364 <input_read_mp4_padding+0x1e4>
movb   $0x0,-0x5d(%rbp,%rax,1)
pshufd $0x55,%xmm1,%xmm1
pcmpeqb %xmm4,%xmm1
pextrw $0x4,%xmm1,%ecx
test   $0x1,%cl
je     137c <input_read_mp4_padding+0x1fc>
movb   $0x0,-0x5c(%rbp,%rax,1)
movdqa %xmm0,%xmm1
pslldq $0x5,%xmm1
pextrw $0x5,%xmm1,%ecx
test   $0x1,%cl
je     1394 <input_read_mp4_padding+0x214>
movb   $0x0,-0x5b(%rbp,%rax,1)
pextrw $0x3,%xmm0,%ecx
test   $0x1,%cl
je     13a3 <input_read_mp4_padding+0x223>
movb   $0x0,-0x5a(%rbp,%rax,1)
pslldq $0x7,%xmm0
pextrw $0x7,%xmm0,%ecx
test   $0x1,%cl
je     12f0 <input_read_mp4_padding+0x170>
movb   $0x0,-0x59(%rbp,%rax,1)
jmp    12f0 <input_read_mp4_padding+0x170>
cmpb   $0x20,-0x38(%rbp)
jne    1458 <input_read_mp4_padding+0x2d8>
movb   $0x0,-0x38(%rbp)
cmpb   $0x20,-0x37(%rbp)
je     1462 <input_read_mp4_padding+0x2e2>
cmpb   $0x20,-0x36(%rbp)
jne    13e2 <input_read_mp4_padding+0x262>
movb   $0x0,-0x36(%rbp)
movb   $0x0,-0x35(%rbp)
lea    -0x57(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <strtol@plt>
mov    0x2beb(%rip),%rcx
cmp    (%rcx),%rax
mov    %eax,%ecx
mov    $0x0,%r12d
cmovg  %r12d,%ecx
test   %rax,%rax
cmovle %r12d,%ecx
mov    -0x70(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x4e(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <strtol@plt>
mov    0x2bb8(%rip),%rcx
cmp    (%rcx),%rax
mov    %eax,%ecx
cmovg  %r12d,%ecx
test   %rax,%rax
cmovle %r12d,%ecx
mov    -0x68(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%edi
call   1050 <input_close_fd@plt>
mov    $0x1,%eax
jmp    1299 <input_read_mp4_padding+0x119>
cmpb   $0x20,-0x37(%rbp)
jne    13d8 <input_read_mp4_padding+0x258>
movb   $0x0,-0x37(%rbp)
cmpb   $0x20,-0x36(%rbp)
je     13de <input_read_mp4_padding+0x25e>
jmp    13e2 <input_read_mp4_padding+0x262>
mov    $0x5,%eax
jmp    1299 <input_read_mp4_padding+0x119>
nop
mov    $0x0,%ecx
cmp    $0x5,%eax
je     11e2 <input_read_mp4_padding+0x62>
mov    %eax,%ecx
jmp    11e2 <input_read_mp4_padding+0x62>
movl   $0x0,(%r15)
movl   $0x0,(%r14)
jmp    14ad <input_read_mp4_padding+0x32d>
mov    -0x2c(%rbp),%edi
call   1050 <input_close_fd@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [9 x i8] c"iTunSMPB\00"
@UINT_MAX = global i64 0
define i32 @input_read_mp4_padding(i8* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i8*
%17 = alloca [44 x i8]
%18 = alloca i32
%19 = alloca i64
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%20 = load i32, i32* @BUFSIZ
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %8
%23 = alloca i8, i64 %21
store i64 %21, i64* %9
%24 = load i8*, i8** %5
%25 = call i32 @input_open_fd(i8* %24)
store i32 %25, i32* %10
%26 = load i32, i32* %10
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %3
%29 = load i32*, i32** %7
store i32 0, i32* %29
%30 = load i32*, i32** %6
store i32 0, i32* %30
store i32 1, i32* %4
store i32 1, i32* %13
br label %151
31: ; preds = %3
br label %32
32: ; preds = %147, %31
%33 = load i32, i32* %10
%34 = load i32, i32* @BUFSIZ
%35 = call i32 @input_read_fd(i32 %33, i8* %23, i32 %34)
store i32 %35, i32* %11
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %148
37: ; preds = %32
%38 = load i32, i32* %11
%39 = sext i32 %38 to i64
%40 = call i8* @memchr(i8* %23, i8 signext 105, i64 %39)
store i8* %40, i8** %14
br label %41
41: ; preds = %141, %37
%42 = load i8*, i8** %14
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %147
44: ; preds = %41
%45 = load i32, i32* %11
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %23, i64 %46
%48 = load i8*, i8** %14
%49 = ptrtoint i8* %47 to i64
%50 = ptrtoint i8* %48 to i64
%51 = sub i64 %49, %50
store i64 %51, i64* %15
%52 = load i8*, i8** %14
%53 = load i64, i64* %15
%54 = call i32 @memmove(i8* %23, i8* %52, i64 %53)
%55 = load i32, i32* %10
%56 = load i64, i64* %15
%57 = getelementptr inbounds i8, i8* %23, i64 %56
%58 = load i32, i32* @BUFSIZ
%59 = sext i32 %58 to i64
%60 = load i64, i64* %15
%61 = sub i64 %59, %60
%62 = trunc i64 %61 to i32
%63 = call i32 @input_read_fd(i32 %55, i8* %57, i32 %62)
store i32 %63, i32* %12
%64 = load i32, i32* %12
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %44
br label %147
67: ; preds = %44
%68 = load i64, i64* %15
%69 = trunc i64 %68 to i32
%70 = load i32, i32* %12
%71 = add nsw i32 %69, %70
store i32 %71, i32* %11
%72 = load i32, i32* %11
%73 = icmp sge i32 %72, 256
br i1 %73, label %74, label %141
74: ; preds = %67
%75 = call i32 @memcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %23, i32 8)
%76 = icmp ne i32 %75, 0
br i1 %76, label %141, label %77
77: ; preds = %74
%78 = call i8* @memchr(i8* %23, i8 signext 32, i64 128)
store i8* %78, i8** %16
%79 = load i8*, i8** %16
%80 = icmp ne i8* %79, null
br i1 %80, label %82, label %81
81: ; preds = %77
br label %147
82: ; preds = %77
%83 = getelementptr inbounds [44 x i8], [44 x i8]* %17, i64 0, i64 0
%84 = load i8*, i8** %16
%85 = getelementptr inbounds i8, i8* %84, i64 1
%86 = call i32 @memcpy(i8* %83, i8* %85, i32 44)
store i32 0, i32* %18
br label %87
87: ; preds = %102, %82
%88 = load i32, i32* %18
%89 = icmp slt i32 %88, 43
br i1 %89, label %90, label %105
90: ; preds = %87
%91 = load i32, i32* %18
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [44 x i8], [44 x i8]* %17, i64 0, i64 %92
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 32
br i1 %96, label %97, label %101
97: ; preds = %90
%98 = load i32, i32* %18
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [44 x i8], [44 x i8]* %17, i64 0, i64 %99
store i8 0, i8* %100
br label %101
101: ; preds = %97, %90
br label %102
102: ; preds = %101
%103 = load i32, i32* %18
%104 = add nsw i32 %103, 1
store i32 %104, i32* %18
br label %87
105: ; preds = %87
%106 = getelementptr inbounds [44 x i8], [44 x i8]* %17, i64 0, i64 43
store i8 0, i8* %106
%107 = getelementptr inbounds [44 x i8], [44 x i8]* %17, i64 0, i64 0
%108 = getelementptr inbounds i8, i8* %107, i64 9
%109 = call i64 @strtol(i8* %108, i32* null, i32 16)
store i64 %109, i64* %19
%110 = load i64, i64* %19
%111 = icmp sgt i64 %110, 0
br i1 %111, label %112, label %119
112: ; preds = %105
%113 = load i64, i64* %19
%114 = load i64, i64* @UINT_MAX
%115 = icmp sle i64 %113, %114
br i1 %115, label %116, label %119
116: ; preds = %112
%117 = load i64, i64* %19
%118 = trunc i64 %117 to i32
br label %120
119: ; preds = %112, %105
br label %120
120: ; preds = %119, %116
%121 = phi i32 [ %118, %116 ], [ 0, %119 ]
%122 = load i32*, i32** %6
store i32 %121, i32* %122
%123 = getelementptr inbounds [44 x i8], [44 x i8]* %17, i64 0, i64 0
%124 = getelementptr inbounds i8, i8* %123, i64 18
%125 = call i64 @strtol(i8* %124, i32* null, i32 16)
store i64 %125, i64* %19
%126 = load i64, i64* %19
%127 = icmp sgt i64 %126, 0
br i1 %127, label %128, label %135
128: ; preds = %120
%129 = load i64, i64* %19
%130 = load i64, i64* @UINT_MAX
%131 = icmp sle i64 %129, %130
br i1 %131, label %132, label %135
132: ; preds = %128
%133 = load i64, i64* %19
%134 = trunc i64 %133 to i32
br label %136
135: ; preds = %128, %120
br label %136
136: ; preds = %135, %132
%137 = phi i32 [ %134, %132 ], [ 0, %135 ]
%138 = load i32*, i32** %7
store i32 %137, i32* %138
%139 = load i32, i32* %10
%140 = call i32 @input_close_fd(i32 %139)
store i32 0, i32* %4
store i32 1, i32* %13
br label %151
141: ; preds = %74, %67
%142 = getelementptr inbounds i8, i8* %23, i64 1
%143 = load i32, i32* %11
%144 = sub nsw i32 %143, 1
%145 = sext i32 %144 to i64
%146 = call i8* @memchr(i8* %142, i8 signext 105, i64 %145)
store i8* %146, i8** %14
br label %41
147: ; preds = %81, %66, %41
br label %32
148: ; preds = %32
%149 = load i32, i32* %10
%150 = call i32 @input_close_fd(i32 %149)
store i32 1, i32* %4
store i32 1, i32* %13
br label %151
151: ; preds = %148, %136, %28
%152 = load i8*, i8** %8
%153 = load i32, i32* %4
ret i32 %153
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [9 x i8] c"iTunSMPB\00"
@UINT_MAX = global i64 0
define i32 @input_read_mp4_padding(i8* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = alloca [44 x i8]
%5 = load i32, i32* @BUFSIZ
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = tail call i32 @input_open_fd(i8* %0)
%9 = icmp slt i32 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %3
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 43
%14 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 9
%15 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 18
%16 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 40
%17 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 41
%18 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 42
br label %20
19: ; preds = %3
store i32 0, i32* %2
store i32 0, i32* %1
br label %146
20: ; preds = %10, %141
%21 = load i32, i32* @BUFSIZ
%22 = call i32 @input_read_fd(i32 %8, i8* %7, i32 %21)
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %144
24: ; preds = %20
%25 = zext i32 %22 to i64
%26 = call i8* @memchr(i8* %7, i8 signext 105, i64 %25)
br label %27
27: ; preds = %137, %24
%28 = phi i8* [ %26, %24 ], [ %139, %137 ]
%29 = phi i32 [ %22, %24 ], [ %45, %137 ]
%30 = icmp eq i8* %28, null
br i1 %30, label %141, label %31
31: ; preds = %27
%32 = sext i32 %29 to i64
%33 = getelementptr inbounds i8, i8* %7, i64 %32
%34 = ptrtoint i8* %33 to i64
%35 = ptrtoint i8* %28 to i64
%36 = sub i64 %34, %35
%37 = call i32 @memmove(i8* %7, i8* %28, i64 %36)
%38 = getelementptr inbounds i8, i8* %7, i64 %36
%39 = load i32, i32* @BUFSIZ
%40 = trunc i64 %36 to i32
%41 = sub i32 %39, %40
%42 = call i32 @input_read_fd(i32 %8, i8* %38, i32 %41)
%43 = icmp slt i32 %42, 0
br i1 %43, label %141, label %44
44: ; preds = %31
%45 = add nsw i32 %42, %40
%46 = icmp sgt i32 %45, 255
br i1 %46, label %47, label %133
47: ; preds = %44
%48 = call i32 @memcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %7, i32 8)
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %133
50: ; preds = %47
%51 = call i8* @memchr(i8* %7, i8 signext 32, i64 128)
%52 = icmp eq i8* %51, null
br i1 %52, label %131, label %53
53: ; preds = %50
%54 = getelementptr inbounds i8, i8* %51, i64 1
%55 = call i32 @memcpy(i8* %12, i8* %54, i32 44)
br label %56
56: ; preds = %100, %53
%57 = phi i64 [ 0, %53 ], [ %101, %100 ]
%58 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 %57
%59 = bitcast i8* %58 to <8 x i8>*
%60 = load <8 x i8>, <8 x i8>* %59
%61 = icmp eq <8 x i8> %60, <i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32>
%62 = extractelement <8 x i1> %61, i64 0
br i1 %62, label %63, label %65
63: ; preds = %56
%64 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 %57
store i8 0, i8* %64
br label %65
65: ; preds = %63, %56
%66 = extractelement <8 x i1> %61, i64 1
br i1 %66, label %67, label %70
67: ; preds = %65
%68 = or i64 %57, 1
%69 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 %68
store i8 0, i8* %69
br label %70
70: ; preds = %67, %65
%71 = extractelement <8 x i1> %61, i64 2
br i1 %71, label %72, label %75
72: ; preds = %70
%73 = or i64 %57, 2
%74 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 %73
store i8 0, i8* %74
br label %75
75: ; preds = %72, %70
%76 = extractelement <8 x i1> %61, i64 3
br i1 %76, label %77, label %80
77: ; preds = %75
%78 = or i64 %57, 3
%79 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 %78
store i8 0, i8* %79
br label %80
80: ; preds = %77, %75
%81 = extractelement <8 x i1> %61, i64 4
br i1 %81, label %82, label %85
82: ; preds = %80
%83 = or i64 %57, 4
%84 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 %83
store i8 0, i8* %84
br label %85
85: ; preds = %82, %80
%86 = extractelement <8 x i1> %61, i64 5
br i1 %86, label %87, label %90
87: ; preds = %85
%88 = or i64 %57, 5
%89 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 %88
store i8 0, i8* %89
br label %90
90: ; preds = %87, %85
%91 = extractelement <8 x i1> %61, i64 6
br i1 %91, label %92, label %95
92: ; preds = %90
%93 = or i64 %57, 6
%94 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 %93
store i8 0, i8* %94
br label %95
95: ; preds = %92, %90
%96 = extractelement <8 x i1> %61, i64 7
br i1 %96, label %97, label %100
97: ; preds = %95
%98 = or i64 %57, 7
%99 = getelementptr inbounds [44 x i8], [44 x i8]* %4, i64 0, i64 %98
store i8 0, i8* %99
br label %100
100: ; preds = %97, %95
%101 = add nuw i64 %57, 8
%102 = icmp eq i64 %101, 40
br i1 %102, label %103, label %56
103: ; preds = %100
%104 = load i8, i8* %16
%105 = icmp eq i8 %104, 32
br i1 %105, label %106, label %107
106: ; preds = %103
store i8 0, i8* %16
br label %107
107: ; preds = %103, %106
%108 = load i8, i8* %17
%109 = icmp eq i8 %108, 32
br i1 %109, label %110, label %111
110: ; preds = %107
store i8 0, i8* %17
br label %111
111: ; preds = %110, %107
%112 = load i8, i8* %18
%113 = icmp eq i8 %112, 32
br i1 %113, label %114, label %115
114: ; preds = %111
store i8 0, i8* %18
br label %115
115: ; preds = %114, %111
store i8 0, i8* %13
%116 = call i64 @strtol(i8* nocapture %14, i32* null, i32 16)
%117 = icmp slt i64 %116, 1
%118 = load i64, i64* @UINT_MAX
%119 = icmp sgt i64 %116, %118
%120 = select i1 %117, i1 true, i1 %119
%121 = trunc i64 %116 to i32
%122 = select i1 %120, i32 0, i32 %121
store i32 %122, i32* %1
%123 = call i64 @strtol(i8* nocapture %15, i32* null, i32 16)
%124 = icmp slt i64 %123, 1
%125 = load i64, i64* @UINT_MAX
%126 = icmp sgt i64 %123, %125
%127 = select i1 %124, i1 true, i1 %126
%128 = trunc i64 %123 to i32
%129 = select i1 %127, i32 0, i32 %128
store i32 %129, i32* %2
%130 = call i32 @input_close_fd(i32 %8)
br label %131
131: ; preds = %50, %115
%132 = phi i32 [ 1, %115 ], [ 5, %50 ]
br label %137
133: ; preds = %47, %44
%134 = add nsw i32 %45, -1
%135 = sext i32 %134 to i64
%136 = call i8* @memchr(i8* %11, i8 signext 105, i64 %135)
br label %137
137: ; preds = %133, %131
%138 = phi i32 [ 0, %133 ], [ %132, %131 ]
%139 = phi i8* [ %136, %133 ], [ %28, %131 ]
switch i32 %138, label %140 [
i32 0, label %27
i32 5, label %141
]
140: ; preds = %137
br label %141
141: ; preds = %27, %137, %31, %140
%142 = phi i32 [ %138, %140 ], [ 0, %31 ], [ 0, %137 ], [ 0, %27 ]
%143 = icmp eq i32 %142, 0
br i1 %143, label %20, label %146
144: ; preds = %20
%145 = call i32 @input_close_fd(i32 %8)
br label %146
146: ; preds = %141, %144, %19
%147 = phi i32 [ 1, %19 ], [ 1, %144 ], [ 0, %141 ]
ret i32 %147
}