#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*/ revert_I_am_a_student(char *);
int scanf(char *, char *);
int main(int argc, char **argv) {
  char string[4096];
  int n;
  printf("Input a string (max len 4095):");
  n = scanf("%[^\n]", string);
  if (n <= 0) {
    printf("No input string\nExit\n");
    return 0;
  } else {
    printf("Revert \"%s\"\n", string);
    revert_I_am_a_student(string);
    printf("Result: \"%s\"\n", string);
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1010(%rbp),%rsi
lea    0xeba(%rip),%rdi
call   1050 <scanf@plt>
mov    %eax,-0x1014(%rbp)
cmpl   $0x0,-0x1014(%rbp)
jg     1197 <main+0x67>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d4 <main+0xa4>
lea    -0x1010(%rbp),%rsi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1010(%rbp),%rdi
call   1040 <revert_I_am_a_student@plt>
lea    -0x1010(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x1000,%rsp
lea    0xeb1(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
test   %eax,%eax
jle    119f <main+0x5f>
lea    0xeb3(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <revert_I_am_a_student@plt>
lea    0xea4(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
jmp    11ab <main+0x6b>
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x1000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Input a string (max len 4095):\00"
@.str.1 = [6 x i8] c"%[^\0A]\00"
@.str.2 = [22 x i8] c"No input string\0AExit\0A\00"
@.str.3 = [13 x i8] c"Revert \22%s\22\0A\00"
@.str.4 = [14 x i8] c"Result: \22%s\22\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4096 x i8]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp sle i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %22
15: ; preds = %2
%16 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%19 = call i32 @revert_I_am_a_student(i8* %18)
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %20)
store i32 1, i32* %3
br label %22
22: ; preds = %15, %13
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str = [31 x i8] c"Input a string (max len 4095):\00"
@.str.1 = [6 x i8] c"%[^\0A]\00"
@.str.3 = [13 x i8] c"Revert \22%s\22\0A\00"
@.str.4 = [14 x i8] c"Result: \22%s\22\0A\00"
@str = [21 x i8] c"No input string\0AExit\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %14
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%12 = call i32 @revert_I_am_a_student(i8* %4)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %4)
br label %14
14: ; preds = %10, %8
%15 = phi i32 [ 0, %8 ], [ 1, %10 ]
ret i32 %15
}