#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int, unsigned int,
                          unsigned int, unsigned int, unsigned int,
                          unsigned int, unsigned int, unsigned int);
int /*<<< orphan*/ sleep(int);
int sscanf(char *, char *, unsigned int *);
int main(int argc, char **argv) {
  FILE *f;
  char *s = (char *)malloc(128);
  unsigned int pic_pts = 0, aud_pts = 0;
  unsigned int pic_ms, aud_ms, tmp;
  while (1) {
    f = fopen("/proc/bus/bitstream", "r");
    while ((s = fgets(s, 128, f))) {
      if (sscanf(s, "MR_PIC_PTS: 0x%x", &tmp) == 1) {
        pic_pts = tmp;
      } else if (sscanf(s, "MR_AUD_PTS: 0x%x", &tmp) == 1) {
        aud_pts = tmp;
        break;
      }
    }
    pic_ms = pic_pts / 45;
    aud_ms = aud_pts / 45;
    fclose(f);
    printf("pic_pts: %02d:%02d:%02d.%03d aud_pts: %02d:%02d:%02d.%03d, diff "
           "(ms): %d\n",
           pic_ms / 3600000, (pic_ms / 60000) % 60, ((pic_ms) / 1000) % 60,
           pic_ms % 1000, aud_ms / 3600000, (aud_ms / 60000) % 60,
           ((aud_ms) / 1000) % 60, aud_ms % 1000, pic_ms - aud_ms);
    sleep(1);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x58,%rsp
movl   $0x0,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xe56(%rip),%rdi
lea    0xe63(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x80,%esi
call   1050 <fgets@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1234 <main+0xc4>
mov    -0x28(%rbp),%rdi
lea    0xe31(%rip),%rsi
lea    -0x3c(%rbp),%rdx
call   1070 <sscanf@plt>
cmp    $0x1,%eax
jne    1202 <main+0x92>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    122f <main+0xbf>
mov    -0x28(%rbp),%rdi
lea    0xe1a(%rip),%rsi
lea    -0x3c(%rbp),%rdx
call   1070 <sscanf@plt>
cmp    $0x1,%eax
jne    122a <main+0xba>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    1234 <main+0xc4>
jmp    122f <main+0xbf>
jmp    11ba <main+0x4a>
mov    -0x2c(%rbp),%eax
mov    $0x2d,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%eax
mov    $0x2d,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x34(%rbp),%eax
mov    $0x36ee80,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%esi
mov    -0x34(%rbp),%eax
mov    $0xea60,%ecx
xor    %edx,%edx
div    %ecx
mov    $0x3c,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x40(%rbp)
mov    -0x34(%rbp),%eax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %ecx
mov    $0x3c,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%ecx
mov    -0x34(%rbp),%eax
mov    $0x3e8,%edi
xor    %edx,%edx
div    %edi
mov    %edx,%r8d
mov    -0x38(%rbp),%eax
mov    $0x36ee80,%edi
xor    %edx,%edx
div    %edi
mov    %eax,%r9d
mov    -0x38(%rbp),%eax
mov    $0xea60,%edi
xor    %edx,%edx
div    %edi
mov    $0x3c,%edi
xor    %edx,%edx
div    %edi
mov    %edx,%ebx
mov    -0x38(%rbp),%eax
mov    $0x3e8,%edi
xor    %edx,%edx
div    %edi
mov    $0x3c,%edi
xor    %edx,%edx
div    %edi
mov    %edx,%r11d
mov    -0x38(%rbp),%eax
mov    $0x3e8,%edi
xor    %edx,%edx
div    %edi
mov    %edx,%r10d
mov    -0x40(%rbp),%edx
mov    -0x34(%rbp),%eax
sub    -0x38(%rbp),%eax
lea    0xd34(%rip),%rdi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
jmp    11a3 <main+0x33>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x80,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
xor    %eax,%eax
mov    %rax,0x10(%rsp)
lea    0xe7d(%rip),%rbx
lea    0x8(%rsp),%rbp
lea    0xe82(%rip),%r12
xor    %r13d,%r13d
jmp    12fd <main+0x18d>
nopl   (%rax)
xor    %r14d,%r14d
mov    %r13d,0xc(%rsp)
mov    %r13d,%ebx
imul   $0x6c16c16d,%rbx,%rax
shr    $0x20,%rax
mov    %r13d,%ebp
sub    %eax,%ebp
shr    %ebp
add    %eax,%ebp
shr    $0x5,%ebp
mov    0x10(%rsp),%r13
mov    %r13,0x10(%rsp)
mov    %r13d,%r12d
imul   $0x6c16c16d,%r12,%rax
shr    $0x20,%rax
sub    %eax,%r13d
shr    %r13d
add    %eax,%r13d
shr    $0x5,%r13d
mov    %r15,%rdi
call   1030 <fclose@plt>
imul   $0x6a0c6f6d,%rbx,%rsi
shr    $0x3a,%rsi
imul   $0x31b5d43b,%rbx,%rax
shr    $0x33,%rax
imul   $0x8889,%eax,%ecx
shr    $0x15,%ecx
imul   $0x3c,%ecx,%ecx
sub    %ecx,%eax
movzwl %ax,%edx
mov    0xc(%rsp),%eax
shr    $0x3,%eax
imul   $0x5d34edf,%rax,%rcx
shr    $0x27,%rcx
mov    %rcx,%rax
mov    $0x88888889,%r10d
imul   %r10,%rax
shr    $0x25,%rax
imul   $0x3c,%eax,%eax
sub    %eax,%ecx
imul   $0x10624dd3,%rbp,%rax
shr    $0x26,%rax
imul   $0x3e8,%eax,%eax
mov    %ebp,%r8d
sub    %eax,%r8d
imul   $0x6a0c6f6d,%r12,%r9
shr    $0x3a,%r9
imul   $0x31b5d43b,%r12,%rax
shr    $0x33,%rax
imul   $0x8889,%eax,%edi
shr    $0x15,%edi
imul   $0x3c,%edi,%edi
sub    %edi,%eax
movzwl %ax,%eax
mov    0x10(%rsp),%rdi
shr    $0x3,%edi
imul   $0x5d34edf,%rdi,%rbx
shr    $0x27,%rbx
mov    %rbx,%rdi
imul   %r10,%rdi
shr    $0x25,%rdi
imul   $0x3c,%edi,%edi
sub    %edi,%ebx
imul   $0x10624dd3,%r13,%rdi
shr    $0x26,%rdi
imul   $0x3e8,%edi,%edi
sub    %r13d,%ebp
sub    %edi,%r13d
lea    0xd6b(%rip),%rdi
push   %rbp
push   %r13
mov    0x1c(%rsp),%r13d
push   %rbx
push   %rax
call   1040 <printf@plt>
add    $0x20,%rsp
mov    $0x1,%edi
call   1090 <sleep@plt>
lea    0xd25(%rip),%rbx
lea    0x8(%rsp),%rbp
lea    0xd2a(%rip),%r12
lea    0xcfc(%rip),%rdi
lea    0xd09(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    $0x80,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11b0 <main+0x40>
mov    %rax,%r14
jmp    1361 <main+0x1f1>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%r13d
mov    %r14,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
mov    %rax,%r14
test   %rax,%rax
je     11b0 <main+0x40>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1070 <sscanf@plt>
cmp    $0x1,%eax
je     1340 <main+0x1d0>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1070 <sscanf@plt>
cmp    $0x1,%eax
jne    1345 <main+0x1d5>
mov    0x8(%rsp),%eax
mov    %rax,0x10(%rsp)
jmp    11b3 <main+0x43>

LLVM IR (-O0):
@.str = [20 x i8] c"/proc/bus/bitstream\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"MR_PIC_PTS: 0x%x\00"
@.str.3 = [17 x i8] c"MR_AUD_PTS: 0x%x\00"
@.str.4 = [74 x i8] c"pic_pts: %02d:%02d:%02d.%03d aud_pts: %02d:%02d:%02d.%03d, diff (ms): %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i64 @malloc(i32 128)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %7
store i32 0, i32* %8
store i32 0, i32* %9
br label %15
15: ; preds = %2, %36
%16 = call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %6
br label %17
17: ; preds = %35, %15
%18 = load i8*, i8** %7
%19 = load i32*, i32** %6
%20 = call i8* @fgets(i8* %18, i32 128, i32* %19)
store i8* %20, i8** %7
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %36
22: ; preds = %17
%23 = load i8*, i8** %7
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32* %12)
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = load i32, i32* %12
store i32 %27, i32* %8
br label %35
28: ; preds = %22
%29 = load i8*, i8** %7
%30 = call i32 @sscanf(i8* %29, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32* %12)
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load i32, i32* %12
store i32 %33, i32* %9
br label %36
34: ; preds = %28
br label %35
35: ; preds = %34, %26
br label %17
36: ; preds = %32, %17
%37 = load i32, i32* %8
%38 = udiv i32 %37, 45
store i32 %38, i32* %10
%39 = load i32, i32* %9
%40 = udiv i32 %39, 45
store i32 %40, i32* %11
%41 = load i32*, i32** %6
%42 = call i32 @fclose(i32* %41)
%43 = load i32, i32* %10
%44 = udiv i32 %43, 3600000
%45 = load i32, i32* %10
%46 = udiv i32 %45, 60000
%47 = urem i32 %46, 60
%48 = load i32, i32* %10
%49 = udiv i32 %48, 1000
%50 = urem i32 %49, 60
%51 = load i32, i32* %10
%52 = urem i32 %51, 1000
%53 = load i32, i32* %11
%54 = udiv i32 %53, 3600000
%55 = load i32, i32* %11
%56 = udiv i32 %55, 60000
%57 = urem i32 %56, 60
%58 = load i32, i32* %11
%59 = udiv i32 %58, 1000
%60 = urem i32 %59, 60
%61 = load i32, i32* %11
%62 = urem i32 %61, 1000
%63 = load i32, i32* %10
%64 = load i32, i32* %11
%65 = sub i32 %63, %64
%66 = call i32 @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.4, i64 0, i64 0), i32 %44, i32 %47, i32 %50, i32 %52, i32 %54, i32 %57, i32 %60, i32 %62, i32 %65)
%67 = call i32 @sleep(i32 1)
br label %15
}

