#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 */
typedef scalar_t__ uid_t;
struct stat {
  scalar_t__ st_uid;
  scalar_t__ st_gid;
};
typedef scalar_t__ gid_t;

/* Variables and functions */
int /*<<< orphan*/ _fstat(int, struct stat *);
int _mkstemp(char *);
int /*<<< orphan*/ _unlink(char *);
int check_fsid(uid_t uid, gid_t gid) {
  int fd;
  char path[] = "/tmp/testfsuidsupp.XXXXXX";
  struct stat sb;
  fd = _mkstemp(path);
  _fstat(fd, &sb);
  _unlink(path);
  return (sb.st_uid == uid && sb.st_gid == gid);
}


x86 assembly (clang, -O0):
<check_fsid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeb9(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb6(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb0(%rip),%ax
mov    %ax,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <_mkstemp@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   1050 <_fstat@plt>
lea    -0x30(%rbp),%rdi
call   1030 <_unlink@plt>
mov    -0x40(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x41(%rbp)
jne    11ae <check_fsid+0x7e>
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
sete   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_fsid>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movups 0xec4(%rip),%xmm0
movups %xmm0,0x1a(%rsp)
movaps 0xeae(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%r15
mov    %r15,%rdi
call   1040 <_mkstemp@plt>
mov    %rsp,%rsi
mov    %eax,%edi
call   1050 <_fstat@plt>
mov    %r15,%rdi
call   1030 <_unlink@plt>
xor    (%rsp),%r14
xor    0x8(%rsp),%rbx
xor    %eax,%eax
or     %r14,%rbx
sete   %al
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.stat = type { i64, i64 }
@__const.check_fsid.path = [26 x i8] c"/tmp/testfsuidsupp.XXXXXX\00"
define i32 @check_fsid(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca [26 x i8]
%7 = alloca %struct.stat
store i64 %0, i64* %3
store i64 %1, i64* %4
%8 = bitcast [26 x i8]* %6 to i8*
%9 = getelementptr inbounds [26 x i8], [26 x i8]* %6, i64 0, i64 0
%10 = call i32 @_mkstemp(i8* %9)
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = call i32 @_fstat(i32 %11, %struct.stat* %7)
%13 = getelementptr inbounds [26 x i8], [26 x i8]* %6, i64 0, i64 0
%14 = call i32 @_unlink(i8* %13)
%15 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%16 = load i64, i64* %15
%17 = load i64, i64* %3
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %24
19: ; preds = %2
%20 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%21 = load i64, i64* %20
%22 = load i64, i64* %4
%23 = icmp eq i64 %21, %22
br label %24
24: ; preds = %19, %2
%25 = phi i1 [ false, %2 ], [ %23, %19 ]
%26 = zext i1 %25 to i32
ret i32 %26
}

LLVM IR (-O2):
%struct.stat = type { i64, i64 }
@__const.check_fsid.path = [26 x i8] c"/tmp/testfsuidsupp.XXXXXX\00"
define i32 @check_fsid(i64 %0, i64 %1) {
%3 = alloca [26 x i8]
%4 = alloca %struct.stat
%5 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.stat* %4 to i8*
%7 = call i32 @_mkstemp(i8* %5)
%8 = call i32 @_fstat(i32 %7, %struct.stat* %4)
%9 = call i32 @_unlink(i8* %5)
%10 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%11 = load i64, i64* %10
%12 = icmp eq i64 %11, %0
%13 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%14 = load i64, i64* %13
%15 = icmp eq i64 %14, %1
%16 = select i1 %12, i1 %15, i1 false
%17 = zext i1 %16 to i32
ret i32 %17
}