#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*/ clear_stdin();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int const);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void get_output_filename(char *outFile) {
  int flag;
  char s[200];
  const int fname_len = 200 - strlen("Model/") - 4;
  do {
    flag = 0;
    char specifier[200];
    sprintf(specifier, "%d", fname_len);
    printf("\x1b["
           "1"
           "m"
           "\nInsert a filename for the modified model, without "
           "extension\n(max. %s chars): "
           "\x1b[0m",
           specifier);
    sprintf(specifier, "%%%ds", fname_len);
    scanf(specifier, s);
    clear_stdin();
    if (strchr(s, '/') != NULL) {
      printf("\x1b["
             "1"
             ";3"
             "1"
             "m"
             "\nFilename cannot contain any '/' character. "
             "Please retry.\n"
             "\x1b[0m");
      flag = 1;
      continue;
    }
    strcat(s, ".ply");
  } while (flag);
  strcpy(outFile, "Model/");
  strcat(outFile, s);
}


x86 assembly (clang, -O0):
<get_output_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe6a(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    $0xc8,%eax
sub    %ecx,%eax
sub    $0x4,%eax
mov    %eax,-0xe4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x1b0(%rbp),%rdi
mov    -0xe4(%rbp),%edx
lea    0xe3f(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x1b0(%rbp),%rsi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x1b0(%rbp),%rdi
mov    -0xe4(%rbp),%edx
lea    0xe6b(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x1b0(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1080 <scanf@plt>
mov    $0x0,%al
call   1040 <clear_stdin@plt>
lea    -0xe0(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
je     124a <get_output_filename+0xca>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0xc(%rbp)
jmp    125d <get_output_filename+0xdd>
lea    -0xe0(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1090 <strcat@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11ad <get_output_filename+0x2d>
mov    -0x8(%rbp),%rdi
lea    0xd8e(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1090 <strcat@plt>
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_output_filename>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
mov    %rdi,0x8(%rsp)
lea    0xe63(%rip),%rdi
call   1050 <strlen@plt>
mov    $0xc4,%ebp
sub    %eax,%ebp
lea    0xe0(%rsp),%rbx
lea    0xe52(%rip),%r12
lea    0xea2(%rip),%r13
lea    0x10(%rsp),%r14
lea    0xe9c(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
lea    0xe2d(%rip),%rsi
mov    %ebp,%edx
call   10a0 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1040 <clear_stdin@plt>
mov    %r14,%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     122b <get_output_filename+0xab>
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    11d0 <get_output_filename+0x50>
lea    0xe7b(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1090 <strcat@plt>
lea    0xdba(%rip),%rsi
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1090 <strcat@plt>
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Model/\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [87 x i8] c"\1B[1m\0AInsert a filename for the modified model, without extension\0A(max. %s chars): \1B[0m\00"
@.str.3 = [6 x i8] c"%%%ds\00"
@.str.4 = [70 x i8] c"\1B[1;31m\0AFilename cannot contain any '/' character. Please retry.\0A\1B[0m\00"
@.str.5 = [5 x i8] c".ply\00"
define void @get_output_filename(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [200 x i8]
%5 = alloca i32
%6 = alloca [200 x i8]
store i8* %0, i8** %2
%7 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = sub nsw i32 200, %7
%9 = sub nsw i32 %8, 4
store i32 %9, i32* %5
br label %10
10: ; preds = %31, %1
store i32 0, i32* %3
%11 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%12 = load i32, i32* %5
%13 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%17 = load i32, i32* %5
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%20 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%21 = call i32 @scanf(i8* %19, i8* %20)
%22 = call i32 (...) @clear_stdin()
%23 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%24 = call i32* @strchr(i8* %23, i8 signext 47)
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %28
26: ; preds = %10
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %31
28: ; preds = %10
%29 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%30 = call i32 @strcat(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %31
31: ; preds = %28, %26
%32 = load i32, i32* %3
%33 = icmp ne i32 %32, 0
br i1 %33, label %10, label %34
34: ; preds = %31
%35 = load i8*, i8** %2
%36 = call i32 @strcpy(i8* %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%37 = load i8*, i8** %2
%38 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%39 = call i32 @strcat(i8* %37, i8* %38)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"Model/\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [87 x i8] c"\1B[1m\0AInsert a filename for the modified model, without extension\0A(max. %s chars): \1B[0m\00"
@.str.3 = [6 x i8] c"%%%ds\00"
@.str.4 = [70 x i8] c"\1B[1;31m\0AFilename cannot contain any '/' character. Please retry.\0A\1B[0m\00"
@.str.5 = [5 x i8] c".ply\00"
define void @get_output_filename(i8* %0) {
%2 = alloca [200 x i8]
%3 = alloca [200 x i8]
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = sub i32 196, %5
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
br label %8
8: ; preds = %16, %1
%9 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([87 x i8], [87 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%11 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%12 = call i32 @scanf(i8* %7, i8* %4)
%13 = call i32 (...) @clear_stdin()
%14 = call i32* @strchr(i8* %4, i8 signext 47)
%15 = icmp eq i32* %14, null
br i1 %15, label %18, label %16
16: ; preds = %8
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.4, i64 0, i64 0))
br label %8
18: ; preds = %8
%19 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @strcat(i8* %0, i8* %4)
ret void
}