#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 *, int const);
void reverse_message(const int array[], int *c) {
  while (*c > 0) {
    if (array[*c] == '\n') {
      *c -= 1;
      continue;
    }
    printf("%c", array[*c]);
    *c -= 1;
  }
  printf("%c\n", array[*c]);
}


x86 assembly (clang, -O0):
<reverse_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jle    117c <reverse_message+0x6c>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
cmpl   $0xa,(%rax,%rcx,4)
jne    1152 <reverse_message+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1120 <reverse_message+0x10>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1120 <reverse_message+0x10>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_message>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    (%rsi),%eax
test   %eax,%eax
jle    1153 <reverse_message+0x43>
mov    %rsi,%rbx
lea    0xed8(%rip),%r15
jmp    113c <reverse_message+0x2c>
nopw   0x0(%rax,%rax,1)
lea    -0x1(%rax),%ecx
mov    %ecx,(%rbx)
cmp    $0x1,%eax
mov    %ecx,%eax
jle    1155 <reverse_message+0x45>
mov    %eax,%ecx
mov    (%r14,%rcx,4),%esi
cmp    $0xa,%esi
je     1130 <reverse_message+0x20>
mov    %r15,%rdi
call   1030 <printf@plt>
mov    (%rbx),%eax
jmp    1130 <reverse_message+0x20>
mov    %eax,%ecx
movslq %ecx,%rax
mov    (%r14,%rax,4),%esi
lea    0xea0(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [4 x i8] c"%c\0A\00"
define void @reverse_message(i32* nocapture %0, i32* nocapture %1) {
%3 = load i32, i32* %1
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %18
5: ; preds = %2, %11
%6 = phi i32 [ %13, %11 ], [ %3, %2 ]
%7 = zext i32 %6 to i64
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 10
br i1 %10, label %11, label %15
11: ; preds = %5, %15
%12 = phi i32 [ %17, %15 ], [ %6, %5 ]
%13 = add nsw i32 %12, -1
store i32 %13, i32* %1
%14 = icmp sgt i32 %12, 1
br i1 %14, label %5, label %18
15: ; preds = %5
%16 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%17 = load i32, i32* %1
br label %11
18: ; preds = %11, %2
%19 = phi i32 [ %3, %2 ], [ %13, %11 ]
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %0, i64 %20
%22 = load i32, i32* %21
%23 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
ret void
}