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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ errx(int /*<<< orphan*/, char *);
int /*<<< orphan*/ getresuid(scalar_t__ *, scalar_t__ *, scalar_t__ *);
scalar_t__ setresuid(scalar_t__, scalar_t__, scalar_t__);
void force_identity() {
  uid_t ruid, euid, suid;
  getresuid(&ruid, &euid, &suid);
  if (ruid != 0 && setresuid(euid, euid, euid) < 0)
    errx(EXIT_FAILURE, "Can't elevate to root permissions required by udhdpc");
}


x86 assembly (clang, -O0):
<force_identity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <getresuid@plt>
cmpq   $0x0,-0x8(%rbp)
je     1184 <force_identity+0x54>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <setresuid@plt>
cmp    $0x0,%rax
jge    1184 <force_identity+0x54>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
call   1040 <errx@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<force_identity>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
lea    0x10(%rsp),%rdx
call   1050 <getresuid@plt>
cmpq   $0x0,0x8(%rsp)
je     1162 <force_identity+0x32>
mov    (%rsp),%rdi
mov    %rdi,%rsi
mov    %rdi,%rdx
call   1030 <setresuid@plt>
test   %rax,%rax
js     1167 <force_identity+0x37>
add    $0x18,%rsp
ret
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
call   1040 <errx@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [53 x i8] c"Can't elevate to root permissions required by udhdpc\00"
define void @force_identity() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = call i32 @getresuid(i64* %1, i64* %2, i64* %3)
%5 = load i64, i64* %1
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %0
%8 = load i64, i64* %2
%9 = load i64, i64* %2
%10 = load i64, i64* %2
%11 = call i64 @setresuid(i64 %8, i64 %9, i64 %10)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @errx(i32 %14, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %13, %7, %0
ret void
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [53 x i8] c"Can't elevate to root permissions required by udhdpc\00"
define void @force_identity() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i64* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = call i32 @getresuid(i64* %1, i64* %2, i64* %3)
%8 = load i64, i64* %1
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %0
%11 = load i64, i64* %2
%12 = call i64 @setresuid(i64 %11, i64 %11, i64 %11)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @errx(i32 %15, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %14, %10, %0
ret void
}