#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
void readfn(char *name) {
  static char buf[32] = "cliche";
  strcpy(name, buf);
  printf("\nEnter filename [%s] ? ", buf);
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%s", name);
  strcpy(buf, name);
}


x86 assembly (clang, -O0):
<readfn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0x2ef9(%rip),%rsi
call   1030 <strcpy@plt>
lea    0xe9d(%rip),%rdi
lea    0x2ee6(%rip),%rsi
call   1040 <printf@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%edx
lea    0x2ed1(%rip),%rdi
mov    $0x20,%esi
call   1050 <fgets@plt>
mov    -0x8(%rbp),%rdx
lea    0x2ebc(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1060 <sscanf@plt>
mov    -0x8(%rbp),%rsi
lea    0x2ea5(%rip),%rdi
call   1030 <strcpy@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readfn>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x2f02(%rip),%r14
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xea3(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x20,%esi
call   1050 <fgets@plt>
lea    0xe96(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1060 <sscanf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@readfn.buf = internal global [32 x i8] c"cliche\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [24 x i8] c"\0AEnter filename [%s] ? \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define void @readfn(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @readfn.buf, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @readfn.buf, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @readfn.buf, i64 0, i64 0), i32 32, i32 %6)
%8 = load i8*, i8** %2
%9 = call i32 @sscanf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @readfn.buf, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %2
%11 = call i32 @strcpy(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @readfn.buf, i64 0, i64 0), i8* %10)
ret void
}

LLVM IR (-O2):
@readfn.buf = internal global [32 x i8] c"cliche\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [24 x i8] c"\0AEnter filename [%s] ? \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define void @readfn(i8* %0) {
%2 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @readfn.buf, i64 0, i64 0))
%3 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @readfn.buf, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = tail call i32 @fgets(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @readfn.buf, i64 0, i64 0), i32 32, i32 %4)
%6 = tail call i32 @sscanf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @readfn.buf, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%7 = tail call i32 @strcpy(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @readfn.buf, i64 0, i64 0), i8* %0)
ret void
}