#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 *);
char *getComp(char *, int /*<<< orphan*/);
int /*<<< orphan*/ getRev(char *, int /*<<< orphan*/);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  FILE *fp;
  char *filepath = argv[1];
  size_t len = 0;
  ssize_t read;
  char *line = NULL;
  fp = fopen(filepath, "r");
  if (fp == NULL) {
    exit(1);
  }
  while ((read = getline(&line, &len, fp)) != -1) {
    char *revc = getComp(line, strlen(line));
    getRev(revc, strlen(line));
    free(revc);
  }
}


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    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe53(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11cb <main+0x5b>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11d0 <main+0x60>
mov    -0x18(%rbp),%rdx
lea    -0x38(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1070 <getline@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     1237 <main+0xc7>
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%esi
call   1090 <getComp@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
call   1060 <getRev@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
jmp    11d0 <main+0x60>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x8(%rsi),%rdi
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xe68(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1227 <main+0xb7>
mov    %rax,%r12
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %rax,%rdx
call   1070 <getline@plt>
cmp    $0xffffffff,%eax
je     1219 <main+0xa9>
lea    0x8(%rsp),%r14
lea    0x10(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1090 <getComp@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <getRev@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1070 <getline@plt>
cmp    $0xffffffff,%eax
jne    11d0 <main+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
store i8* %14, i8** %7
store i64 0, i64* %8
store i8* null, i8** %10
%15 = load i8*, i8** %7
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
br label %22
22: ; preds = %26, %21
%23 = load i32*, i32** %6
%24 = call i32 @getline(i8** %10, i64* %8, i32* %23)
store i32 %24, i32* %9
%25 = icmp ne i32 %24, -1
br i1 %25, label %26, label %37
26: ; preds = %22
%27 = load i8*, i8** %10
%28 = load i8*, i8** %10
%29 = call i32 @strlen(i8* %28)
%30 = call i8* @getComp(i8* %27, i32 %29)
store i8* %30, i8** %11
%31 = load i8*, i8** %11
%32 = load i8*, i8** %10
%33 = call i32 @strlen(i8* %32)
%34 = call i32 @getRev(i8* %31, i32 %33)
%35 = load i8*, i8** %11
%36 = call i32 @free(i8* %35)
br label %22
37: ; preds = %22
%38 = load i32, i32* %3
ret i32 %38
}

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