#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 */
scalar_t__ get_line(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
char *reverse(char *, char *);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  char input_buffer[1024];
  char output_buffer[1024];
  if (argc == 2) {
    printf("%s\n", reverse(output_buffer, argv[1]));
  } else {
    while (get_line(input_buffer, stdin))
      printf("%s\n", reverse(output_buffer, input_buffer));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    117b <main+0x4b>
lea    -0x810(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <reverse@plt>
mov    %rax,%rsi
lea    0xe8f(%rip),%rdi
call   1050 <printf@plt>
jmp    11cb <main+0x9b>
jmp    1180 <main+0x50>
lea    -0x410(%rbp),%rdi
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
call   1040 <get_line@plt>
cmp    $0x0,%rax
je     11c6 <main+0x96>
lea    -0x810(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1030 <reverse@plt>
mov    %rax,%rsi
lea    0xe44(%rip),%rdi
call   1050 <printf@plt>
jmp    1180 <main+0x50>
jmp    11cb <main+0x9b>
xor    %eax,%eax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x808,%rsp
cmp    $0x2,%edi
jne    1160 <main+0x30>
mov    0x8(%rsi),%rsi
mov    %rsp,%rdi
call   1030 <reverse@plt>
lea    0xeaa(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
jmp    11b7 <main+0x87>
mov    0x2e81(%rip),%r12
mov    (%r12),%esi
lea    0x400(%rsp),%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     11b7 <main+0x87>
mov    %rsp,%r14
lea    0x400(%rsp),%rbx
lea    0xe71(%rip),%r15
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <reverse@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
jne    1190 <main+0x60>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i8* @reverse(i8* %11, i8* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %29
17: ; preds = %2
br label %18
18: ; preds = %23, %17
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%20 = load i32, i32* @stdin
%21 = call i64 @get_line(i8* %19, i32 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%26 = call i8* @reverse(i8* %24, i8* %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %26)
br label %18
28: ; preds = %18
br label %29
29: ; preds = %28, %10
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 2
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i32, i32* @stdin
%10 = call i64 @get_line(i8* %5, i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %23, label %17
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i8* @reverse(i8* %6, i8* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %23
17: ; preds = %8, %17
%18 = call i8* @reverse(i8* %6, i8* %5)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @stdin
%21 = call i64 @get_line(i8* %5, i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %17
23: ; preds = %17, %8, %12
ret i32 0
}