#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 */
char *fileContents(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int strlen(char *);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ touch(char *);
int main() {
  int L;
  printf("Enter minimum lengths of names: ");
  scanf("%d", &L);
  touch("s.stl");
  char *cmd;
  char *name;
  char nameArray[2048];
  float R;
  cmd = malloc(4096);
  while (1) {
    sprintf(cmd, "./StringCreate s.stl --stopX -l %d > name.txt", L);
    system(cmd);
    name = fileContents("name.txt");
    printf("Rate the following name: %sRating [-1 to 1 or Ctrl-C to quit]: ",
           name);
    name[strlen(name) - 1] = 'X';
    scanf("%f", &R);
    sprintf(cmd, "./StringLearn %s -r %f -s s.stl", name, R);
    system(cmd);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe7a(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xef6(%rip),%rdi
call   1030 <touch@plt>
mov    $0x1000,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe4a(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <system@plt>
lea    0xe58(%rip),%rdi
call   1090 <fileContents@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x830(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x830(%rbp),%rax
sub    $0x1,%ecx
mov    %ecx,-0x828(%rbp)
movslq %ecx,%rcx
movb   $0x58,(%rax,%rcx,1)
lea    0xe52(%rip),%rdi
lea    -0x824(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movss  -0x824(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xe2c(%rip),%rsi
mov    $0x1,%al
call   10a0 <sprintf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <system@plt>
jmp    11cc <main+0x4c>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe6e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe81(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0xefc(%rip),%rdi
call   1030 <touch@plt>
mov    $0x1000,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe86(%rip),%r12
lea    0xebf(%rip),%r13
mov    %rsp,%rbp
lea    0xeb8(%rip),%r14
nopl   (%rax)
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
lea    0xe36(%rip),%rsi
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
lea    0xe45(%rip),%rdi
call   1090 <fileContents@plt>
mov    %rax,%r15
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x58,-0x1(%rax,%r15,1)
mov    %r13,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    $0x1,%al
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
jmp    11e0 <main+0x60>

LLVM IR (-O0):
@.str = [33 x i8] c"Enter minimum lengths of names: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"s.stl\00"
@.str.3 = [46 x i8] c"./StringCreate s.stl --stopX -l %d > name.txt\00"
@.str.4 = [9 x i8] c"name.txt\00"
@.str.5 = [64 x i8] c"Rate the following name: %sRating [-1 to 1 or Ctrl-C to quit]: \00"
@.str.6 = [3 x i8] c"%f\00"
@.str.7 = [32 x i8] c"./StringLearn %s -r %f -s s.stl\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [2048 x i8]
%6 = alloca float
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = call i32 @touch(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%10 = call i8* @malloc(i32 4096)
store i8* %10, i8** %3
br label %11
11: ; preds = %0, %11
%12 = load i8*, i8** %3
%13 = load i32, i32* %2
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = load i8*, i8** %3
%16 = call i32 @system(i8* %15)
%17 = call i8* @fileContents(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %4
%21 = load i8*, i8** %4
%22 = call i32 @strlen(i8* %21)
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %20, i64 %24
store i8 88, i8* %25
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), float* %6)
%27 = load i8*, i8** %3
%28 = load i8*, i8** %4
%29 = load float, float* %6
%30 = fpext float %29 to double
%31 = call i32 (i8*, i8*, ...) @sprintf(i8* %27, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i8* %28, double %30)
%32 = load i8*, i8** %3
%33 = call i32 @system(i8* %32)
br label %11
}

LLVM IR (-O2):
@.str = [33 x i8] c"Enter minimum lengths of names: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"s.stl\00"
@.str.3 = [46 x i8] c"./StringCreate s.stl --stopX -l %d > name.txt\00"
@.str.4 = [9 x i8] c"name.txt\00"
@.str.5 = [64 x i8] c"Rate the following name: %sRating [-1 to 1 or Ctrl-C to quit]: \00"
@.str.6 = [3 x i8] c"%f\00"
@.str.7 = [32 x i8] c"./StringLearn %s -r %f -s s.stl\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = call i32 @touch(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%7 = bitcast float* %2 to i8*
%8 = call dereferenceable_or_null(4096) i8* @malloc(i32 4096)
br label %9
9: ; preds = %9, %0
%10 = load i32, i32* %1
%11 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %8, i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = call i32 @system(i8* %8)
%13 = call i8* @fileContents(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.5, i64 0, i64 0), i8* %13)
%15 = call i32 @strlen(i8* %13)
%16 = add nsw i32 %15, -1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %13, i64 %17
store i8 88, i8* %18
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), float* %2)
%20 = load float, float* %2
%21 = fpext float %20 to double
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %8, i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i8* %13, double %21)
%23 = call i32 @system(i8* %8)
br label %9
}