#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_RDONLY;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ lseek(int, int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ read(int, int *, int);
int main(int argc, char **argv) {
  if (argc < 2) {
    puts("Give video path as argument.");
    return -1;
  }
  char *meta[13] = {"time delay between frames in ms",
                    "data rate of avi data",
                    "padding multiple size, typically 2048",
                    "parameter flags",
                    "number of video frames",
                    "number of preview frames",
                    "number of data streams (1 or 2)",
                    "suggested playback buffer size in bytes",
                    "width of video image in pixels",
                    "height of video image in pixels",
                    "time scale, typically 30",
                    "data rate (frame rate = data rate / time scale)",
                    "starting time, typically 0"};
  int fd = open(argv[1], O_RDONLY);
  if (fd < 0) {
    puts("File error");
    return -1;
  }
  printf("\n*************** %s ***************\n\n", argv[1]);
  if (sizeof(int) != 4) {
    puts("Int is not 4 bytes on this machine");
    return -1;
  }
  int i, pos;
  int val;
  pos = fd;
  for (i = 32; i <= (80); i += 4) {
    lseek(pos, i, SEEK_SET);
    read(pos, &val, sizeof(int));
    printf("%-10d %s\n", val, meta[(i - 32) / 4]);
  }
  printf("\n***************************************************\n");
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11ab <main+0x3b>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12cb <main+0x15b>
lea    -0x80(%rbp),%rdi
lea    0x2bea(%rip),%rsi
mov    $0x68,%edx
call   1080 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e11(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jge    1201 <main+0x91>
lea    0xfb4(%rip),%rdi
call   1030 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12cb <main+0x15b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xf9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x84(%rbp),%eax
mov    %eax,-0x8c(%rbp)
movl   $0x20,-0x88(%rbp)
cmpl   $0x50,-0x88(%rbp)
jg     12ab <main+0x13b>
mov    -0x8c(%rbp),%edi
mov    -0x88(%rbp),%esi
mov    0x2d83(%rip),%rax
mov    (%rax),%edx
call   1050 <lseek@plt>
mov    -0x8c(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0x4,%edx
call   1070 <read@plt>
mov    -0x90(%rbp),%esi
mov    -0x88(%rbp),%eax
sub    $0x20,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cltq
mov    -0x80(%rbp,%rax,8),%rdx
lea    0xf45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x88(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x88(%rbp)
jmp    122d <main+0xbd>
lea    0xf2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x84(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     117c <main+0x1c>
lea    0xe89(%rip),%rdi
jmp    1249 <main+0xe9>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
mov    0x2e5e(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
test   %eax,%eax
js     1242 <main+0xe2>
mov    %eax,%ebx
mov    0x8(%rbp),%rsi
lea    0x1009(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1c,%r12d
lea    0x4(%rsp),%r14
lea    0x1055(%rip),%r13
lea    0x100f(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
lea    0x4(%r12),%ebp
mov    0x2dfc(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %ebp,%esi
call   1050 <lseek@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1070 <read@plt>
mov    0x4(%rsp),%esi
add    $0xe4,%r12b
mov    %r12d,%eax
sar    $0x7,%al
shr    $0x6,%al
add    %r12b,%al
sar    $0x2,%al
movsbq %al,%rax
movslq 0x0(%r13,%rax,4),%rdx
add    %r13,%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%r12d
cmp    $0x4d,%ebp
jb     11d0 <main+0x70>
lea    0xfad(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
jmp    1253 <main+0xf3>
lea    0xf5b(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Give video path as argument.\00"
@.str.1 = [32 x i8] c"time delay between frames in ms\00"
@.str.2 = [22 x i8] c"data rate of avi data\00"
@.str.3 = [38 x i8] c"padding multiple size, typically 2048\00"
@.str.4 = [16 x i8] c"parameter flags\00"
@.str.5 = [23 x i8] c"number of video frames\00"
@.str.6 = [25 x i8] c"number of preview frames\00"
@.str.7 = [32 x i8] c"number of data streams (1 or 2)\00"
@.str.8 = [40 x i8] c"suggested playback buffer size in bytes\00"
@.str.9 = [31 x i8] c"width of video image in pixels\00"
@.str.10 = [32 x i8] c"height of video image in pixels\00"
@.str.11 = [25 x i8] c"time scale, typically 30\00"
@.str.12 = [48 x i8] c"data rate (frame rate = data rate / time scale)\00"
@.str.13 = [27 x i8] c"starting time, typically 0\00"
@__const.main.meta = [13 x i8*] [i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i32 0, i32 0)]
@O_RDONLY = global i32 0
@.str.14 = [11 x i8] c"File error\00"
@.str.15 = [38 x i8] c"\0A*************** %s ***************\0A\0A\00"
@SEEK_SET = global i32 0
@.str.16 = [10 x i8] c"%-10d %s\0A\00"
@.str.17 = [54 x i8] c"\0A***************************************************\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [13 x i8*]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %57
15: ; preds = %2
%16 = bitcast [13 x i8*]* %6 to i8*
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = load i32, i32* @O_RDONLY
%21 = call i32 @open(i8* %19, i32 %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %15
%25 = call i32 @puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
store i32 -1, i32* %3
br label %57
26: ; preds = %15
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.15, i64 0, i64 0), i8* %29)
%31 = load i32, i32* %7
store i32 %31, i32* %9
store i32 32, i32* %8
br label %32
32: ; preds = %50, %26
%33 = load i32, i32* %8
%34 = icmp sle i32 %33, 80
br i1 %34, label %35, label %53
35: ; preds = %32
%36 = load i32, i32* %9
%37 = load i32, i32* %8
%38 = load i32, i32* @SEEK_SET
%39 = call i32 @lseek(i32 %36, i32 %37, i32 %38)
%40 = load i32, i32* %9
%41 = call i32 @read(i32 %40, i32* %10, i32 4)
%42 = load i32, i32* %10
%43 = load i32, i32* %8
%44 = sub nsw i32 %43, 32
%45 = sdiv i32 %44, 4
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [13 x i8*], [13 x i8*]* %6, i64 0, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0), i32 %42, i8* %48)
br label %50
50: ; preds = %35
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 4
store i32 %52, i32* %8
br label %32
53: ; preds = %32
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.17, i64 0, i64 0))
%55 = load i32, i32* %7
%56 = call i32 @close(i32 %55)
store i32 0, i32* %3
br label %57
57: ; preds = %53, %24, %13
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@.str = [29 x i8] c"Give video path as argument.\00"
@.str.1 = [32 x i8] c"time delay between frames in ms\00"
@.str.2 = [22 x i8] c"data rate of avi data\00"
@.str.3 = [38 x i8] c"padding multiple size, typically 2048\00"
@.str.4 = [16 x i8] c"parameter flags\00"
@.str.5 = [23 x i8] c"number of video frames\00"
@.str.6 = [25 x i8] c"number of preview frames\00"
@.str.7 = [32 x i8] c"number of data streams (1 or 2)\00"
@.str.8 = [40 x i8] c"suggested playback buffer size in bytes\00"
@.str.9 = [31 x i8] c"width of video image in pixels\00"
@.str.10 = [32 x i8] c"height of video image in pixels\00"
@.str.11 = [25 x i8] c"time scale, typically 30\00"
@.str.12 = [48 x i8] c"data rate (frame rate = data rate / time scale)\00"
@.str.13 = [27 x i8] c"starting time, typically 0\00"
@reltable.main = [13 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([32 x i8]* @.str.1 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([38 x i8]* @.str.3 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.4 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.5 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.6 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([32 x i8]* @.str.7 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([40 x i8]* @.str.8 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @.str.9 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([32 x i8]* @.str.10 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.11 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([48 x i8]* @.str.12 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.13 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32)]
@O_RDONLY = global i32 0
@.str.14 = [11 x i8] c"File error\00"
@.str.15 = [38 x i8] c"\0A*************** %s ***************\0A\0A\00"
@SEEK_SET = global i32 0
@.str.16 = [10 x i8] c"%-10d %s\0A\00"
@str = [53 x i8] c"\0A***************************************************\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %37
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = load i32, i32* @O_RDONLY
%11 = tail call i32 @open(i8* %9, i32 %10)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
br label %37
15: ; preds = %7
%16 = load i8*, i8** %8
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.15, i64 0, i64 0), i8* %16)
%18 = bitcast i32* %3 to i8*
br label %19
19: ; preds = %15, %19
%20 = phi i32 [ 32, %15 ], [ %32, %19 ]
%21 = load i32, i32* @SEEK_SET
%22 = tail call i32 @lseek(i32 %11, i32 %20, i32 %21)
%23 = call i32 @read(i32 %11, i32* %3, i32 4)
%24 = load i32, i32* %3
%25 = trunc i32 %20 to i8
%26 = add nsw i8 %25, -32
%27 = sdiv i8 %26, 4
%28 = sext i8 %27 to i64
%29 = shl i64 %28, 2
%30 = call i8* @llvm.load.relative.i64(i8* bitcast ([13 x i32]* @reltable.main to i8*), i64 %29)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0), i32 %24, i8* %30)
%32 = add nuw nsw i32 %20, 4
%33 = icmp ult i32 %20, 77
br i1 %33, label %19, label %34
34: ; preds = %19
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
%36 = tail call i32 @close(i32 %11)
br label %37
37: ; preds = %13, %34, %5
%38 = phi i32 [ -1, %5 ], [ -1, %13 ], [ 0, %34 ]
ret i32 %38
}