#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
size_t getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
char *reverse(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  FILE *file;
  char *line;
  size_t length = 0;
  size_t read;
  if (argc != 2) {
    printf("usage: %s filename", argv[0]);
    exit(1);
  }
  file = fopen(argv[1], "r");
  if (file == NULL) {
    printf("Failed to open file at %s: ", argv[1]);
    exit(1);
  }
  while ((read = getline(&line, &length, file)) != -1) {
    char target[length];
    strcpy(target, line);
    printf("\nsoruce %s", line);
    printf("reversed %s", reverse(target));
  }
  free(line);
  fclose(file);
  exit(0);
}


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)
movq   $0x0,-0x28(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11c5 <main+0x45>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe4a(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1206 <main+0x86>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe1e(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    120b <main+0x8b>
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1090 <getline@plt>
mov    %rax,-0x30(%rbp)
cmp    $0xffffffffffffffff,%rax
je     128e <main+0x10e>
mov    -0x28(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x20(%rbp),%rsi
lea    0xdcc(%rip),%rdi
call   1070 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <reverse@plt>
mov    %rax,%rsi
lea    0xdbf(%rip),%rdi
call   1070 <printf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
jmp    120b <main+0x8b>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
movq   $0x0,-0x38(%rbp)
cmp    $0x2,%edi
jne    11c3 <main+0x43>
mov    0x8(%r14),%rdi
lea    0xe67(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
jne    11dc <main+0x5c>
mov    0x8(%r14),%rsi
lea    0xe54(%rip),%rdi
jmp    11cd <main+0x4d>
mov    (%r14),%rsi
lea    0xe33(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    %rax,%rbx
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
mov    %rax,%rdx
call   1090 <getline@plt>
cmp    $0xffffffffffffffff,%rax
je     1262 <main+0xe2>
lea    -0x30(%rbp),%r12
lea    -0x38(%rbp),%r13
nopl   (%rax)
mov    %rsp,%r15
mov    -0x38(%rbp),%rax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    -0x30(%rbp),%rsi
mov    %r14,%rdi
call   1050 <strcpy@plt>
mov    -0x30(%rbp),%rsi
lea    0xe02(%rip),%rdi
call   1070 <printf@plt>
mov    %r14,%rdi
call   1030 <reverse@plt>
lea    0xdf9(%rip),%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
mov    %r15,%rsp
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1090 <getline@plt>
cmp    $0xffffffffffffffff,%rax
jne    1200 <main+0x80>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"usage: %s filename\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"Failed to open file at %s: \00"
@.str.3 = [11 x i8] c"\0Asoruce %s\00"
@.str.4 = [12 x i8] c"reversed %s\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 i64
%10 = alloca i8*
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %8
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %6
%25 = load i32*, i32** %6
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %33
27: ; preds = %20
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %20
br label %34
34: ; preds = %38, %33
%35 = load i32*, i32** %6
%36 = call i64 @getline(i8** %7, i64* %8, i32* %35)
store i64 %36, i64* %9
%37 = icmp ne i64 %36, -1
br i1 %37, label %38, label %49
38: ; preds = %34
%39 = load i64, i64* %8
%40 = call i8* @llvm.stacksave()
store i8* %40, i8** %10
%41 = alloca i8, i64 %39
store i64 %39, i64* %11
%42 = load i8*, i8** %7
%43 = call i32 @strcpy(i8* %41, i8* %42)
%44 = load i8*, i8** %7
%45 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %44)
%46 = call i8* @reverse(i8* %41)
%47 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %46)
%48 = load i8*, i8** %10
br label %34
49: ; preds = %34
%50 = load i8*, i8** %7
%51 = call i32 @free(i8* %50)
%52 = load i32*, i32** %6
%53 = call i32 @fclose(i32* %52)
%54 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [19 x i8] c"usage: %s filename\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"Failed to open file at %s: \00"
@.str.3 = [11 x i8] c"\0Asoruce %s\00"
@.str.4 = [12 x i8] c"reversed %s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%7 = icmp eq i32 %0, 2
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 1)
unreachable
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 %20, label %17
17: ; preds = %12
%18 = call i64 @getline(i8** %3, i64* %4, i32* %15)
%19 = icmp eq i64 %18, -1
br i1 %19, label %36, label %24
20: ; preds = %12
%21 = load i8*, i8** %13
%22 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %17, %24
%25 = load i64, i64* %4
%26 = call i8* @llvm.stacksave()
%27 = alloca i8, i64 %25
%28 = load i8*, i8** %3
%29 = call i32 @strcpy(i8* %27, i8* %28)
%30 = load i8*, i8** %3
%31 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %30)
%32 = call i8* @reverse(i8* %27)
%33 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %32)
%34 = call i64 @getline(i8** %3, i64* %4, i32* %15)
%35 = icmp eq i64 %34, -1
br i1 %35, label %36, label %24
36: ; preds = %24, %17
%37 = load i8*, i8** %3
%38 = call i32 @free(i8* %37)
%39 = call i32 @fclose(i32* %15)
%40 = call i32 @exit(i32 0)
unreachable
}