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

/* Variables and functions */
int S_IWUSR;
int /*<<< orphan*/ printf(char *, char const *const);
int /*<<< orphan*/ stat(char const *const, struct stat *);
int main(int argc, char *argv[]) {
  const char *const file_name = argv[1];
  struct stat buf;
  stat(file_name, &buf);
  if (buf.st_mode & S_IWUSR) {
    printf("owning user can wirte '%s' .\n", file_name);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <stat@plt>
mov    -0x20(%rbp),%eax
mov    0x2e8f(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1174 <main+0x54>
mov    -0x18(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x8(%rsi),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <stat@plt>
mov    0x2eab(%rip),%rax
mov    (%rax),%eax
test   %eax,0x8(%rsp)
je     1154 <main+0x34>
lea    0xeb4(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@S_IWUSR = global i32 0
@.str = [30 x i8] c"owning user can wirte '%s' .\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = call i32 @stat(i8* %11, %struct.stat* %7)
%13 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%14 = load i32, i32* %13
%15 = load i32, i32* @S_IWUSR
%16 = and i32 %14, %15
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i8*, i8** %6
%20 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %2
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@S_IWUSR = global i32 0
@.str = [30 x i8] c"owning user can wirte '%s' .\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = bitcast %struct.stat* %3 to i8*
%7 = call i32 @stat(i8* %5, %struct.stat* %3)
%8 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%9 = load i32, i32* %8
%10 = load i32, i32* @S_IWUSR
%11 = and i32 %10, %9
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %2
%14 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %15
15: ; preds = %13, %2
ret i32 0
}