#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int check_path(char *path, char *name) {
  if (path[0] == '~' && (path[1] == '/' || path[1] == '\0'))
    return 0;
  if (path[0] == '.' && (path[1] == '/' || path[1] == '\0'))
    return 0;
  if (path[0] == '/')
    return 0;
  fprintf(stderr, "ERROR: %s is incorrect\n", name);
  printf("ERROR\n");
  return -1;
}


x86 assembly (clang, -O0):
<check_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7e,%eax
jne    116e <check_path+0x4e>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
je     1162 <check_path+0x42>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    116e <check_path+0x4e>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <check_path+0xd4>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11ac <check_path+0x8c>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
je     11a0 <check_path+0x80>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    11ac <check_path+0x8c>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <check_path+0xd4>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    11c8 <check_path+0xa8>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <check_path+0xd4>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe24(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_path>:
push   %rax
mov    %rsi,%rdx
mov    (%rdi),%cl
xor    %eax,%eax
cmp    $0x2e,%cl
je     1137 <check_path+0x17>
cmp    $0x2f,%cl
je     1169 <check_path+0x49>
cmp    $0x7e,%cl
jne    1143 <check_path+0x23>
mov    0x1(%rdi),%cl
test   %cl,%cl
je     1169 <check_path+0x49>
cmp    $0x2f,%cl
je     1169 <check_path+0x49>
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
lea    0xead(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"ERROR: %s is incorrect\0A\00"
@.str.1 = [7 x i8] c"ERROR\0A\00"
define i32 @check_path(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 126
br i1 %10, label %11, label %24
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 47
br i1 %16, label %23, label %17
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %17, %11
store i32 0, i32* %3
br label %55
24: ; preds = %17, %2
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 46
br i1 %29, label %30, label %43
30: ; preds = %24
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 47
br i1 %35, label %42, label %36
36: ; preds = %30
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %36, %30
store i32 0, i32* %3
br label %55
43: ; preds = %36, %24
%44 = load i8*, i8** %4
%45 = getelementptr inbounds i8, i8* %44, i64 0
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 47
br i1 %48, label %49, label %50
49: ; preds = %43
store i32 0, i32* %3
br label %55
50: ; preds = %43
%51 = load i32, i32* @stderr
%52 = load i8*, i8** %5
%53 = call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %52)
%54 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %55
55: ; preds = %50, %49, %42, %23
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"ERROR: %s is incorrect\0A\00"
@str = [6 x i8] c"ERROR\00"
define i32 @check_path(i8* nocapture %0, i8* %1) {
%3 = load i8, i8* %0
switch i8 %3, label %10 [
i8 126, label %4
i8 46, label %7
i8 47, label %14
]
4: ; preds = %2
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
switch i8 %6, label %10 [
i8 47, label %14
i8 0, label %14
]
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
switch i8 %9, label %10 [
i8 47, label %14
i8 0, label %14
]
10: ; preds = %2, %4, %7
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %1)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %14
14: ; preds = %2, %7, %7, %4, %4, %10
%15 = phi i32 [ -1, %10 ], [ 0, %4 ], [ 0, %4 ], [ 0, %7 ], [ 0, %7 ], [ 0, %2 ]
ret i32 %15
}