#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*/ findallranges();
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ outputsource(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ readinput(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  FILE *file;
  if (argc != 2)
    return 1;
  readinput(stdin);
  findallranges();
  file = fopen(argv[1], "w");
  if (!file) {
    perror(argv[1]);
    return 1;
  }
  outputsource(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     117c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    11dd <main+0x8d>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
call   1050 <readinput@plt>
mov    $0x0,%al
call   1030 <findallranges@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe60(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11cd <main+0x7d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11dd <main+0x8d>
mov    -0x18(%rbp),%rdi
call   1040 <outputsource@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%ebx
cmp    $0x2,%edi
jne    1195 <main+0x45>
mov    %rsi,%r14
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
call   1050 <readinput@plt>
xor    %eax,%eax
call   1030 <findallranges@plt>
mov    0x8(%r14),%rdi
lea    0xe7f(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     119f <main+0x4f>
mov    %rax,%rdi
call   1040 <outputsource@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x8(%r14),%rdi
call   1070 <perror@plt>
jmp    1195 <main+0x45>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 1, i32* %3
br label %28
10: ; preds = %2
%11 = load i32, i32* @stdin
%12 = call i32 @readinput(i32 %11)
%13 = call i32 (...) @findallranges()
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %6
%18 = load i32*, i32** %6
%19 = icmp ne i32* %18, null
br i1 %19, label %25, label %20
20: ; preds = %10
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @perror(i8* %23)
store i32 1, i32* %3
br label %28
25: ; preds = %10
%26 = load i32*, i32** %6
%27 = call i32 @outputsource(i32* %26)
store i32 0, i32* %3
br label %28
28: ; preds = %25, %20, %9
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %17
4: ; preds = %2
%5 = load i32, i32* @stdin
%6 = tail call i32 @readinput(i32 %5)
%7 = tail call i32 (...) @findallranges()
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %4
%13 = load i8*, i8** %8
%14 = tail call i32 @perror(i8* %13)
br label %17
15: ; preds = %4
%16 = tail call i32 @outputsource(i32* %10)
br label %17
17: ; preds = %2, %15, %12
%18 = phi i32 [ 0, %15 ], [ 1, %12 ], [ 1, %2 ]
ret i32 %18
}