#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*/ uint64_t;
struct xdf_file {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
char *strchr(char *, char);
int /*<<< orphan*/ *strstr(char *, char *);
char *xdf_read_chunk_data(struct xdf_file *, int /*<<< orphan*/);
int stream_summary(struct xdf_file *xf, uint64_t size) {
  char *buf, *p, *n;
  buf = xdf_read_chunk_data(xf, size);
  if (buf == NULL)
    return 1;
  for (p = buf; *p != '\0'; p = n + 1) {
    n = strchr(p, '\n');
    if (n == NULL) {
      printf(">>> %s\n", p);
      return 0;
    }
    *n = '\0';
    if (strstr(p, "<desc") != NULL)
      break;
    if (strstr(p, "info>") != NULL)
      continue;
    if (strstr(p, "<?xml") != NULL)
      continue;
    printf("%s\n", p);
  }
  return 0;
}


x86 assembly (clang, -O0):
<stream_summary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <xdf_read_chunk_data@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1176 <stream_summary+0x36>
movl   $0x1,-0x4(%rbp)
jmp    1253 <stream_summary+0x113>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     124c <stream_summary+0x10c>
mov    -0x28(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11c7 <stream_summary+0x87>
mov    -0x28(%rbp),%rsi
lea    0xe4a(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1253 <stream_summary+0x113>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11ed <stream_summary+0xad>
jmp    124c <stream_summary+0x10c>
mov    -0x28(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     120c <stream_summary+0xcc>
jmp    123b <stream_summary+0xfb>
mov    -0x28(%rbp),%rdi
lea    0xdfd(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     122b <stream_summary+0xeb>
jmp    123b <stream_summary+0xfb>
mov    -0x28(%rbp),%rsi
lea    0xdce(%rip),%rdi
call   1050 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    117e <stream_summary+0x3e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stream_summary>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
call   1030 <xdf_read_chunk_data@plt>
test   %rax,%rax
je     11e7 <stream_summary+0xa7>
mov    %rax,%rbx
xor    %r14d,%r14d
cmpb   $0x0,(%rax)
je     11fe <stream_summary+0xbe>
lea    0xe99(%rip),%rbp
lea    0xe98(%rip),%r15
lea    0xe97(%rip),%r12
jmp    118e <stream_summary+0x4e>
nop
mov    %r13,%rbx
add    $0x1,%rbx
cmpb   $0x0,0x1(%r13)
je     11fe <stream_summary+0xbe>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11ef <stream_summary+0xaf>
mov    %rax,%r13
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
jne    11fe <stream_summary+0xbe>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
jne    1180 <stream_summary+0x40>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
jne    1180 <stream_summary+0x40>
lea    0xe27(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
jmp    1180 <stream_summary+0x40>
mov    $0x1,%r14d
jmp    11fe <stream_summary+0xbe>
lea    0xe0a(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.xdf_file = type { i32 }
@.str = [8 x i8] c">>> %s\0A\00"
@.str.1 = [6 x i8] c"<desc\00"
@.str.2 = [6 x i8] c"info>\00"
@.str.3 = [6 x i8] c"<?xml\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @stream_summary(%struct.xdf_file* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.xdf_file*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store %struct.xdf_file* %0, %struct.xdf_file** %4
store i32 %1, i32* %5
%9 = load %struct.xdf_file*, %struct.xdf_file** %4
%10 = load i32, i32* %5
%11 = call i8* @xdf_read_chunk_data(%struct.xdf_file* %9, i32 %10)
store i8* %11, i8** %6
%12 = load i8*, i8** %6
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 1, i32* %3
br label %53
15: ; preds = %2
%16 = load i8*, i8** %6
store i8* %16, i8** %7
br label %17
17: ; preds = %49, %15
%18 = load i8*, i8** %7
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %52
22: ; preds = %17
%23 = load i8*, i8** %7
%24 = call i8* @strchr(i8* %23, i8 signext 10)
store i8* %24, i8** %8
%25 = load i8*, i8** %8
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i8*, i8** %7
%29 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %28)
store i32 0, i32* %3
br label %53
30: ; preds = %22
%31 = load i8*, i8** %8
store i8 0, i8* %31
%32 = load i8*, i8** %7
%33 = call i32* @strstr(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp ne i32* %33, null
br i1 %34, label %35, label %36
35: ; preds = %30
br label %52
36: ; preds = %30
%37 = load i8*, i8** %7
%38 = call i32* @strstr(i8* %37, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%39 = icmp ne i32* %38, null
br i1 %39, label %40, label %41
40: ; preds = %36
br label %49
41: ; preds = %36
%42 = load i8*, i8** %7
%43 = call i32* @strstr(i8* %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%44 = icmp ne i32* %43, null
br i1 %44, label %45, label %46
45: ; preds = %41
br label %49
46: ; preds = %41
%47 = load i8*, i8** %7
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %46, %45, %40
%50 = load i8*, i8** %8
%51 = getelementptr inbounds i8, i8* %50, i64 1
store i8* %51, i8** %7
br label %17
52: ; preds = %35, %17
store i32 0, i32* %3
br label %53
53: ; preds = %52, %27, %14
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
%struct.xdf_file = type { i32 }
@.str = [8 x i8] c">>> %s\0A\00"
@.str.1 = [6 x i8] c"<desc\00"
@.str.2 = [6 x i8] c"info>\00"
@.str.3 = [6 x i8] c"<?xml\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @stream_summary(%struct.xdf_file* %0, i32 %1) {
%3 = tail call i8* @xdf_read_chunk_data(%struct.xdf_file* %0, i32 %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %29, label %5
5: ; preds = %2
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 0
br i1 %7, label %29, label %8
8: ; preds = %5, %25
%9 = phi i8* [ %26, %25 ], [ %3, %5 ]
%10 = tail call i8* @strchr(i8* %9, i8 signext 10)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %29
14: ; preds = %8
store i8 0, i8* %10
%15 = tail call i32* @strstr(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %29
17: ; preds = %14
%18 = tail call i32* @strstr(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = tail call i32* @strstr(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %9)
br label %25
25: ; preds = %20, %17, %23
%26 = getelementptr inbounds i8, i8* %10, i64 1
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %8
29: ; preds = %14, %25, %5, %2, %12
%30 = phi i32 [ 0, %12 ], [ 1, %2 ], [ 0, %5 ], [ 0, %25 ], [ 0, %14 ]
ret i32 %30
}