#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;
};

/* Variables and functions */
scalar_t__ S_ISDIR(int /*<<< orphan*/);
scalar_t__ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int /*<<< orphan*/ stat(char *, struct stat *);
bool response_check_public_object(char *target, const char *objname) {
  struct stat st;
  sprintf(target,
          "www"
          "%s",
          objname);
  stat(target, &st);
  return S_ISDIR(st.st_mode) || S_ISREG(st.st_mode);
}


x86 assembly (clang, -O0):
<response_check_public_object>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xea1(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <stat@plt>
mov    -0x18(%rbp),%edi
call   1030 <S_ISDIR@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
jne    119d <response_check_public_object+0x5d>
mov    -0x18(%rbp),%edi
call   1050 <S_ISREG@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<response_check_public_object>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rdx
mov    %rdi,%rbx
lea    0xeae(%rip),%rsi
call   1060 <sprintf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <stat@plt>
mov    0x8(%rsp),%ebx
mov    %ebx,%edi
call   1030 <S_ISDIR@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    118e <response_check_public_object+0x4e>
mov    %ebx,%edi
call   1050 <S_ISREG@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [6 x i8] c"www%s\00"
define i32 @response_check_public_object(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.stat
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = load i8*, i8** %4
%8 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i8*, i8** %3
%10 = call i32 @stat(i8* %9, %struct.stat* %5)
%11 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i64 @S_ISDIR(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %2
%16 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%17 = load i32, i32* %16
%18 = call i64 @S_ISREG(i32 %17)
%19 = icmp ne i64 %18, 0
br label %20
20: ; preds = %15, %2
%21 = phi i1 [ true, %2 ], [ %19, %15 ]
%22 = zext i1 %21 to i32
ret i32 %22
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [6 x i8] c"www%s\00"
define i32 @response_check_public_object(i8* nocapture %0, i8* %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %1)
%6 = call i32 @stat(i8* %0, %struct.stat* %3)
%7 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%8 = load i32, i32* %7
%9 = tail call i64 @S_ISDIR(i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = tail call i64 @S_ISREG(i32 %8)
%13 = icmp ne i64 %12, 0
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %11, %2
%16 = phi i32 [ 1, %2 ], [ %14, %11 ]
ret i32 %16
}