#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*/ exit(int);
scalar_t__ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  const char *tag;
  char *aliases_file_name;
  char *canonical_file_name;
  FILE *aliases_file;
  FILE *canonical_file;
  if (argc != 4) {
    fprintf(stderr, "Usage: genaliases2 tag aliases.h canonical.h\n");
    exit(1);
  }
  tag = argv[1];
  aliases_file_name = argv[2];
  canonical_file_name = argv[3];
  aliases_file = fopen(aliases_file_name, "w");
  if (aliases_file == NULL) {
    fprintf(stderr, "Could not open '%s' for writing\n", aliases_file_name);
    exit(1);
  }
  canonical_file = fopen(canonical_file_name, "w");
  if (canonical_file == NULL) {
    fprintf(stderr, "Could not open '%s' for writing\n", canonical_file_name);
    exit(1);
  }
  if (ferror(aliases_file) || fclose(aliases_file))
    exit(1);
  if (ferror(canonical_file) || fclose(canonical_file))
    exit(1);
  exit(0);
}


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)
cmpl   $0x4,-0x8(%rbp)
je     1191 <main+0x41>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11f9 <main+0xa9>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x28(%rbp),%rdi
lea    0xe2a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    123d <main+0xed>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x30(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
jne    1263 <main+0x113>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     126d <main+0x11d>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x38(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
jne    1293 <main+0x143>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     129d <main+0x14d>
mov    $0x1,%edi
call   1070 <exit@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x4,%edi
jne    118e <main+0x3e>
mov    0x10(%rsi),%rbx
mov    0x18(%rsi),%r15
lea    0xec2(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
jne    11af <main+0x5f>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xea7(%rip),%rsi
mov    %rbx,%rdx
jmp    11d9 <main+0x89>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    %rax,%r12
lea    0xe75(%rip),%rsi
mov    %r15,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
jne    11ea <main+0x9a>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    0xe5a(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    11a5 <main+0x55>
mov    %r12,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
jne    11a5 <main+0x55>
mov    %r14,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    11a5 <main+0x55>
mov    %r14,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
jne    11a5 <main+0x55>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [46 x i8] c"Usage: genaliases2 tag aliases.h canonical.h\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [33 x i8] c"Could not open '%s' for writing\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%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 ne i32 %11, 4
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
store i8* %20, i8** %6
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
store i8* %23, i8** %7
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 3
%26 = load i8*, i8** %25
store i8* %26, i8** %8
%27 = load i8*, i8** %7
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %9
%29 = load i32*, i32** %9
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %36
31: ; preds = %17
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %7
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %17
%37 = load i8*, i8** %8
%38 = call i32* @fopen(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %38, i32** %10
%39 = load i32*, i32** %10
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %46
41: ; preds = %36
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %8
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %43)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %36
%47 = load i32*, i32** %9
%48 = call i64 @ferror(i32* %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %54, label %50
50: ; preds = %46
%51 = load i32*, i32** %9
%52 = call i64 @fclose(i32* %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %50, %46
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %50
%57 = load i32*, i32** %10
%58 = call i64 @ferror(i32* %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %64, label %60
60: ; preds = %56
%61 = load i32*, i32** %10
%62 = call i64 @fclose(i32* %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %60, %56
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %60
%67 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [46 x i8] c"Usage: genaliases2 tag aliases.h canonical.h\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [33 x i8] c"Could not open '%s' for writing\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %8
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %8
%20 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %19
%27 = tail call i64 @ferror(i32* %13)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = tail call i64 @fclose(i32* %13)
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29, %26
%33 = tail call i32 @exit(i32 1)
unreachable
34: ; preds = %29
%35 = tail call i64 @ferror(i32* %20)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = tail call i64 @fclose(i32* %20)
%39 = icmp eq i64 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37, %34
%41 = tail call i32 @exit(i32 1)
unreachable
42: ; preds = %37
%43 = tail call i32 @exit(i32 0)
unreachable
}