#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*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int filterData(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  FILE *in = stdin;
  FILE *out = stdout;
  int cc;
  if (argc != 3) {
    fprintf(stderr, "Usage: hprof-conf infile outfile\n\n");
    fprintf(stderr, "Specify '-' for either or both to use stdin/stdout.\n\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");
    return 2;
  }
  if (strcmp(argv[1], "-") != 0) {
    in = fopen(argv[1], "rb");
    if (in == NULL) {
      fprintf(stderr, "ERROR: failed to open input '%s': %s\n", argv[1],
              strerror(errno));
      return 1;
    }
  }
  if (strcmp(argv[2], "-") != 0) {
    out = fopen(argv[2], "wb");
    if (out == NULL) {
      fprintf(stderr, "ERROR: failed to open output '%s': %s\n", argv[2],
              strerror(errno));
      if (in != stdin)
        fclose(in);
      return 1;
    }
  }
  cc = filterData(in, out);
  if (in != stdin)
    fclose(in);
  if (out != stdout)
    fclose(out);
  return (cc != 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e6b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e3d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11ed <main+0x8d>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1383 <main+0x223>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xf9a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     127d <main+0x11d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xf7e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1278 <main+0x118>
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    %rax,%rcx
lea    0xf36(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1383 <main+0x223>
jmp    127d <main+0x11d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xf0a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     132a <main+0x1ca>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xf17(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1325 <main+0x1c5>
mov    0x2d13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    0x2cf3(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rdx
mov    %rax,%rcx
lea    0xecf(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    0x2ce1(%rip),%rcx
cmp    (%rcx),%rax
je     1319 <main+0x1b9>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    1383 <main+0x223>
jmp    132a <main+0x1ca>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <filterData@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2ca3(%rip),%rcx
cmp    (%rcx),%rax
je     1357 <main+0x1f7>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rax
mov    0x2c66(%rip),%rcx
cmp    (%rcx),%rax
je     1374 <main+0x214>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
cmpl   $0x0,-0x24(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    1221 <main+0xc1>
mov    %rsi,%rbx
mov    0x2e4a(%rip),%r13
mov    0x0(%r13),%r14
mov    0x2e5f(%rip),%r12
mov    (%r12),%r15
mov    0x8(%rsi),%rdi
lea    0xffe(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11be <main+0x5e>
mov    0x8(%rbx),%rdi
lea    0xfeb(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     126e <main+0x10e>
mov    0x10(%rbx),%rdi
lea    0xfcd(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ef <main+0x8f>
mov    0x10(%rbx),%rdi
lea    0xfe3(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
je     12a6 <main+0x146>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <filterData@plt>
mov    %eax,%ebp
cmp    (%r12),%r15
je     120a <main+0xaa>
mov    %r15,%rdi
call   1030 <fclose@plt>
cmp    0x0(%r13),%r14
je     1218 <main+0xb8>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %ebx,%ebx
test   %ebp,%ebp
setne  %bl
jmp    125d <main+0xfd>
mov    0x2db0(%rip),%rbx
mov    (%rbx),%edi
lea    0xdcf(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xde2(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe08(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x2,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d63(%rip),%rax
mov    (%rax),%ebp
mov    0x8(%rbx),%rbx
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xf0b(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%ebx
jmp    125d <main+0xfd>
mov    0x2d2b(%rip),%rax
mov    (%rax),%ebp
mov    0x10(%rbx),%rbx
mov    0x2d16(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xefc(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%ebx
cmp    (%r12),%r15
je     125d <main+0xfd>
mov    %r15,%rdi
call   1030 <fclose@plt>
jmp    125d <main+0xfd>

LLVM IR (-O0):
@stdin = global i32* null
@stdout = global i32* null
@stderr = global i32 0
@.str = [35 x i8] c"Usage: hprof-conf infile outfile\0A\0A\00"
@.str.1 = [54 x i8] c"Specify '-' for either or both to use stdin/stdout.\0A\0A\00"
@.str.2 = [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"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [38 x i8] c"ERROR: failed to open input '%s': %s\0A\00"
@errno = global i32 0
@.str.6 = [3 x i8] c"wb\00"
@.str.7 = [39 x i8] c"ERROR: failed to open output '%s': %s\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32*, i32** @stdin
store i32* %9, i32** %6
%10 = load i32*, i32** @stdout
store i32* %10, i32** %7
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([317 x i8], [317 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %3
br label %92
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %42
26: ; preds = %20
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %30, i32** %6
%31 = load i32*, i32** %6
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %41
33: ; preds = %26
%34 = load i32, i32* @stderr
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = load i32, i32* @errno
%39 = call i8* @strerror(i32 %38)
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %37, i8* %39)
store i32 1, i32* %3
br label %92
41: ; preds = %26
br label %42
42: ; preds = %41, %20
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %71
48: ; preds = %42
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i32* @fopen(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %52, i32** %7
%53 = load i32*, i32** %7
%54 = icmp eq i32* %53, null
br i1 %54, label %55, label %70
55: ; preds = %48
%56 = load i32, i32* @stderr
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 2
%59 = load i8*, i8** %58
%60 = load i32, i32* @errno
%61 = call i8* @strerror(i32 %60)
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0), i8* %59, i8* %61)
%63 = load i32*, i32** %6
%64 = load i32*, i32** @stdin
%65 = icmp ne i32* %63, %64
br i1 %65, label %66, label %69
66: ; preds = %55
%67 = load i32*, i32** %6
%68 = call i32 @fclose(i32* %67)
br label %69
69: ; preds = %66, %55
store i32 1, i32* %3
br label %92
70: ; preds = %48
br label %71
71: ; preds = %70, %42
%72 = load i32*, i32** %6
%73 = load i32*, i32** %7
%74 = call i32 @filterData(i32* %72, i32* %73)
store i32 %74, i32* %8
%75 = load i32*, i32** %6
%76 = load i32*, i32** @stdin
%77 = icmp ne i32* %75, %76
br i1 %77, label %78, label %81
78: ; preds = %71
%79 = load i32*, i32** %6
%80 = call i32 @fclose(i32* %79)
br label %81
81: ; preds = %78, %71
%82 = load i32*, i32** %7
%83 = load i32*, i32** @stdout
%84 = icmp ne i32* %82, %83
br i1 %84, label %85, label %88
85: ; preds = %81
%86 = load i32*, i32** %7
%87 = call i32 @fclose(i32* %86)
br label %88
88: ; preds = %85, %81
%89 = load i32, i32* %8
%90 = icmp ne i32 %89, 0
%91 = zext i1 %90 to i32
store i32 %91, i32* %3
br label %92
92: ; preds = %88, %69, %33, %13
%93 = load i32, i32* %3
ret i32 %93
}

LLVM IR (-O2):
@stdin = global i32* null
@stdout = global i32* null
@stderr = global i32 0
@.str = [35 x i8] c"Usage: hprof-conf infile outfile\0A\0A\00"
@.str.1 = [54 x i8] c"Specify '-' for either or both to use stdin/stdout.\0A\0A\00"
@.str.2 = [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"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [38 x i8] c"ERROR: failed to open input '%s': %s\0A\00"
@errno = global i32 0
@.str.6 = [3 x i8] c"wb\00"
@.str.7 = [39 x i8] c"ERROR: failed to open output '%s': %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32*, i32** @stdout
%4 = icmp eq i32 %0, 3
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([317 x i8], [317 x i8]* @.str.2, i64 0, i64 0))
br label %63
12: ; preds = %2
%13 = load i32*, i32** @stdin
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %28, label %18
18: ; preds = %12
%19 = load i8*, i8** %14
%20 = tail call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %14
%25 = load i32, i32* @errno
%26 = tail call i8* @strerror(i32 %25)
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %24, i8* %26)
br label %63
28: ; preds = %18, %12
%29 = phi i32* [ %20, %18 ], [ %13, %12 ]
%30 = getelementptr inbounds i8*, i8** %1, i64 2
%31 = load i8*, i8** %30
%32 = tail call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %48, label %34
34: ; preds = %28
%35 = load i8*, i8** %30
%36 = tail call i32* @fopen(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %48
38: ; preds = %34
%39 = load i32, i32* @stderr
%40 = load i8*, i8** %30
%41 = load i32, i32* @errno
%42 = tail call i8* @strerror(i32 %41)
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0), i8* %40, i8* %42)
%44 = load i32*, i32** @stdin
%45 = icmp eq i32* %29, %44
br i1 %45, label %63, label %46
46: ; preds = %38
%47 = tail call i32 @fclose(i32* %29)
br label %63
48: ; preds = %34, %28
%49 = phi i32* [ %36, %34 ], [ %3, %28 ]
%50 = tail call i32 @filterData(i32* %29, i32* %49)
%51 = load i32*, i32** @stdin
%52 = icmp eq i32* %29, %51
br i1 %52, label %55, label %53
53: ; preds = %48
%54 = tail call i32 @fclose(i32* %29)
br label %55
55: ; preds = %53, %48
%56 = load i32*, i32** @stdout
%57 = icmp eq i32* %49, %56
br i1 %57, label %60, label %58
58: ; preds = %55
%59 = tail call i32 @fclose(i32* %49)
br label %60
60: ; preds = %58, %55
%61 = icmp ne i32 %50, 0
%62 = zext i1 %61 to i32
br label %63
63: ; preds = %38, %46, %60, %22, %5
%64 = phi i32 [ 2, %5 ], [ 1, %22 ], [ %62, %60 ], [ 1, %46 ], [ 1, %38 ]
ret i32 %64
}