#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 */

/* Variables and functions */
int get_line_and_len(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ reverse_line(char *, char *, int);
int main() {
  int len;
  char line[1000];
  char reverse[1000];
  len = get_line_and_len(line, 1000);
  printf("Original line is %s\n", line);
  reverse_line(reverse, line, len);
  printf("Reverse line is %s\n", reverse);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7e0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1050 <get_line_and_len@plt>
mov    %eax,-0x8(%rbp)
lea    -0x3f0(%rbp),%rsi
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
lea    -0x7e0(%rbp),%rdi
lea    -0x3f0(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1040 <reverse_line@plt>
lea    -0x7e0(%rbp),%rsi
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x7e0,%rsp
lea    0x3f0(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1050 <get_line_and_len@plt>
mov    %eax,%ebp
lea    0xea7(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <reverse_line@plt>
lea    0xe9d(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Original line is %s\0A\00"
@.str.1 = [20 x i8] c"Reverse line is %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i8]
store i32 0, i32* %1
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = call i32 @get_line_and_len(i8* %5, i32 1000)
store i32 %6, i32* %2
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%11 = load i32, i32* %2
%12 = call i32 @reverse_line(i8* %9, i8* %10, i32 %11)
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %13)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"Original line is %s\0A\00"
@.str.1 = [20 x i8] c"Reverse line is %s\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%5 = call i32 @get_line_and_len(i8* %3, i32 1000)
%6 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %3)
%7 = call i32 @reverse_line(i8* %4, i8* %3, i32 %5)
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 0
}