#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 */
struct stat {
  int /*<<< orphan*/ st_mode;
};
typedef int /*<<< orphan*/ path;

/* Variables and functions */
int /*<<< orphan*/ S_ISDIR(int /*<<< orphan*/);
int /*<<< orphan*/ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ abort();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ strncat(char *, char *, int);
int main(int argc, char *argv[]) {
  char path[1024] = "/";
  struct stat buf;
  strncat(path, argv[0], sizeof(path) - 2);
  if (stat(".", &buf) != 0 || !S_ISDIR(buf.st_mode))
    abort();
  if (stat(path, &buf) != 0 || !S_ISREG(buf.st_mode))
    abort();
  printf("pass\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
movb   $0x2f,-0x410(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    $0x3fe,%edx
call   1070 <strncat@plt>
lea    0xe2e(%rip),%rdi
lea    -0x418(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0x0,%rax
jne    11fc <main+0x7c>
mov    -0x418(%rbp),%edi
call   1050 <S_ISDIR@plt>
cmp    $0x0,%eax
jne    1203 <main+0x83>
mov    $0x0,%al
call   1030 <abort@plt>
lea    -0x410(%rbp),%rdi
lea    -0x418(%rbp),%rsi
call   1080 <stat@plt>
cmp    $0x0,%rax
jne    1234 <main+0xb4>
mov    -0x418(%rbp),%edi
call   1090 <S_ISREG@plt>
cmp    $0x0,%eax
jne    123b <main+0xbb>
mov    $0x0,%al
call   1030 <abort@plt>
lea    0xdc0(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%rbx
lea    0x10(%rsp),%r14
mov    $0x400,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
movb   $0x2f,0x10(%rsp)
mov    (%rbx),%rsi
mov    %r14,%rdi
mov    $0x3fe,%edx
call   1070 <strncat@plt>
lea    0xe43(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1080 <stat@plt>
test   %rax,%rax
jne    11fa <main+0x7a>
mov    0x8(%rsp),%edi
call   1050 <S_ISDIR@plt>
test   %eax,%eax
je     11fa <main+0x7a>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1080 <stat@plt>
test   %rax,%rax
jne    11fa <main+0x7a>
mov    0x8(%rsp),%edi
call   1090 <S_ISREG@plt>
test   %eax,%eax
jne    1201 <main+0x81>
xor    %eax,%eax
call   1030 <abort@plt>
lea    0xdfa(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [2 x i8] c".\00"
@.str.1 = [6 x i8] c"pass\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [1024 x i8]* %6 to i8*
%9 = bitcast i8* %8 to [1024 x i8]*
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i32 0, i32 0
store i8 47, i8* %10
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @strncat(i8* %11, i8* %14, i32 1022)
%16 = call i64 @stat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %struct.stat* %7)
%17 = icmp ne i64 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %2
%19 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%20 = load i32, i32* %19
%21 = call i32 @S_ISDIR(i32 %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %18, %2
%24 = call i32 (...) @abort()
unreachable
25: ; preds = %18
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%27 = call i64 @stat(i8* %26, %struct.stat* %7)
%28 = icmp ne i64 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %25
%30 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%31 = load i32, i32* %30
%32 = call i32 @S_ISREG(i32 %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %29, %25
%35 = call i32 (...) @abort()
unreachable
36: ; preds = %29
%37 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%38 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [2 x i8] c".\00"
@str = [5 x i8] c"pass\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca %struct.stat
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
store i8 47, i8* %5
%6 = bitcast %struct.stat* %4 to i8*
%7 = load i8*, i8** %1
%8 = call i32 @strncat(i8* %5, i8* %7, i32 1022)
%9 = call i64 @stat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %struct.stat* %4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%13 = load i32, i32* %12
%14 = call i32 @S_ISDIR(i32 %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11, %2
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %11
%19 = call i64 @stat(i8* %5, %struct.stat* %4)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i32, i32* %12
%23 = call i32 @S_ISREG(i32 %22)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21, %18
%26 = call i32 (...) @abort()
unreachable
27: ; preds = %21
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%29 = call i32 @exit(i32 0)
unreachable
}