#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 checkpath(char *, char const *, char const *);
int /*<<< orphan*/ makedospath(char *, char *);
int /*<<< orphan*/ printf(char *, char const *, char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char tolower(char);
void askpath(char *oldpath, const char *text, const char *testfile) {
  char testpath[300], path[300];
  int ok = 1;
  makedospath(oldpath, path);
  do {
    printf("%s directory (old: \"%s\", abort with 'q'): ", text, oldpath);
    scanf("%199s", testpath);
    if (strlen(testpath) == 1 && tolower(testpath[0]) == 'q') {
      return;
    }
    if (strlen(testpath) == 0) {
      strcpy(testpath, path);
    }
    makedospath(testpath, path);
    if (testfile) {
      ok = checkpath(path, testfile, text);
    }
  } while (!ok);
  strcpy(oldpath, path);
}


x86 assembly (clang, -O0):
<askpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x290,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x1,-0x284(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x280(%rbp),%rsi
call   1040 <makedospath@plt>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe50(%rip),%rdi
call   1060 <printf@plt>
lea    -0x150(%rbp),%rsi
lea    0xe68(%rip),%rdi
call   1090 <scanf@plt>
lea    -0x150(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x1,%eax
jne    11fa <askpath+0x8a>
movsbl -0x150(%rbp),%edi
call   1080 <tolower@plt>
movsbl %al,%eax
cmp    $0x71,%eax
jne    11fa <askpath+0x8a>
jmp    1283 <askpath+0x113>
lea    -0x150(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
jne    1222 <askpath+0xb2>
lea    -0x150(%rbp),%rdi
lea    -0x280(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x150(%rbp),%rdi
lea    -0x280(%rbp),%rsi
call   1040 <makedospath@plt>
cmpq   $0x0,-0x18(%rbp)
je     125a <askpath+0xea>
lea    -0x280(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1070 <checkpath@plt>
mov    %eax,-0x284(%rbp)
jmp    125f <askpath+0xef>
cmpl   $0x0,-0x284(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11a1 <askpath+0x31>
mov    -0x8(%rbp),%rdi
lea    -0x280(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x290,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<askpath>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x268,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%r12
mov    %r12,%rsi
call   1040 <makedospath@plt>
mov    $0x1,%ebp
lea    0x130(%rsp),%r13
jmp    11b9 <askpath+0x49>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %ebp,%ebp
mov    $0x0,%ebp
jne    1234 <askpath+0xc4>
lea    0xe40(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <printf@plt>
lea    0xe59(%rip),%rdi
mov    %r13,%rsi
call   1090 <scanf@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
cmp    $0x1,%eax
jne    11f8 <askpath+0x88>
movsbl 0x130(%rsp),%edi
call   1080 <tolower@plt>
cmp    $0x71,%al
je     123f <askpath+0xcf>
mov    %r13,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jne    120f <askpath+0x9f>
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <makedospath@plt>
test   %r15,%r15
je     11b0 <askpath+0x40>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1070 <checkpath@plt>
mov    %eax,%ebp
jmp    11b0 <askpath+0x40>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
add    $0x268,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"%s directory (old: \22%s\22, abort with 'q'): \00"
@.str.1 = [6 x i8] c"%199s\00"
define void @askpath(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [300 x i8]
%8 = alloca [300 x i8]
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 1, i32* %9
%10 = load i8*, i8** %4
%11 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%12 = call i32 @makedospath(i8* %10, i8* %11)
br label %13
13: ; preds = %49, %3
%14 = load i8*, i8** %5
%15 = load i8*, i8** %4
%16 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %15)
%17 = getelementptr inbounds [300 x i8], [300 x i8]* %7, i64 0, i64 0
%18 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [300 x i8], [300 x i8]* %7, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %29
22: ; preds = %13
%23 = getelementptr inbounds [300 x i8], [300 x i8]* %7, i64 0, i64 0
%24 = load i8, i8* %23
%25 = call signext i8 @tolower(i8 signext %24)
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 113
br i1 %27, label %28, label %29
28: ; preds = %22
br label %57
29: ; preds = %22, %13
%30 = getelementptr inbounds [300 x i8], [300 x i8]* %7, i64 0, i64 0
%31 = call i32 @strlen(i8* %30)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = getelementptr inbounds [300 x i8], [300 x i8]* %7, i64 0, i64 0
%35 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%36 = call i32 @strcpy(i8* %34, i8* %35)
br label %37
37: ; preds = %33, %29
%38 = getelementptr inbounds [300 x i8], [300 x i8]* %7, i64 0, i64 0
%39 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%40 = call i32 @makedospath(i8* %38, i8* %39)
%41 = load i8*, i8** %6
%42 = icmp ne i8* %41, null
br i1 %42, label %43, label %48
43: ; preds = %37
%44 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%45 = load i8*, i8** %6
%46 = load i8*, i8** %5
%47 = call i32 @checkpath(i8* %44, i8* %45, i8* %46)
store i32 %47, i32* %9
br label %48
48: ; preds = %43, %37
br label %49
49: ; preds = %48
%50 = load i32, i32* %9
%51 = icmp ne i32 %50, 0
%52 = xor i1 %51, true
br i1 %52, label %13, label %53
53: ; preds = %49
%54 = load i8*, i8** %4
%55 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%56 = call i32 @strcpy(i8* %54, i8* %55)
br label %57
57: ; preds = %53, %28
ret void
}

LLVM IR (-O2):
@.str = [43 x i8] c"%s directory (old: \22%s\22, abort with 'q'): \00"
@.str.1 = [6 x i8] c"%199s\00"
define void @askpath(i8* %0, i8* %1, i8* %2) {
%4 = alloca [300 x i8]
%5 = alloca [300 x i8]
%6 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%8 = call i32 @makedospath(i8* %0, i8* %7)
%9 = icmp eq i8* %2, null
br label %10
10: ; preds = %29, %3
%11 = phi i32 [ 1, %3 ], [ 0, %29 ]
%12 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %0)
%13 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%14 = call i32 @strlen(i8* %6)
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %20
16: ; preds = %10
%17 = load i8, i8* %6
%18 = call signext i8 @tolower(i8 signext %17)
%19 = icmp eq i8 %18, 113
br i1 %19, label %34, label %20
20: ; preds = %16, %10
%21 = call i32 @strlen(i8* %6)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @strcpy(i8* %6, i8* %7)
br label %25
25: ; preds = %23, %20
%26 = call i32 @makedospath(i8* %6, i8* %7)
br i1 %9, label %29, label %27
27: ; preds = %25
%28 = call i32 @checkpath(i8* %7, i8* %2, i8* %1)
br label %29
29: ; preds = %25, %27
%30 = phi i32 [ %28, %27 ], [ %11, %25 ]
%31 = icmp eq i32 %30, 0
br i1 %31, label %10, label %32
32: ; preds = %29
%33 = call i32 @strcpy(i8* %0, i8* %7)
br label %34
34: ; preds = %16, %32
ret void
}