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

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int lstat(char *, struct stat *);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int dostat(char *path, struct stat *st, int do_lstat, int quiet) {
  int n;
  if (do_lstat)
    n = lstat(path, st);
  else
    n = stat(path, st);
  if (n != 0) {
    if (!quiet)
      fprintf(stderr, "mountpoint: %s: %s\n", path, strerror(errno));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<dostat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1175 <dostat+0x35>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <lstat@plt>
mov    %eax,-0x24(%rbp)
jmp    1185 <dostat+0x45>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <stat@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11dd <dostat+0x9d>
cmpl   $0x0,-0x20(%rbp)
jne    11d1 <dostat+0x91>
mov    0x2e40(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    %rax,%rcx
lea    0xe34(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e4 <dostat+0xa4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dostat>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%r14d
mov    %rdi,%rbx
test   %edx,%edx
je     1190 <dostat+0x50>
call   1030 <lstat@plt>
test   %eax,%eax
je     1199 <dostat+0x59>
mov    $0xffffffff,%ebp
test   %r14d,%r14d
jne    119b <dostat+0x5b>
mov    0x2e78(%rip),%rax
mov    (%rax),%r14d
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe80(%rip),%rsi
mov    %r14d,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1040 <fprintf@plt>
jmp    119b <dostat+0x5b>
call   1050 <stat@plt>
test   %eax,%eax
jne    1157 <dostat+0x17>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [20 x i8] c"mountpoint: %s: %s\0A\00"
@errno = global i32 0
define i32 @dostat(i8* %0, %struct.stat* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca %struct.stat*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store %struct.stat* %1, %struct.stat** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%11 = load i32, i32* %8
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %4
%14 = load i8*, i8** %6
%15 = load %struct.stat*, %struct.stat** %7
%16 = call i32 @lstat(i8* %14, %struct.stat* %15)
store i32 %16, i32* %10
br label %21
17: ; preds = %4
%18 = load i8*, i8** %6
%19 = load %struct.stat*, %struct.stat** %7
%20 = call i32 @stat(i8* %18, %struct.stat* %19)
store i32 %20, i32* %10
br label %21
21: ; preds = %17, %13
%22 = load i32, i32* %10
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = load i32, i32* %9
%26 = icmp ne i32 %25, 0
br i1 %26, label %33, label %27
27: ; preds = %24
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %6
%30 = load i32, i32* @errno
%31 = call i8* @strerror(i32 %30)
%32 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %29, i8* %31)
br label %33
33: ; preds = %27, %24
store i32 -1, i32* %5
br label %35
34: ; preds = %21
store i32 0, i32* %5
br label %35
35: ; preds = %34, %33
%36 = load i32, i32* %5
ret i32 %36
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [20 x i8] c"mountpoint: %s: %s\0A\00"
@errno = global i32 0
define i32 @dostat(i8* %0, %struct.stat* nocapture %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %2, 0
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = tail call i32 @lstat(i8* %0, %struct.stat* %1)
br label %10
8: ; preds = %4
%9 = tail call i32 @stat(i8* %0, %struct.stat* %1)
br label %10
10: ; preds = %8, %6
%11 = phi i32 [ %7, %6 ], [ %9, %8 ]
%12 = icmp eq i32 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %10
%14 = icmp eq i32 %3, 0
br i1 %14, label %15, label %20
15: ; preds = %13
%16 = load i32, i32* @stderr
%17 = load i32, i32* @errno
%18 = tail call i8* @strerror(i32 %17)
%19 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %18)
br label %20
20: ; preds = %10, %13, %15
%21 = phi i32 [ -1, %15 ], [ -1, %13 ], [ 0, %10 ]
ret i32 %21
}