#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*/ _exit(int);
int /*<<< orphan*/ droproot();
int /*<<< orphan*/ dropuidgid(int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/);
int /*<<< orphan*/ getegid();
int /*<<< orphan*/ geteuid();
void test2(void) {
  droproot();
  if (!dropuidgid(0, geteuid(), getegid()))
    _exit(111);
  if (!dropuidgid(0, geteuid(), getegid()))
    _exit(111);
  _exit(0);
}


x86 assembly (clang, -O0):
<test2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <droproot@plt>
mov    $0x0,%al
call   1050 <geteuid@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1070 <getegid@plt>
mov    -0x4(%rbp),%esi
mov    %eax,%edx
xor    %edi,%edi
call   1060 <dropuidgid@plt>
cmp    $0x0,%eax
jne    118f <test2+0x3f>
mov    $0x6f,%edi
call   1030 <_exit@plt>
mov    $0x0,%al
call   1050 <geteuid@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1070 <getegid@plt>
mov    -0x8(%rbp),%esi
mov    %eax,%edx
xor    %edi,%edi
call   1060 <dropuidgid@plt>
cmp    $0x0,%eax
jne    11bf <test2+0x6f>
mov    $0x6f,%edi
call   1030 <_exit@plt>
xor    %edi,%edi
call   1030 <_exit@plt>

x86 assembly (clang, -O2):
<test2>:
push   %rbx
xor    %eax,%eax
call   1040 <droproot@plt>
xor    %eax,%eax
call   1050 <geteuid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <getegid@plt>
xor    %edi,%edi
mov    %ebx,%esi
mov    %eax,%edx
call   1060 <dropuidgid@plt>
test   %eax,%eax
je     1196 <test2+0x46>
xor    %eax,%eax
call   1050 <geteuid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <getegid@plt>
xor    %edi,%edi
mov    %ebx,%esi
mov    %eax,%edx
call   1060 <dropuidgid@plt>
test   %eax,%eax
jne    11a0 <test2+0x50>
mov    $0x6f,%edi
call   1030 <_exit@plt>
xor    %edi,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
define void @test2() {
%1 = call i32 (...) @droproot()
%2 = call i32 (...) @geteuid()
%3 = call i32 (...) @getegid()
%4 = call i32 @dropuidgid(i32 0, i32 %2, i32 %3)
%5 = icmp ne i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 @_exit(i32 111)
unreachable
8: ; preds = %0
%9 = call i32 (...) @geteuid()
%10 = call i32 (...) @getegid()
%11 = call i32 @dropuidgid(i32 0, i32 %9, i32 %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = call i32 @_exit(i32 111)
unreachable
15: ; preds = %8
%16 = call i32 @_exit(i32 0)
unreachable
}

LLVM IR (-O2):
define void @test2() {
%1 = tail call i32 (...) @droproot()
%2 = tail call i32 (...) @geteuid()
%3 = tail call i32 (...) @getegid()
%4 = tail call i32 @dropuidgid(i32 0, i32 %2, i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 @_exit(i32 111)
unreachable
8: ; preds = %0
%9 = tail call i32 (...) @geteuid()
%10 = tail call i32 (...) @getegid()
%11 = tail call i32 @dropuidgid(i32 0, i32 %9, i32 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 @_exit(i32 111)
unreachable
15: ; preds = %8
%16 = tail call i32 @_exit(i32 0)
unreachable
}