#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 ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ pmc_map(char *);
int main() {
  ssize_t read;
  FILE *pfile;
  char *line = NULL;
  size_t len = 0;
  pfile = fopen("tmp/"
                "input.txt",
                "r");
  if (pfile == NULL)
    exit(1);
  while ((read = getline(&line, &len, pfile)) != -1) {
    pmc_map(line);
  }
  if (line)
    free(line);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119b <main+0x4b>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    11a0 <main+0x50>
mov    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <getline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
je     11cb <main+0x7b>
mov    -0x18(%rbp),%rdi
call   1040 <pmc_map@plt>
jmp    11a0 <main+0x50>
cmpq   $0x0,-0x18(%rbp)
je     11df <main+0x8f>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xe8f(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
jne    118c <main+0x3c>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %rax,%rdx
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
je     11cc <main+0x7c>
mov    %rsp,%r14
lea    0x8(%rsp),%r15
nopl   0x0(%rax)
mov    (%rsp),%rdi
call   1040 <pmc_map@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
jne    11b0 <main+0x60>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     11da <main+0x8a>
call   1030 <free@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"tmp/input.txt\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
store i32 0, i32* %1
store i8* null, i8** %4
store i64 0, i64* %5
%6 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %3
%7 = load i32*, i32** %3
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
br label %12
12: ; preds = %16, %11
%13 = load i32*, i32** %3
%14 = call i32 @getline(i8** %4, i64* %5, i32* %13)
store i32 %14, i32* %2
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = call i32 @pmc_map(i8* %17)
br label %12
19: ; preds = %12
%20 = load i8*, i8** %4
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i8*, i8** %4
%24 = call i32 @free(i8* %23)
br label %25
25: ; preds = %22, %19
%26 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [14 x i8] c"tmp/input.txt\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i64
%3 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%4 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = call i32 @getline(i8** %1, i64* %2, i32* %5)
%9 = icmp eq i32 %8, -1
br i1 %9, label %17, label %12
10: ; preds = %0
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %7, %12
%13 = load i8*, i8** %1
%14 = call i32 @pmc_map(i8* %13)
%15 = call i32 @getline(i8** %1, i64* %2, i32* %5)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %12
17: ; preds = %12, %7
%18 = load i8*, i8** %1
%19 = icmp eq i8* %18, null
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = call i32 @free(i8* %18)
br label %22
22: ; preds = %20, %17
%23 = call i32 @exit(i32 0)
unreachable
}