#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*/ m2(char *, int);
char *malloc(int);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int n;
  scanf("%d\n", &n);
  char *c = malloc(sizeof(char) * n);
  char *t = c;
  for (int i = 0; i < n; i++)
    scanf("%c", t++);
  m2(c, n);
  t = c;
  for (int i = 0; i < n; i++)
    printf("%c\n", *t++);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b6 <main+0x76>
mov    -0x18(%rbp),%rsi
mov    %rsi,%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
lea    0xe61(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1181 <main+0x41>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <m2@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1209 <main+0xc9>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%esi
lea    0xe11(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d1 <main+0x91>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%ebp
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
test   %ebp,%ebp
jle    1198 <main+0x58>
xor    %ebx,%ebx
lea    0xe91(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%r15,%rbx,1),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
mov    0x4(%rsp),%ebp
add    $0x1,%rbx
cmp    %ebp,%ebx
jl     1180 <main+0x40>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <m2@plt>
cmpl   $0x0,0x4(%rsp)
jle    11d7 <main+0x97>
xor    %ebx,%ebx
lea    0xe55(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl (%r15,%rbx,1),%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    0x4(%rsp),%ebx
jl     11c0 <main+0x80>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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