#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 void *uid_t;
typedef void *gid_t;

/* Variables and functions */
int /*<<< orphan*/ __NR_getegid;
int /*<<< orphan*/ __NR_geteuid;
int /*<<< orphan*/ __NR_getgid;
int /*<<< orphan*/ __NR_getresgid;
int /*<<< orphan*/ __NR_getresuid;
int /*<<< orphan*/ __NR_getuid;
int /*<<< orphan*/ __NR_setfsgid;
int /*<<< orphan*/ __NR_setfsuid;
int /*<<< orphan*/ __NR_setgid;
int /*<<< orphan*/ __NR_setregid;
int /*<<< orphan*/ __NR_setresgid;
int /*<<< orphan*/ __NR_setresuid;
int /*<<< orphan*/ __NR_setreuid;
int /*<<< orphan*/ __NR_setuid;
void *syscall(int /*<<< orphan*/, ...);
int main() {
  uid_t uid, ruid, euid, suid;
  gid_t gid, rgid, egid, sgid;
  uid = syscall(__NR_getuid);
  uid = syscall(__NR_geteuid);
  gid = syscall(__NR_getgid);
  gid = syscall(__NR_getegid);
  syscall(__NR_setuid, 4096);
  syscall(__NR_setresuid, -1, 4097, -1);
  syscall(__NR_getresuid, &ruid, &euid, &suid);
  syscall(__NR_setgid, 4098);
  syscall(__NR_setresgid, -1, 4099, -1);
  syscall(__NR_getresgid, &rgid, &egid, &sgid);
  syscall(__NR_setreuid, -1, 5000);
  syscall(__NR_setreuid, 5001, -1);
  syscall(__NR_setregid, -1, 5002);
  syscall(__NR_setregid, 5003, -1);
  syscall(__NR_setfsuid, 5004);
  syscall(__NR_setfsgid, 5005);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eaa(%rip),%rax
mov    (%rax),%edi
mov    $0x0,%al
call   1030 <syscall@plt>
mov    %rax,-0x10(%rbp)
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
mov    $0x0,%al
call   1030 <syscall@plt>
mov    %rax,-0x10(%rbp)
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
mov    $0x0,%al
call   1030 <syscall@plt>
mov    %rax,-0x30(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
mov    $0x0,%al
call   1030 <syscall@plt>
mov    %rax,-0x30(%rbp)
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
mov    $0x1000,%esi
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
mov    $0xffffffff,%ecx
mov    $0x1001,%edx
mov    %ecx,%esi
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
mov    $0x1002,%esi
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
mov    $0xffffffff,%ecx
mov    $0x1003,%edx
mov    %ecx,%esi
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
lea    -0x38(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
mov    $0xffffffff,%esi
mov    $0x1388,%edx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
mov    $0x1389,%esi
mov    $0xffffffff,%edx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
mov    $0xffffffff,%esi
mov    $0x138a,%edx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
mov    $0x138b,%esi
mov    $0xffffffff,%edx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
mov    $0x138c,%esi
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
mov    $0x138d,%esi
mov    $0x0,%al
call   1030 <syscall@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    0x2eb4(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x2eac(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x2eac(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
mov    $0x1000,%esi
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
mov    $0xffffffff,%esi
mov    $0x1001,%edx
mov    $0xffffffff,%ecx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0x28(%rsp),%rsi
lea    0x20(%rsp),%rdx
lea    0x18(%rsp),%rcx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
mov    $0x1002,%esi
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
mov    $0xffffffff,%esi
mov    $0x1003,%edx
mov    $0xffffffff,%ecx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x2db8(%rip),%rbx
mov    (%rbx),%edi
mov    $0xffffffff,%esi
mov    $0x1388,%edx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    (%rbx),%edi
mov    $0x1389,%esi
mov    $0xffffffff,%edx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x2d6b(%rip),%rbx
mov    (%rbx),%edi
mov    $0xffffffff,%esi
mov    $0x138a,%edx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    (%rbx),%edi
mov    $0x138b,%esi
mov    $0xffffffff,%edx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
mov    $0x138c,%esi
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
mov    $0x138d,%esi
xor    %eax,%eax
call   1030 <syscall@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__NR_getuid = global i32 0
@__NR_geteuid = global i32 0
@__NR_getgid = global i32 0
@__NR_getegid = global i32 0
@__NR_setuid = global i32 0
@__NR_setresuid = global i32 0
@__NR_getresuid = global i32 0
@__NR_setgid = global i32 0
@__NR_setresgid = global i32 0
@__NR_getresgid = global i32 0
@__NR_setreuid = global i32 0
@__NR_setregid = global i32 0
@__NR_setfsuid = global i32 0
@__NR_setfsgid = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %1
%10 = load i32, i32* @__NR_getuid
%11 = call i8* (i32, ...) @syscall(i32 %10)
store i8* %11, i8** %2
%12 = load i32, i32* @__NR_geteuid
%13 = call i8* (i32, ...) @syscall(i32 %12)
store i8* %13, i8** %2
%14 = load i32, i32* @__NR_getgid
%15 = call i8* (i32, ...) @syscall(i32 %14)
store i8* %15, i8** %6
%16 = load i32, i32* @__NR_getegid
%17 = call i8* (i32, ...) @syscall(i32 %16)
store i8* %17, i8** %6
%18 = load i32, i32* @__NR_setuid
%19 = call i8* (i32, ...) @syscall(i32 %18, i32 4096)
%20 = load i32, i32* @__NR_setresuid
%21 = call i8* (i32, ...) @syscall(i32 %20, i32 -1, i32 4097, i32 -1)
%22 = load i32, i32* @__NR_getresuid
%23 = call i8* (i32, ...) @syscall(i32 %22, i8** %3, i8** %4, i8** %5)
%24 = load i32, i32* @__NR_setgid
%25 = call i8* (i32, ...) @syscall(i32 %24, i32 4098)
%26 = load i32, i32* @__NR_setresgid
%27 = call i8* (i32, ...) @syscall(i32 %26, i32 -1, i32 4099, i32 -1)
%28 = load i32, i32* @__NR_getresgid
%29 = call i8* (i32, ...) @syscall(i32 %28, i8** %7, i8** %8, i8** %9)
%30 = load i32, i32* @__NR_setreuid
%31 = call i8* (i32, ...) @syscall(i32 %30, i32 -1, i32 5000)
%32 = load i32, i32* @__NR_setreuid
%33 = call i8* (i32, ...) @syscall(i32 %32, i32 5001, i32 -1)
%34 = load i32, i32* @__NR_setregid
%35 = call i8* (i32, ...) @syscall(i32 %34, i32 -1, i32 5002)
%36 = load i32, i32* @__NR_setregid
%37 = call i8* (i32, ...) @syscall(i32 %36, i32 5003, i32 -1)
%38 = load i32, i32* @__NR_setfsuid
%39 = call i8* (i32, ...) @syscall(i32 %38, i32 5004)
%40 = load i32, i32* @__NR_setfsgid
%41 = call i8* (i32, ...) @syscall(i32 %40, i32 5005)
ret i32 0
}

LLVM IR (-O2):
@__NR_getuid = global i32 0
@__NR_geteuid = global i32 0
@__NR_getgid = global i32 0
@__NR_getegid = global i32 0
@__NR_setuid = global i32 0
@__NR_setresuid = global i32 0
@__NR_getresuid = global i32 0
@__NR_setgid = global i32 0
@__NR_setresgid = global i32 0
@__NR_getresgid = global i32 0
@__NR_setreuid = global i32 0
@__NR_setregid = global i32 0
@__NR_setfsuid = global i32 0
@__NR_setfsgid = global i32 0
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = bitcast i8** %1 to i8*
%8 = bitcast i8** %2 to i8*
%9 = bitcast i8** %3 to i8*
%10 = bitcast i8** %4 to i8*
%11 = bitcast i8** %5 to i8*
%12 = bitcast i8** %6 to i8*
%13 = load i32, i32* @__NR_getuid
%14 = tail call i8* (i32, ...) @syscall(i32 %13)
%15 = load i32, i32* @__NR_geteuid
%16 = tail call i8* (i32, ...) @syscall(i32 %15)
%17 = load i32, i32* @__NR_getgid
%18 = tail call i8* (i32, ...) @syscall(i32 %17)
%19 = load i32, i32* @__NR_getegid
%20 = tail call i8* (i32, ...) @syscall(i32 %19)
%21 = load i32, i32* @__NR_setuid
%22 = tail call i8* (i32, ...) @syscall(i32 %21, i32 4096)
%23 = load i32, i32* @__NR_setresuid
%24 = tail call i8* (i32, ...) @syscall(i32 %23, i32 -1, i32 4097, i32 -1)
%25 = load i32, i32* @__NR_getresuid
%26 = call i8* (i32, ...) @syscall(i32 %25, i8** %1, i8** %2, i8** %3)
%27 = load i32, i32* @__NR_setgid
%28 = call i8* (i32, ...) @syscall(i32 %27, i32 4098)
%29 = load i32, i32* @__NR_setresgid
%30 = call i8* (i32, ...) @syscall(i32 %29, i32 -1, i32 4099, i32 -1)
%31 = load i32, i32* @__NR_getresgid
%32 = call i8* (i32, ...) @syscall(i32 %31, i8** %4, i8** %5, i8** %6)
%33 = load i32, i32* @__NR_setreuid
%34 = call i8* (i32, ...) @syscall(i32 %33, i32 -1, i32 5000)
%35 = load i32, i32* @__NR_setreuid
%36 = call i8* (i32, ...) @syscall(i32 %35, i32 5001, i32 -1)
%37 = load i32, i32* @__NR_setregid
%38 = call i8* (i32, ...) @syscall(i32 %37, i32 -1, i32 5002)
%39 = load i32, i32* @__NR_setregid
%40 = call i8* (i32, ...) @syscall(i32 %39, i32 5003, i32 -1)
%41 = load i32, i32* @__NR_setfsuid
%42 = call i8* (i32, ...) @syscall(i32 %41, i32 5004)
%43 = load i32, i32* @__NR_setfsgid
%44 = call i8* (i32, ...) @syscall(i32 %43, i32 5005)
ret i32 0
}