#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*/ *);
int filterData(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ *fopen_or_default(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
int optind;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
int main(int argc, char **argv) {
  FILE *in = NULL;
  FILE *out = NULL;
  int flags = 0;
  int res = 1;
  int opt;
  while ((opt = getopt(argc, argv, "z")) != -1) {
    switch (opt) {
    case 'z':
      flags |= 1;
      break;
    case '?':
    default:
      goto usage;
    }
  }
  int i;
  for (i = optind; i < argc; i++) {
    char *arg = argv[i];
    if (!in) {
      in = fopen_or_default(arg, "rb", stdin);
    } else if (!out) {
      out = fopen_or_default(arg, "wb", stdout);
    } else {
      goto usage;
    }
  }
  if (in == NULL || out == NULL) {
    goto usage;
  }
  res = filterData(in, out, flags);
  goto finish;
usage:
  fprintf(stderr, "Usage: hprof-conf [-z] infile outfile\n");
  fprintf(stderr, "\n");
  fprintf(stderr, "  -z: exclude non-app heaps, such as Zygote\n");
  fprintf(stderr, "\n");
  fprintf(stderr,
          "Specify '-' for either or both files to use stdin/stdout.\n");
  fprintf(stderr, "\n");
  fprintf(stderr,
          "Copyright (C) 2009 The Android Open Source Project\n\n"
          "This software is built from source code licensed under the "
          "Apache License,\n"
          "Version 2.0 (the \"License\"). You may obtain a copy of the "
          "License at\n\n"
          "     http://www.apache.org/licenses/LICENSE-2.0\n\n"
          "See the associated NOTICE file for this software for further "
          "details.\n");
  res = 2;
finish:
  if (in != stdin)
    fclose(in);
  if (out != stdout)
    fclose(out);
  return res;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe6e(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     11e5 <main+0x95>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x3f,%eax
je     11d6 <main+0x86>
jmp    11b7 <main+0x67>
mov    -0x3c(%rbp),%eax
sub    $0x7a,%eax
jne    11db <main+0x8b>
jmp    11c8 <main+0x78>
mov    -0x24(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e0 <main+0x90>
jmp    11db <main+0x8b>
jmp    12b9 <main+0x169>
jmp    1184 <main+0x34>
mov    0x2df4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1286 <main+0x136>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    123b <main+0xeb>
mov    -0x38(%rbp),%rdi
mov    0x2dc5(%rip),%rax
mov    (%rax),%rdx
lea    0xdd5(%rip),%rsi
call   1030 <fopen_or_default@plt>
mov    %rax,-0x18(%rbp)
jmp    1273 <main+0x123>
cmpq   $0x0,-0x20(%rbp)
jne    1269 <main+0x119>
mov    -0x38(%rbp),%rdi
mov    0x2d77(%rip),%rax
mov    (%rax),%rdx
lea    0xdaa(%rip),%rsi
call   1030 <fopen_or_default@plt>
mov    %rax,-0x20(%rbp)
jmp    126e <main+0x11e>
jmp    12b9 <main+0x169>
jmp    1273 <main+0x123>
jmp    1278 <main+0x128>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11f1 <main+0xa1>
cmpq   $0x0,-0x18(%rbp)
je     129c <main+0x14c>
cmpq   $0x0,-0x20(%rbp)
jne    12a1 <main+0x151>
jmp    12b9 <main+0x169>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1050 <filterData@plt>
mov    %eax,-0x28(%rbp)
jmp    1353 <main+0x203>
mov    0x2d10(%rip),%rax
mov    (%rax),%edi
lea    0xd3f(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
lea    0xef4(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
lea    0xd3c(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2cd1(%rip),%rax
mov    (%rax),%edi
lea    0xeca(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
lea    0xd3f(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2ca7(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2c92(%rip),%rax
mov    (%rax),%edi
lea    0xd50(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x2,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2c8a(%rip),%rcx
cmp    (%rcx),%rax
je     1370 <main+0x220>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rax
mov    0x2c4d(%rip),%rcx
cmp    (%rcx),%rax
je     138d <main+0x23d>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r12d
xor    %ecx,%ecx
lea    0xe96(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %ecx,%ebp
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <getopt@plt>
mov    $0x1,%ecx
cmp    $0x7a,%eax
je     1170 <main+0x20>
cmp    $0xffffffff,%eax
jne    11ff <main+0xaf>
mov    0x2e4a(%rip),%rax
movslq (%rax),%rax
cmp    %r12d,%eax
jge    11ff <main+0xaf>
lea    (%rbx,%rax,8),%rbx
sub    %eax,%r12d
xor    %r13d,%r13d
xor    %r15d,%r15d
xor    %r14d,%r14d
jmp    11d6 <main+0x86>
mov    0x2e31(%rip),%rax
mov    (%rax),%rdx
lea    0xe41(%rip),%rsi
call   1030 <fopen_or_default@plt>
mov    %rax,%r15
add    $0x1,%r13
cmp    %r13d,%r12d
je     12ae <main+0x15e>
mov    (%rbx,%r13,8),%rdi
test   %r15,%r15
je     11b0 <main+0x60>
test   %r14,%r14
jne    1205 <main+0xb5>
mov    0x2ddd(%rip),%rax
mov    (%rax),%rdx
lea    0xe10(%rip),%rsi
call   1030 <fopen_or_default@plt>
mov    %rax,%r14
jmp    11c9 <main+0x79>
xor    %r14d,%r14d
xor    %r15d,%r15d
mov    0x2dc4(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xdf2(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xfad(%rip),%rbx
mov    %rbx,%rsi
call   1060 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xdf8(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
call   1060 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe0b(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
call   1060 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe2c(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x2,%ebx
mov    0x2d6c(%rip),%rax
cmp    (%rax),%r15
je     1289 <main+0x139>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    0x2d38(%rip),%rax
cmp    (%rax),%r14
je     129d <main+0x14d>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
test   %r15,%r15
je     1205 <main+0xb5>
test   %r14,%r14
je     1205 <main+0xb5>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1050 <filterData@plt>
mov    %eax,%ebx
jmp    1275 <main+0x125>

LLVM IR (-O0):
@.str = [2 x i8] c"z\00"
@optind = global i32 0
@.str.1 = [3 x i8] c"rb\00"
@stdin = global i32* null
@.str.2 = [3 x i8] c"wb\00"
@stdout = global i32* null
@stderr = global i32 0
@.str.3 = [39 x i8] c"Usage: hprof-conf [-z] infile outfile\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [45 x i8] c" -z: exclude non-app heaps, such as Zygote\0A\00"
@.str.6 = [59 x i8] c"Specify '-' for either or both files to use stdin/stdout.\0A\00"
@.str.7 = [317 x i8] c"Copyright (C) 2009 The Android Open Source Project\0A\0AThis software is built from source code licensed under the Apache License,\0AVersion 2.0 (the \22License\22). You may obtain a copy of the License at\0A\0A http://www.apache.org/licenses/LICENSE-2.0\0A\0ASee the associated NOTICE file for this software for further details.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32* null, i32** %7
store i32 0, i32* %8
store i32 1, i32* %9
br label %13
13: ; preds = %25, %2
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @getopt(i32 %14, i8** %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %10
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %26
18: ; preds = %13
%19 = load i32, i32* %10
switch i32 %19, label %24 [
i32 122, label %20
i32 63, label %23
]
20: ; preds = %18
%21 = load i32, i32* %8
%22 = or i32 %21, 1
store i32 %22, i32* %8
br label %25
23: ; preds = %18
br label %24
24: ; preds = %18, %23
br label %69
25: ; preds = %20
br label %13
26: ; preds = %13
%27 = load i32, i32* @optind
store i32 %27, i32* %11
br label %28
28: ; preds = %54, %26
%29 = load i32, i32* %11
%30 = load i32, i32* %4
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %57
32: ; preds = %28
%33 = load i8**, i8*** %5
%34 = load i32, i32* %11
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
store i8* %37, i8** %12
%38 = load i32*, i32** %6
%39 = icmp ne i32* %38, null
br i1 %39, label %44, label %40
40: ; preds = %32
%41 = load i8*, i8** %12
%42 = load i32*, i32** @stdin
%43 = call i32* @fopen_or_default(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %42)
store i32* %43, i32** %6
br label %53
44: ; preds = %32
%45 = load i32*, i32** %7
%46 = icmp ne i32* %45, null
br i1 %46, label %51, label %47
47: ; preds = %44
%48 = load i8*, i8** %12
%49 = load i32*, i32** @stdout
%50 = call i32* @fopen_or_default(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %49)
store i32* %50, i32** %7
br label %52
51: ; preds = %44
br label %69
52: ; preds = %47
br label %53
53: ; preds = %52, %40
br label %54
54: ; preds = %53
%55 = load i32, i32* %11
%56 = add nsw i32 %55, 1
store i32 %56, i32* %11
br label %28
57: ; preds = %28
%58 = load i32*, i32** %6
%59 = icmp eq i32* %58, null
br i1 %59, label %63, label %60
60: ; preds = %57
%61 = load i32*, i32** %7
%62 = icmp eq i32* %61, null
br i1 %62, label %63, label %64
63: ; preds = %60, %57
br label %69
64: ; preds = %60
%65 = load i32*, i32** %6
%66 = load i32*, i32** %7
%67 = load i32, i32* %8
%68 = call i32 @filterData(i32* %65, i32* %66, i32 %67)
store i32 %68, i32* %9
br label %84
69: ; preds = %63, %51, %24
%70 = load i32, i32* @stderr
%71 = call i32 @fprintf(i32 %70, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%72 = load i32, i32* @stderr
%73 = call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%74 = load i32, i32* @stderr
%75 = call i32 @fprintf(i32 %74, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
%76 = load i32, i32* @stderr
%77 = call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%78 = load i32, i32* @stderr
%79 = call i32 @fprintf(i32 %78, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.6, i64 0, i64 0))
%80 = load i32, i32* @stderr
%81 = call i32 @fprintf(i32 %80, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%82 = load i32, i32* @stderr
%83 = call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([317 x i8], [317 x i8]* @.str.7, i64 0, i64 0))
store i32 2, i32* %9
br label %84
84: ; preds = %69, %64
%85 = load i32*, i32** %6
%86 = load i32*, i32** @stdin
%87 = icmp ne i32* %85, %86
br i1 %87, label %88, label %91
88: ; preds = %84
%89 = load i32*, i32** %6
%90 = call i32 @fclose(i32* %89)
br label %91
91: ; preds = %88, %84
%92 = load i32*, i32** %7
%93 = load i32*, i32** @stdout
%94 = icmp ne i32* %92, %93
br i1 %94, label %95, label %98
95: ; preds = %91
%96 = load i32*, i32** %7
%97 = call i32 @fclose(i32* %96)
br label %98
98: ; preds = %95, %91
%99 = load i32, i32* %9
ret i32 %99
}

LLVM IR (-O2):
@.str = [2 x i8] c"z\00"
@optind = global i32 0
@.str.1 = [3 x i8] c"rb\00"
@stdin = global i32* null
@.str.2 = [3 x i8] c"wb\00"
@stdout = global i32* null
@stderr = global i32 0
@.str.3 = [39 x i8] c"Usage: hprof-conf [-z] infile outfile\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [45 x i8] c" -z: exclude non-app heaps, such as Zygote\0A\00"
@.str.6 = [59 x i8] c"Specify '-' for either or both files to use stdin/stdout.\0A\00"
@.str.7 = [317 x i8] c"Copyright (C) 2009 The Android Open Source Project\0A\0AThis software is built from source code licensed under the Apache License,\0AVersion 2.0 (the \22License\22). You may obtain a copy of the License at\0A\0A http://www.apache.org/licenses/LICENSE-2.0\0A\0ASee the associated NOTICE file for this software for further details.\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i32 [ 0, %2 ], [ 1, %3 ]
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
switch i32 %5, label %38 [
i32 -1, label %6
i32 122, label %3
]
6: ; preds = %3
%7 = load i32, i32* @optind
%8 = icmp slt i32 %7, %0
br i1 %8, label %9, label %38
9: ; preds = %6
%10 = sext i32 %7 to i64
br label %11
11: ; preds = %9, %26
%12 = phi i64 [ %10, %9 ], [ %29, %26 ]
%13 = phi i32* [ null, %9 ], [ %28, %26 ]
%14 = phi i32* [ null, %9 ], [ %27, %26 ]
%15 = getelementptr inbounds i8*, i8** %1, i64 %12
%16 = load i8*, i8** %15
%17 = icmp eq i32* %13, null
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = load i32*, i32** @stdin
%20 = tail call i32* @fopen_or_default(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %19)
br label %26
21: ; preds = %11
%22 = icmp eq i32* %14, null
br i1 %22, label %23, label %38
23: ; preds = %21
%24 = load i32*, i32** @stdout
%25 = tail call i32* @fopen_or_default(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %24)
br label %26
26: ; preds = %23, %18
%27 = phi i32* [ %14, %18 ], [ %25, %23 ]
%28 = phi i32* [ %20, %18 ], [ %13, %23 ]
%29 = add nsw i64 %12, 1
%30 = trunc i64 %29 to i32
%31 = icmp eq i32 %30, %0
br i1 %31, label %32, label %11
32: ; preds = %26
%33 = icmp eq i32* %28, null
%34 = icmp eq i32* %27, null
%35 = select i1 %33, i1 true, i1 %34
br i1 %35, label %38, label %36
36: ; preds = %32
%37 = tail call i32 @filterData(i32* %28, i32* %27, i32 %4)
br label %55
38: ; preds = %3, %21, %6, %32
%39 = phi i32* [ %27, %32 ], [ null, %6 ], [ %14, %21 ], [ null, %3 ]
%40 = phi i32* [ %28, %32 ], [ null, %6 ], [ %13, %21 ], [ null, %3 ]
%41 = load i32, i32* @stderr
%42 = tail call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%43 = load i32, i32* @stderr
%44 = tail call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%45 = load i32, i32* @stderr
%46 = tail call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
%47 = load i32, i32* @stderr
%48 = tail call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%49 = load i32, i32* @stderr
%50 = tail call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.6, i64 0, i64 0))
%51 = load i32, i32* @stderr
%52 = tail call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%53 = load i32, i32* @stderr
%54 = tail call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([317 x i8], [317 x i8]* @.str.7, i64 0, i64 0))
br label %55
55: ; preds = %38, %36
%56 = phi i32* [ %39, %38 ], [ %27, %36 ]
%57 = phi i32 [ 2, %38 ], [ %37, %36 ]
%58 = phi i32* [ %40, %38 ], [ %28, %36 ]
%59 = load i32*, i32** @stdin
%60 = icmp eq i32* %58, %59
br i1 %60, label %63, label %61
61: ; preds = %55
%62 = tail call i32 @fclose(i32* %58)
br label %63
63: ; preds = %61, %55
%64 = load i32*, i32** @stdout
%65 = icmp eq i32* %56, %64
br i1 %65, label %68, label %66
66: ; preds = %63
%67 = tail call i32 @fclose(i32* %56)
br label %68
68: ; preds = %63, %66
ret i32 %57
}