#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 */
scalar_t__ wfile_eitherslash(char);
int /*<<< orphan*/ wfile_fullname(char *, char *, char *);
int wfile_status(char *);
int wfile_hushit(char *filename) {
  static char dir[512], hushfile[512];
  int i;
  for (i = 0; filename[i] != '\0'; i++) {
    dir[i] = filename[i];
    dir[i + 1] = '\0';
    if (wfile_eitherslash(dir[i])) {
      wfile_fullname(hushfile, dir, ".hush");
      if (wfile_status(hushfile) == 1)
        return (-1);
    }
  }
  wfile_fullname(hushfile, dir, ".hush");
  return (wfile_status(hushfile) == 1);
}


x86 assembly (clang, -O0):
<wfile_hushit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11f6 <wfile_hushit+0xc6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
movslq -0x14(%rbp),%rcx
lea    0x2ee2(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2ecf(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
movslq -0x14(%rbp),%rcx
lea    0x2ec0(%rip),%rax
movsbl (%rax,%rcx,1),%edi
call   1030 <wfile_eitherslash@plt>
cmp    $0x0,%rax
je     11e3 <wfile_hushit+0xb3>
lea    0x30a6(%rip),%rdi
lea    0x2e9f(%rip),%rsi
lea    0xe48(%rip),%rdx
call   1050 <wfile_fullname@plt>
lea    0x308c(%rip),%rdi
call   1040 <wfile_status@plt>
cmp    $0x1,%eax
jne    11de <wfile_hushit+0xae>
movl   $0xffffffff,-0x4(%rbp)
jmp    122a <wfile_hushit+0xfa>
jmp    11e3 <wfile_hushit+0xb3>
jmp    11e8 <wfile_hushit+0xb8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1143 <wfile_hushit+0x13>
lea    0x3053(%rip),%rdi
lea    0x2e4c(%rip),%rsi
lea    0xdf5(%rip),%rdx
call   1050 <wfile_fullname@plt>
lea    0x3039(%rip),%rdi
call   1040 <wfile_status@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wfile_hushit>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     11a6 <wfile_hushit+0x76>
mov    %rdi,%r14
mov    $0x1,%ebx
lea    0x2f02(%rip),%r13
lea    0x30fb(%rip),%r15
lea    0xea4(%rip),%r12
jmp    116d <wfile_hushit+0x3d>
xchg   %ax,%ax
movzbl (%r14,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
je     11a6 <wfile_hushit+0x76>
mov    %al,-0x1(%rbx,%r13,1)
movb   $0x0,(%rbx,%r13,1)
movsbl %al,%edi
call   1030 <wfile_eitherslash@plt>
test   %rax,%rax
je     1160 <wfile_hushit+0x30>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1050 <wfile_fullname@plt>
mov    %r15,%rdi
call   1040 <wfile_status@plt>
cmp    $0x1,%eax
jne    1160 <wfile_hushit+0x30>
mov    $0xffffffff,%eax
jmp    11d5 <wfile_hushit+0xa5>
lea    0x30a3(%rip),%rbx
lea    0x2e9c(%rip),%rsi
lea    0xe45(%rip),%rdx
mov    %rbx,%rdi
call   1050 <wfile_fullname@plt>
mov    %rbx,%rdi
call   1040 <wfile_status@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
sete   %al
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@wfile_hushit.dir = internal global [512 x i8] zeroinitializer
@wfile_hushit.hushfile = internal global [512 x i8] zeroinitializer
@.str = [6 x i8] c".hush\00"
define i32 @wfile_hushit(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %39, %1
%6 = load i8*, i8** %3
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %42
13: ; preds = %5
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [512 x i8], [512 x i8]* @wfile_hushit.dir, i64 0, i64 %20
store i8 %18, i8* %21
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [512 x i8], [512 x i8]* @wfile_hushit.dir, i64 0, i64 %24
store i8 0, i8* %25
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [512 x i8], [512 x i8]* @wfile_hushit.dir, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = call i64 @wfile_eitherslash(i8 signext %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %13
%33 = call i32 @wfile_fullname(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_hushit.hushfile, i64 0, i64 0), i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_hushit.dir, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%34 = call i32 @wfile_status(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_hushit.hushfile, i64 0, i64 0))
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 -1, i32* %2
br label %47
37: ; preds = %32
br label %38
38: ; preds = %37, %13
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %5
42: ; preds = %5
%43 = call i32 @wfile_fullname(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_hushit.hushfile, i64 0, i64 0), i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_hushit.dir, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%44 = call i32 @wfile_status(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_hushit.hushfile, i64 0, i64 0))
%45 = icmp eq i32 %44, 1
%46 = zext i1 %45 to i32
store i32 %46, i32* %2
br label %47
47: ; preds = %42, %36
%48 = load i32, i32* %2
ret i32 %48
}

LLVM IR (-O2):
@wfile_hushit.dir = internal global [512 x i8] zeroinitializer
@wfile_hushit.hushfile = internal global [512 x i8] zeroinitializer
@.str = [6 x i8] c".hush\00"
define i32 @wfile_hushit(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %20, label %4
4: ; preds = %1, %16
%5 = phi i64 [ %8, %16 ], [ 0, %1 ]
%6 = phi i8 [ %18, %16 ], [ %2, %1 ]
%7 = getelementptr inbounds [512 x i8], [512 x i8]* @wfile_hushit.dir, i64 0, i64 %5
store i8 %6, i8* %7
%8 = add nuw nsw i64 %5, 1
%9 = getelementptr inbounds [512 x i8], [512 x i8]* @wfile_hushit.dir, i64 0, i64 %8
store i8 0, i8* %9
%10 = tail call i64 @wfile_eitherslash(i8 signext %6)
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %4
%13 = tail call i32 @wfile_fullname(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_hushit.hushfile, i64 0, i64 0), i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_hushit.dir, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @wfile_status(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_hushit.hushfile, i64 0, i64 0))
%15 = icmp eq i32 %14, 1
br i1 %15, label %25, label %16
16: ; preds = %4, %12
%17 = getelementptr inbounds i8, i8* %0, i64 %8
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %4
20: ; preds = %16, %1
%21 = tail call i32 @wfile_fullname(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_hushit.hushfile, i64 0, i64 0), i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_hushit.dir, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%22 = tail call i32 @wfile_status(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @wfile_hushit.hushfile, i64 0, i64 0))
%23 = icmp eq i32 %22, 1
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %12, %20
%26 = phi i32 [ %24, %20 ], [ -1, %12 ]
ret i32 %26
}