#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 */
typedef int /*<<< orphan*/ fname;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getchar();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ save(char *);
void ciao(void) {
  char fname[80];
  size_t pos;
  printf("What would you like to call the saved version?\n");
  for (pos = 0; pos < sizeof(fname) - 1; pos++) {
    int ch;
    ch = getchar();
    if (ch == '\n' || ch == EOF)
      break;
    fname[pos] = ch;
  }
  fname[pos] = '\0';
  if (save(fname) != 0)
    return;
  printf("To resume, say \"adventure %s\".\n", fname);
  printf("\"With these rooms I might now have been familiarly ");
  printf("acquainted.\"\n");
  exit(0);
}


x86 assembly (clang, -O0):
<ciao>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x58(%rbp)
cmpq   $0x4f,-0x58(%rbp)
jae    11b2 <ciao+0x72>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0xa,-0x5c(%rbp)
je     118f <ciao+0x4f>
mov    -0x5c(%rbp),%eax
mov    0x2e61(%rip),%rcx
cmp    (%rcx),%eax
jne    1194 <ciao+0x54>
jmp    11b2 <ciao+0x72>
mov    -0x5c(%rbp),%eax
mov    %al,%cl
mov    -0x58(%rbp),%rax
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x58(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    115e <ciao+0x1e>
mov    -0x58(%rbp),%rax
movb   $0x0,-0x50(%rbp,%rax,1)
lea    -0x50(%rbp),%rdi
call   1040 <save@plt>
cmp    $0x0,%rax
je     11d4 <ciao+0x94>
add    $0x60,%rsp
pop    %rbp
ret
lea    -0x50(%rbp),%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<ciao>:
push   %r14
push   %rbx
sub    $0x58,%rsp
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e7e(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%eax
je     1193 <ciao+0x43>
cmp    (%r14),%eax
je     1193 <ciao+0x43>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x4f,%rbx
jne    1170 <ciao+0x20>
mov    $0x4f,%ebx
movb   $0x0,(%rsp,%rbx,1)
mov    %rsp,%rdi
call   1050 <save@plt>
test   %rax,%rax
je     11ac <ciao+0x5c>
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe4d(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [48 x i8] c"What would you like to call the saved version?\0A\00"
@EOF = global i32 0
@.str.1 = [32 x i8] c"To resume, say \22adventure %s\22.\0A\00"
@.str.2 = [52 x i8] c"\22With these rooms I might now have been familiarly \00"
@.str.3 = [14 x i8] c"acquainted.\22\0A\00"
define void @ciao() {
%1 = alloca [80 x i8]
%2 = alloca i64
%3 = alloca i32
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* %2
br label %5
5: ; preds = %22, %0
%6 = load i64, i64* %2
%7 = icmp ult i64 %6, 79
br i1 %7, label %8, label %25
8: ; preds = %5
%9 = call i32 (...) @getchar()
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 10
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = load i32, i32* %3
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %12, %8
br label %25
17: ; preds = %12
%18 = load i32, i32* %3
%19 = trunc i32 %18 to i8
%20 = load i64, i64* %2
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %20
store i8 %19, i8* %21
br label %22
22: ; preds = %17
%23 = load i64, i64* %2
%24 = add i64 %23, 1
store i64 %24, i64* %2
br label %5
25: ; preds = %16, %5
%26 = load i64, i64* %2
%27 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %26
store i8 0, i8* %27
%28 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%29 = call i64 @save(i8* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %25
ret void
32: ; preds = %25
%33 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%37 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.1 = [32 x i8] c"To resume, say \22adventure %s\22.\0A\00"
@.str.2 = [52 x i8] c"\22With these rooms I might now have been familiarly \00"
@str = [47 x i8] c"What would you like to call the saved version?\00"
@str.4 = [13 x i8] c"acquainted.\22\00"
define void @ciao() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %0, %11
%5 = phi i64 [ 0, %0 ], [ %14, %11 ]
%6 = tail call i32 (...) @getchar()
%7 = icmp eq i32 %6, 10
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %6, %8
%10 = select i1 %7, i1 true, i1 %9
br i1 %10, label %16, label %11
11: ; preds = %4
%12 = trunc i32 %6 to i8
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %5
store i8 %12, i8* %13
%14 = add nuw nsw i64 %5, 1
%15 = icmp eq i64 %14, 79
br i1 %15, label %16, label %4
16: ; preds = %4, %11
%17 = phi i64 [ %5, %4 ], [ 79, %11 ]
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %17
store i8 0, i8* %18
%19 = call i64 @save(i8* %2)
%20 = icmp eq i64 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %16
ret void
22: ; preds = %16
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.4, i64 0, i64 0))
%26 = call i32 @exit(i32 0)
unreachable
}