#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 /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ reverse_string(char *, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int n;
  scanf("%d", &n);
  char str1[n], str2[n];
  for (int i = 0; i < n; i++) {
    scanf("%c", &str1[i]);
  }
  reverse_string(str1, str2, n - 1, 0);
  for (int i = 0; i < n; i++) {
    printf("%c", str2[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d0 <main+0xa0>
mov    -0x38(%rbp),%rsi
movslq -0x24(%rbp),%rax
add    %rax,%rsi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119d <main+0x6d>
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
xor    %ecx,%ecx
call   1030 <reverse_string@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121e <main+0xee>
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
lea    0xdfc(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ec <main+0xbc>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebb(%rip),%rdi
lea    -0x2c(%rbp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rsp,%r12
mov    -0x2c(%rbp),%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    -0x2c(%rbp),%edx
mov    %rsp,%r14
mov    %rdx,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
test   %edx,%edx
jle    11ab <main+0x7b>
lea    0xe7a(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
lea    (%rbx,%r13,1),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rdx
cmp    %rdx,%rbx
jl     1190 <main+0x60>
add    $0xffffffff,%edx
mov    %r13,%rdi
mov    %r14,%rsi
xor    %ecx,%ecx
call   1030 <reverse_string@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    11ea <main+0xba>
xor    %ebx,%ebx
lea    0xe39(%rip),%r15
nopw   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%esi
mov    %r15,%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
cmp    %rax,%rbx
jl     11d0 <main+0xa0>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %3
%12 = alloca i8, i64 %10
store i64 %10, i64* %4
%13 = load i32, i32* %2
%14 = zext i32 %13 to i64
%15 = alloca i8, i64 %14
store i64 %14, i64* %5
store i32 0, i32* %6
br label %16
16: ; preds = %25, %0
%17 = load i32, i32* %6
%18 = load i32, i32* %2
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %12, i64 %22
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %20
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %16
28: ; preds = %16
%29 = load i32, i32* %2
%30 = sub nsw i32 %29, 1
%31 = call i32 @reverse_string(i8* %12, i8* %15, i32 %30, i32 0)
store i32 0, i32* %7
br label %32
32: ; preds = %42, %28
%33 = load i32, i32* %7
%34 = load i32, i32* %2
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %45
36: ; preds = %32
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %15, i64 %38
%40 = load i8, i8* %39
%41 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %40)
br label %42
42: ; preds = %36
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %32
45: ; preds = %32
store i32 0, i32* %1
%46 = load i8*, i8** %3
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = zext i32 %4 to i64
%6 = call i8* @llvm.stacksave()
%7 = alloca i8, i64 %5
%8 = load i32, i32* %1
%9 = zext i32 %8 to i64
%10 = alloca i8, i64 %9
%11 = icmp sgt i32 %8, 0
br i1 %11, label %18, label %12
12: ; preds = %18, %0
%13 = phi i32 [ %8, %0 ], [ %23, %18 ]
%14 = add nsw i32 %13, -1
%15 = call i32 @reverse_string(i8* %7, i8* %10, i32 %14, i32 0)
%16 = load i32, i32* %1
%17 = icmp sgt i32 %16, 0
br i1 %17, label %27, label %26
18: ; preds = %0, %18
%19 = phi i64 [ %22, %18 ], [ 0, %0 ]
%20 = getelementptr inbounds i8, i8* %7, i64 %19
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = add nuw nsw i64 %19, 1
%23 = load i32, i32* %1
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %22, %24
br i1 %25, label %18, label %12
26: ; preds = %27, %12
ret i32 0
27: ; preds = %12, %27
%28 = phi i64 [ %32, %27 ], [ 0, %12 ]
%29 = getelementptr inbounds i8, i8* %10, i64 %28
%30 = load i8, i8* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %30)
%32 = add nuw nsw i64 %28, 1
%33 = load i32, i32* %1
%34 = sext i32 %33 to i64
%35 = icmp slt i64 %32, %34
br i1 %35, label %27, label %26
}