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

/* Variables and functions */
int /*<<< orphan*/ asprintf(char **, char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
char *get_dna_complement(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
char *strrev(char *);
char *strstrip(char *);
int32_t main(int32_t argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <dataset file>\n", argv[0]);
    return 1;
  }
  FILE *inp_fp = fopen(argv[1], "r");
  if (inp_fp == NULL) {
    char *err_msg;
    asprintf(&err_msg, "Failed to open \"%s\"", argv[1]);
    perror(err_msg);
    free(err_msg);
    return 1;
  }
  char *line_ptr = NULL;
  size_t line_len = 0;
  ssize_t read_len = 0;
  read_len = getline(&line_ptr, &line_len, inp_fp);
  fclose(inp_fp);
  if (read_len == -1) {
    char *err_msg;
    asprintf(&err_msg, "Failed to get line from \"%s\"", argv[1]);
    perror(err_msg);
    free(err_msg);
    return 1;
  }
  char *dna_str = strstrip(line_ptr);
  char *dna_complement = get_dna_complement(dna_str);
  if (!dna_complement) {
    fprintf(stderr, "get_dna_complement() failed, possible garbage data?\n");
    fprintf(stderr, "%s\n", dna_str);
    return 1;
  }
  char *dna_reverse_complement = strrev(dna_complement);
  if (!dna_reverse_complement) {
    fprintf(stderr,
            "dna_reverse_complement() failed, possible garbage data?\n");
    fprintf(stderr, "%s\n", dna_complement);
    return 1;
  }
  printf("%s\n", dna_reverse_complement);
  free(dna_reverse_complement);
  free(dna_complement);
  free(line_ptr);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11fa <main+0x4a>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe19(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13ab <main+0x1fb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe11(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1253 <main+0xa3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    -0x20(%rbp),%rdi
lea    0xdec(%rip),%rsi
call   1090 <asprintf@plt>
mov    -0x20(%rbp),%rdi
call   10c0 <perror@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    13ab <main+0x1fb>
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   10d0 <getline@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0xffffffff,-0x34(%rbp)
jne    12c7 <main+0x117>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    -0x40(%rbp),%rdi
lea    0xd8c(%rip),%rsi
call   1090 <asprintf@plt>
mov    -0x40(%rbp),%rdi
call   10c0 <perror@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    13ab <main+0x1fb>
mov    -0x28(%rbp),%rdi
call   1070 <strstrip@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1050 <get_dna_complement@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    132a <main+0x17a>
mov    0x2ced(%rip),%rax
mov    (%rax),%edi
lea    0xd51(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2cd6(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rdx
lea    0xd6b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13ab <main+0x1fb>
mov    -0x50(%rbp),%rdi
call   10a0 <strrev@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1380 <main+0x1d0>
mov    0x2c97(%rip),%rax
mov    (%rax),%edi
lea    0xd34(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%rdx
lea    0xd15(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13ab <main+0x1fb>
mov    -0x58(%rbp),%rsi
lea    0xcf7(%rip),%rdi
call   1060 <printf@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
cmp    $0x2,%edi
jne    126e <main+0xbe>
mov    0x8(%r14),%rdi
lea    0xe49(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12e2 <main+0x132>
mov    %rax,%rbx
movq   $0x0,(%rsp)
movq   $0x0,0x10(%rsp)
mov    %rsp,%rdi
lea    0x10(%rsp),%rsi
mov    %rax,%rdx
call   10d0 <getline@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fclose@plt>
cmp    $0xffffffff,%ebp
je     1304 <main+0x154>
mov    (%rsp),%rdi
call   1070 <strstrip@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <get_dna_complement@plt>
test   %rax,%rax
je     1283 <main+0xd3>
mov    %rax,%r15
mov    %rax,%rdi
call   10a0 <strrev@plt>
test   %rax,%rax
je     12a8 <main+0xf8>
mov    %rax,%rbx
lea    0xe39(%rip),%rdi
mov    %rax,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    12d7 <main+0x127>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xd7f(%rip),%rsi
jmp    12cb <main+0x11b>
mov    0x2d56(%rip),%rbx
mov    (%rbx),%edi
lea    0xdba(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
lea    0xddf(%rip),%rsi
mov    %r14,%rdx
jmp    12cb <main+0x11b>
mov    0x2d31(%rip),%rbx
mov    (%rbx),%edi
lea    0xdce(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
lea    0xdba(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%r14),%rdx
lea    0xd2f(%rip),%rsi
mov    %rsp,%rdi
call   1090 <asprintf@plt>
mov    (%rsp),%rdi
call   10c0 <perror@plt>
mov    (%rsp),%rdi
jmp    1328 <main+0x178>
mov    0x8(%r14),%rdx
lea    0xd21(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1090 <asprintf@plt>
mov    0x8(%rsp),%rdi
call   10c0 <perror@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
jmp    12d2 <main+0x122>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"Usage: %s <dataset file>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Failed to open \22%s\22\00"
@.str.3 = [29 x i8] c"Failed to get line from \22%s\22\00"
@.str.4 = [53 x i8] c"get_dna_complement() failed, possible garbage data?\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [57 x i8] c"dna_reverse_complement() failed, possible garbage data?\0A\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 i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %23
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %21)
store i32 1, i32* %3
br label %88
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %6
%28 = load i32*, i32** %6
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %39
30: ; preds = %23
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @asprintf(i8** %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = load i8*, i8** %7
%36 = call i32 @perror(i8* %35)
%37 = load i8*, i8** %7
%38 = call i32 @free(i8* %37)
store i32 1, i32* %3
br label %88
39: ; preds = %23
store i8* null, i8** %8
store i64 0, i64* %9
store i32 0, i32* %10
%40 = load i32*, i32** %6
%41 = call i32 @getline(i8** %8, i64* %9, i32* %40)
store i32 %41, i32* %10
%42 = load i32*, i32** %6
%43 = call i32 @fclose(i32* %42)
%44 = load i32, i32* %10
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %55
46: ; preds = %39
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = call i32 @asprintf(i8** %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %49)
%51 = load i8*, i8** %11
%52 = call i32 @perror(i8* %51)
%53 = load i8*, i8** %11
%54 = call i32 @free(i8* %53)
store i32 1, i32* %3
br label %88
55: ; preds = %39
%56 = load i8*, i8** %8
%57 = call i8* @strstrip(i8* %56)
store i8* %57, i8** %12
%58 = load i8*, i8** %12
%59 = call i8* @get_dna_complement(i8* %58)
store i8* %59, i8** %13
%60 = load i8*, i8** %13
%61 = icmp ne i8* %60, null
br i1 %61, label %68, label %62
62: ; preds = %55
%63 = load i32, i32* @stderr
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
%65 = load i32, i32* @stderr
%66 = load i8*, i8** %12
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %66)
store i32 1, i32* %3
br label %88
68: ; preds = %55
%69 = load i8*, i8** %13
%70 = call i8* @strrev(i8* %69)
store i8* %70, i8** %14
%71 = load i8*, i8** %14
%72 = icmp ne i8* %71, null
br i1 %72, label %79, label %73
73: ; preds = %68
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.6, i64 0, i64 0))
%76 = load i32, i32* @stderr
%77 = load i8*, i8** %13
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %77)
store i32 1, i32* %3
br label %88
79: ; preds = %68
%80 = load i8*, i8** %14
%81 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %80)
%82 = load i8*, i8** %14
%83 = call i32 @free(i8* %82)
%84 = load i8*, i8** %13
%85 = call i32 @free(i8* %84)
%86 = load i8*, i8** %8
%87 = call i32 @free(i8* %86)
br label %88
88: ; preds = %79, %73, %62, %46, %30, %17
%89 = load i32, i32* %3
ret i32 %89
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"Usage: %s <dataset file>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Failed to open \22%s\22\00"
@.str.3 = [29 x i8] c"Failed to get line from \22%s\22\00"
@.str.4 = [53 x i8] c"get_dna_complement() failed, possible garbage data?\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [57 x i8] c"dna_reverse_complement() failed, possible garbage data?\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = icmp eq i32 %0, 2
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %65
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %25
17: ; preds = %12
%18 = bitcast i8** %3 to i8*
%19 = load i8*, i8** %13
%20 = call i32 @asprintf(i8** %3, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %3
%22 = call i32 @perror(i8* %21)
%23 = load i8*, i8** %3
%24 = call i32 @free(i8* %23)
br label %65
25: ; preds = %12
%26 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%27 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%28 = call i32 @getline(i8** %4, i64* %5, i32* %15)
%29 = call i32 @fclose(i32* %15)
%30 = icmp eq i32 %28, -1
br i1 %30, label %31, label %39
31: ; preds = %25
%32 = bitcast i8** %6 to i8*
%33 = load i8*, i8** %13
%34 = call i32 @asprintf(i8** %6, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %33)
%35 = load i8*, i8** %6
%36 = call i32 @perror(i8* %35)
%37 = load i8*, i8** %6
%38 = call i32 @free(i8* %37)
br label %63
39: ; preds = %25
%40 = load i8*, i8** %4
%41 = call i8* @strstrip(i8* %40)
%42 = call i8* @get_dna_complement(i8* %41)
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %49
44: ; preds = %39
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %41)
br label %63
49: ; preds = %39
%50 = call i8* @strrev(i8* %42)
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %57
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.6, i64 0, i64 0))
%55 = load i32, i32* @stderr
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %42)
br label %63
57: ; preds = %49
%58 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %50)
%59 = call i32 @free(i8* %50)
%60 = call i32 @free(i8* %42)
%61 = load i8*, i8** %4
%62 = call i32 @free(i8* %61)
br label %63
63: ; preds = %44, %57, %52, %31
%64 = phi i32 [ 1, %31 ], [ 1, %44 ], [ 0, %57 ], [ 1, %52 ]
br label %65
65: ; preds = %17, %63, %8
%66 = phi i32 [ 1, %8 ], [ 1, %17 ], [ %64, %63 ]
ret i32 %66
}