#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 *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
char *strstrip(char *);
char *transcribe_dna_to_rna(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 *rna_str = transcribe_dna_to_rna(dna_str);
  printf("%s\n", rna_str);
  free(line_ptr);
  free(rna_str);
}


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)
cmpl   $0x2,-0x8(%rbp)
je     11e8 <main+0x48>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe29(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <main+0x151>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe23(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1241 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    -0x20(%rbp),%rdi
lea    0xdfe(%rip),%rsi
call   1090 <asprintf@plt>
mov    -0x20(%rbp),%rdi
call   10b0 <perror@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <main+0x151>
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   10c0 <getline@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0xffffffff,-0x34(%rbp)
jne    12b5 <main+0x115>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    -0x40(%rbp),%rdi
lea    0xd9e(%rip),%rsi
call   1090 <asprintf@plt>
mov    -0x40(%rbp),%rdi
call   10b0 <perror@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    12f1 <main+0x151>
mov    -0x28(%rbp),%rdi
call   1070 <strstrip@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1060 <transcribe_dna_to_rna@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rsi
lea    0xd73(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
cmp    $0x2,%edi
jne    1241 <main+0xa1>
mov    0x8(%r14),%rdi
lea    0xe5b(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1267 <main+0xc7>
mov    %rax,%rbx
movq   $0x0,0x8(%rsp)
movq   $0x0,0x18(%rsp)
lea    0x8(%rsp),%rdi
lea    0x18(%rsp),%rsi
mov    %rax,%rdx
call   10c0 <getline@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <fclose@plt>
cmp    $0xffffffff,%ebp
je     128d <main+0xed>
mov    0x8(%rsp),%rdi
call   1070 <strstrip@plt>
mov    %rax,%rdi
call   1060 <transcribe_dna_to_rna@plt>
mov    %rax,%rbx
lea    0xe2a(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    125e <main+0xbe>
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xdac(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x8(%r14),%rdx
lea    0xdaa(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1090 <asprintf@plt>
mov    0x8(%rsp),%rdi
call   10b0 <perror@plt>
mov    0x8(%rsp),%rdi
jmp    12b1 <main+0x111>
mov    0x8(%r14),%rdx
lea    0xd98(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1090 <asprintf@plt>
mov    0x10(%rsp),%rdi
call   10b0 <perror@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
jmp    1259 <main+0xb9>

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 = [4 x i8] c"%s\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*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 2
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 1, i32* %3
br label %65
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %6
%27 = load i32*, i32** %6
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %38
29: ; preds = %22
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @asprintf(i8** %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %7
%35 = call i32 @perror(i8* %34)
%36 = load i8*, i8** %7
%37 = call i32 @free(i8* %36)
store i32 1, i32* %3
br label %65
38: ; preds = %22
store i8* null, i8** %8
store i64 0, i64* %9
store i32 0, i32* %10
%39 = load i32*, i32** %6
%40 = call i32 @getline(i8** %8, i64* %9, i32* %39)
store i32 %40, i32* %10
%41 = load i32*, i32** %6
%42 = call i32 @fclose(i32* %41)
%43 = load i32, i32* %10
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %54
45: ; preds = %38
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 1
%48 = load i8*, i8** %47
%49 = call i32 @asprintf(i8** %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %48)
%50 = load i8*, i8** %11
%51 = call i32 @perror(i8* %50)
%52 = load i8*, i8** %11
%53 = call i32 @free(i8* %52)
store i32 1, i32* %3
br label %65
54: ; preds = %38
%55 = load i8*, i8** %8
%56 = call i8* @strstrip(i8* %55)
store i8* %56, i8** %12
%57 = load i8*, i8** %12
%58 = call i8* @transcribe_dna_to_rna(i8* %57)
store i8* %58, i8** %13
%59 = load i8*, i8** %13
%60 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %59)
%61 = load i8*, i8** %8
%62 = call i32 @free(i8* %61)
%63 = load i8*, i8** %13
%64 = call i32 @free(i8* %63)
br label %65
65: ; preds = %54, %45, %29, %16
%66 = load i32, i32* %3
ret i32 %66
}

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 = [4 x i8] c"%s\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 @fprintf(i32 %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %49
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 %49
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 %47
39: ; preds = %25
%40 = load i8*, i8** %4
%41 = call i8* @strstrip(i8* %40)
%42 = call i8* @transcribe_dna_to_rna(i8* %41)
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %42)
%44 = load i8*, i8** %4
%45 = call i32 @free(i8* %44)
%46 = call i32 @free(i8* %42)
br label %47
47: ; preds = %39, %31
%48 = phi i32 [ 1, %31 ], [ 0, %39 ]
br label %49
49: ; preds = %17, %47, %8
%50 = phi i32 [ 1, %8 ], [ 1, %17 ], [ %48, %47 ]
ret i32 %50
}