#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 /*<<< orphan*/ reverse(char *);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ should_continue(char);
int main() {
  char stringToReverse[256];
  char continueResult;
  do {
    printf("Please Enter a string to reverse (%i characters max): ", 256);
    scanf("%s", stringToReverse);
    reverse(stringToReverse);
    printf("Reversed String: %s\n", stringToReverse);
    printf("Would you like to continue (y to continue): ");
    scanf(" %c", &continueResult);
  } while (should_continue(continueResult) == 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x100,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xec4(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x110(%rbp),%rsi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0x111(%rbp),%rsi
call   1060 <scanf@plt>
movsbl -0x111(%rbp),%edi
call   1050 <should_continue@plt>
cmp    $0x0,%rax
je     1152 <main+0x12>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
lea    0xedf(%rip),%r15
lea    0x10(%rsp),%rbx
lea    0xed6(%rip),%r12
lea    0xee4(%rip),%r13
lea    0xf0a(%rip),%rbp
lea    0xf(%rsp),%r14
nopw   0x0(%rax,%rax,1)
lea    0xe79(%rip),%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1030 <reverse@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
movsbl 0xf(%rsp),%edi
call   1050 <should_continue@plt>
test   %rax,%rax
je     1180 <main+0x40>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [55 x i8] c"Please Enter a string to reverse (%i characters max): \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [21 x i8] c"Reversed String: %s\0A\00"
@.str.3 = [45 x i8] c"Would you like to continue (y to continue): \00"
@.str.4 = [4 x i8] c" %c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i8
store i32 0, i32* %1
br label %4
4: ; preds = %14, %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 256)
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%9 = call i32 @reverse(i8* %8)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %3)
br label %14
14: ; preds = %4
%15 = load i8, i8* %3
%16 = call i64 @should_continue(i8 signext %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %4, label %18
18: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@.str = [55 x i8] c"Please Enter a string to reverse (%i characters max): \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [21 x i8] c"Reversed String: %s\0A\00"
@.str.3 = [45 x i8] c"Would you like to continue (y to continue): \00"
@.str.4 = [4 x i8] c" %c\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca i8
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
br label %4
4: ; preds = %4, %0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 256)
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 @reverse(i8* %3)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%11 = load i8, i8* %2
%12 = call i64 @should_continue(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %4, label %14
14: ; preds = %4
ret i32 0
}