LLVM IR (-O2):
@.str = [20 x i8] c"/proc/bus/bitstream\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"MR_PIC_PTS: 0x%x\00"
@.str.3 = [17 x i8] c"MR_AUD_PTS: 0x%x\00"
@.str.4 = [74 x i8] c"pic_pts: %02d:%02d:%02d.%03d aud_pts: %02d:%02d:%02d.%03d, diff (ms): %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = tail call i64 @malloc(i32 128)
%5 = inttoptr i64 %4 to i8*
%6 = bitcast i32* %3 to i8*
br label %7
7: ; preds = %30, %2
%8 = phi i32 [ 0, %2 ], [ %33, %30 ]
%9 = phi i32 [ 0, %2 ], [ %31, %30 ]
%10 = phi i8* [ %5, %2 ], [ %32, %30 ]
%11 = call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = call i8* @fgets(i8* %10, i32 128, i32* %11)
%13 = icmp eq i8* %12, null
br i1 %13, label %30, label %14
14: ; preds = %7, %26
%15 = phi i8* [ %28, %26 ], [ %12, %7 ]
%16 = phi i32 [ %27, %26 ], [ %9, %7 ]
%17 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = load i32, i32* %3
br label %26
21: ; preds = %14
%22 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = load i32, i32* %3
br label %30
26: ; preds = %21, %19
%27 = phi i32 [ %20, %19 ], [ %16, %21 ]
%28 = call i8* @fgets(i8* %15, i32 128, i32* %11)
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %14
30: ; preds = %26, %7, %24
%31 = phi i32 [ %16, %24 ], [ %9, %7 ], [ %27, %26 ]
%32 = phi i8* [ %15, %24 ], [ null, %7 ], [ null, %26 ]
%33 = phi i32 [ %25, %24 ], [ %8, %7 ], [ %8, %26 ]
%34 = udiv i32 %31, 45
%35 = udiv i32 %33, 45
%36 = call i32 @fclose(i32* %11)
%37 = udiv i32 %31, 162000000
%38 = udiv i32 %31, 2700000
%39 = trunc i32 %38 to i16
%40 = urem i16 %39, 60
%41 = zext i16 %40 to i32
%42 = udiv i32 %31, 45000
%43 = urem i32 %42, 60
%44 = urem i32 %34, 1000
%45 = udiv i32 %33, 162000000
%46 = udiv i32 %33, 2700000
%47 = trunc i32 %46 to i16
%48 = urem i16 %47, 60
%49 = zext i16 %48 to i32
%50 = udiv i32 %33, 45000
%51 = urem i32 %50, 60
%52 = urem i32 %35, 1000
%53 = sub nsw i32 %34, %35
%54 = call i32 @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.4, i64 0, i64 0), i32 %37, i32 %41, i32 %43, i32 %44, i32 %45, i32 %49, i32 %51, i32 %52, i32 %53)
%55 = call i32 @sleep(i32 1)
br label %7
}