#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 */
int /*<<< orphan*/ geteuid();
scalar_t__ getuid();
int /*<<< orphan*/ printf(char *);
int check_setuid(void) {
  if (getuid() && !geteuid()) {
    printf("This mount.cifs program has been built with the "
           "ability to run as a setuid root program disabled.\n"
           "mount.cifs has not been well audited for security "
           "holes. Therefore the Samba team does not recommend "
           "installing it as a setuid root program.\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_setuid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <getuid@plt>
cmp    $0x0,%rax
je     1171 <check_setuid+0x41>
mov    $0x0,%al
call   1050 <geteuid@plt>
cmp    $0x0,%eax
jne    1171 <check_setuid+0x41>
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1178 <check_setuid+0x48>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_setuid>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getuid@plt>
test   %rax,%rax
je     115d <check_setuid+0x2d>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <geteuid@plt>
test   %eax,%eax
jne    115d <check_setuid+0x2d>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [240 x i8] c"This mount.cifs program has been built with the ability to run as a setuid root program disabled.\0Amount.cifs has not been well audited for security holes. Therefore the Samba team does not recommend installing it as a setuid root program.\0A\00"
define i32 @check_setuid() {
%1 = alloca i32
%2 = call i64 (...) @getuid()
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %9
4: ; preds = %0
%5 = call i32 (...) @geteuid()
%6 = icmp ne i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = call i32 @printf(i8* getelementptr inbounds ([240 x i8], [240 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %10
9: ; preds = %4, %0
store i32 0, i32* %1
br label %10
10: ; preds = %9, %7
%11 = load i32, i32* %1
ret i32 %11
}

LLVM IR (-O2):
@str = [239 x i8] c"This mount.cifs program has been built with the ability to run as a setuid root program disabled.\0Amount.cifs has not been well audited for security holes. Therefore the Samba team does not recommend installing it as a setuid root program.\00"
define i32 @check_setuid() {
%1 = tail call i64 (...) @getuid()
%2 = icmp eq i64 %1, 0
br i1 %2, label %8, label %3
3: ; preds = %0
%4 = tail call i32 (...) @geteuid()
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([239 x i8], [239 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %0, %3, %6
%9 = phi i32 [ 1, %6 ], [ 0, %3 ], [ 0, %0 ]
ret i32 %9
}