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

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ err_exit(char *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getresgid(int *, int *, int *);
int getresuid(int *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int setfsgid(int);
int setfsuid(int);
int setresuid(int, int, int);
int setreuid(int, int);
int setuid(int);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  uid_t ruid, euid, suid;
  gid_t rgid, egid, sgid;
  if (getresuid(&ruid, &euid, &suid) == -1) {
    err_exit("Error on getresuid %s\n", strerror(errno));
  }
  printf("Real User ID: %d\nEffective User ID: %d\nSaved Set User ID: %d\n",
         ruid, euid, suid);
  if (getresgid(&rgid, &egid, &sgid) == -1) {
    err_exit("Error on getresgid %s\n", strerror(errno));
  }
  printf(
      "\nReal Group ID: %d\nEffective Group ID: %d\nSaved Set Group ID: %d\n",
      rgid, egid, sgid);
  printf("\nFile system User ID: %d\nFile System Group ID: %d\n", setfsuid(-1),
         setfsgid(-1));
  printf("\nModifying the Real User ID: 1000, Effective User ID: 0, Saved Set "
         "User ID: 0\n");
  if (setresuid(1000, 0, 0) == -1) {
    err_exit("Error on setresuid %s\n", strerror(errno));
  }
  if (getresuid(&ruid, &euid, &suid) == -1) {
    err_exit("Error on getresuid %s\n", strerror(errno));
  }
  printf("\nAfter modifying:\nReal User ID: %d\nEffective User ID: %d\nSaved "
         "Set User ID: %d\nFile System User ID: %d\n",
         ruid, euid, suid, setfsuid(-1));
  printf("\nSetting Real User ID to 2000\n");
  if (setuid(2000) == -1) {
    err_exit("Error on setuid %s\n", strerror(errno));
  }
  if (getresuid(&ruid, &euid, &suid) == -1) {
    err_exit("Error on getresuid %s\n", strerror(errno));
  }
  printf("\nAfter modifying:\nReal User ID: %d\nEffective User ID: %d\nSaved "
         "Set User ID: %d\nFile System User ID: %d\n",
         ruid, euid, suid, setfsuid(-1));
  printf("\nSetting Effective User ID to 2000\n");
  if (setreuid(-1, 2000) == -1) {
    err_exit("Error on setreuid %s\n", strerror(errno));
  }
  if (getresuid(&ruid, &euid, &suid) == -1) {
    err_exit("Error on getresuid %s\n", strerror(errno));
  }
  printf("\nAfter modifying:\nReal User ID: %d\nEffective User ID: %d\nSaved "
         "Set User ID: %d\nFile System User ID: %d\n",
         ruid, euid, suid, setfsuid(-1));
  printf("\nSetting Effective User ID to 2000, Saved Set User ID to 3000, File "
         "System User ID to 4000\n");
  if (setresuid(-1, 2000, 3000) == -1) {
    err_exit("Error on setresuid %s\n", strerror(errno));
  }
  if (getresuid(&ruid, &euid, &suid) == -1) {
    err_exit("Error on getresuid %s\n", strerror(errno));
  }
  printf("\nAfter modifying:\nReal User ID: %d\nEffective User ID: %d\nSaved "
         "Set User ID: %d\nFile System User ID: %d\n",
         ruid, euid, suid, setfsuid(4000));
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1070 <getresuid@plt>
cmp    $0xffffffff,%eax
jne    11fc <main+0x4c>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %eax,%esi
lea    0xe09(%rip),%rdi
call   1080 <err_exit@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <getresgid@plt>
cmp    $0xffffffff,%eax
jne    1249 <main+0x99>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %eax,%esi
lea    0xe11(%rip),%rdi
call   1080 <err_exit@plt>
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <setfsuid@plt>
mov    %eax,-0x2c(%rbp)
mov    $0xffffffff,%edi
call   10a0 <setfsgid@plt>
mov    -0x2c(%rbp),%esi
mov    %eax,%edx
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x3e8,%edi
xor    %edx,%edx
mov    %edx,%esi
call   1040 <setresuid@plt>
cmp    $0xffffffff,%eax
jne    12cb <main+0x11b>
mov    0x2d2a(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %eax,%esi
lea    0xe6a(%rip),%rdi
call   1080 <err_exit@plt>
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1070 <getresuid@plt>
cmp    $0xffffffff,%eax
jne    1301 <main+0x151>
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %eax,%esi
lea    0xd04(%rip),%rdi
call   1080 <err_exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    $0xffffffff,%edi
call   1060 <setfsuid@plt>
mov    -0x38(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    %eax,%r8d
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x7d0,%edi
call   10c0 <setuid@plt>
cmp    $0xffffffff,%eax
jne    1374 <main+0x1c4>
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %eax,%esi
lea    0xe5f(%rip),%rdi
call   1080 <err_exit@plt>
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1070 <getresuid@plt>
cmp    $0xffffffff,%eax
jne    13aa <main+0x1fa>
mov    0x2c4b(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %eax,%esi
lea    0xc5b(%rip),%rdi
call   1080 <err_exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    $0xffffffff,%edi
call   1060 <setfsuid@plt>
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    -0x3c(%rbp),%ecx
mov    %eax,%r8d
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
mov    $0x7d0,%esi
call   1090 <setreuid@plt>
cmp    $0xffffffff,%eax
jne    1422 <main+0x272>
mov    0x2bd3(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %eax,%esi
lea    0xde9(%rip),%rdi
call   1080 <err_exit@plt>
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1070 <getresuid@plt>
cmp    $0xffffffff,%eax
jne    1458 <main+0x2a8>
mov    0x2b9d(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %eax,%esi
lea    0xbad(%rip),%rdi
call   1080 <err_exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    $0xffffffff,%edi
call   1060 <setfsuid@plt>
mov    -0x50(%rbp),%esi
mov    -0x4c(%rbp),%edx
mov    -0x48(%rbp),%ecx
mov    %eax,%r8d
lea    0xcc0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
mov    $0x7d0,%esi
mov    $0xbb8,%edx
call   1040 <setresuid@plt>
cmp    $0xffffffff,%eax
jne    14d5 <main+0x325>
mov    0x2b20(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %eax,%esi
lea    0xc60(%rip),%rdi
call   1080 <err_exit@plt>
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1070 <getresuid@plt>
cmp    $0xffffffff,%eax
jne    150b <main+0x35b>
mov    0x2aea(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %eax,%esi
lea    0xafa(%rip),%rdi
call   1080 <err_exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    $0xfa0,%edi
call   1060 <setfsuid@plt>
mov    -0x5c(%rbp),%esi
mov    -0x58(%rbp),%edx
mov    -0x54(%rbp),%ecx
mov    %eax,%r8d
lea    0xc0d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2a90(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1080 <getresuid@plt>
cmp    $0xffffffff,%eax
jne    11fd <main+0x3d>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xe0a(%rip),%rdi
mov    %eax,%esi
call   1090 <err_exit@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xe07(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x1c(%rsp),%rdi
lea    0x18(%rsp),%rsi
lea    0x14(%rsp),%rdx
call   1030 <getresgid@plt>
cmp    $0xffffffff,%eax
jne    124c <main+0x8c>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xe10(%rip),%rdi
mov    %eax,%esi
call   1090 <err_exit@plt>
mov    0x1c(%rsp),%esi
mov    0x18(%rsp),%edx
mov    0x14(%rsp),%ecx
lea    0xe0d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <setfsuid@plt>
mov    %eax,%ebx
mov    $0xffffffff,%edi
call   10b0 <setfsgid@plt>
lea    0xe2b(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xef5(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3e8,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <setresuid@plt>
cmp    $0xffffffff,%eax
jne    12c9 <main+0x109>
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xe1f(%rip),%rdi
mov    %eax,%esi
call   1090 <err_exit@plt>
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1080 <getresuid@plt>
cmp    $0xffffffff,%eax
jne    12fe <main+0x13e>
mov    0x2cf7(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xd09(%rip),%rdi
mov    %eax,%esi
call   1090 <err_exit@plt>
mov    0x10(%rsp),%ebx
mov    0xc(%rsp),%ebp
mov    0x8(%rsp),%r14d
mov    $0xffffffff,%edi
call   1070 <setfsuid@plt>
lea    0xddc(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xea4(%rip),%rdi
call   1040 <puts@plt>
mov    $0x7d0,%edi
call   10d0 <setuid@plt>
cmp    $0xffffffff,%eax
jne    1364 <main+0x1a4>
mov    0x2c91(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xe03(%rip),%rdi
mov    %eax,%esi
call   1090 <err_exit@plt>
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1080 <getresuid@plt>
cmp    $0xffffffff,%eax
jne    1399 <main+0x1d9>
mov    0x2c5c(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xc6e(%rip),%rdi
mov    %eax,%esi
call   1090 <err_exit@plt>
mov    0x10(%rsp),%ebx
mov    0xc(%rsp),%ebp
mov    0x8(%rsp),%r14d
mov    $0xffffffff,%edi
call   1070 <setfsuid@plt>
lea    0xd41(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe27(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
mov    $0x7d0,%esi
call   10a0 <setreuid@plt>
cmp    $0xffffffff,%eax
jne    1404 <main+0x244>
mov    0x2bf1(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xd77(%rip),%rdi
mov    %eax,%esi
call   1090 <err_exit@plt>
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1080 <getresuid@plt>
cmp    $0xffffffff,%eax
jne    1439 <main+0x279>
mov    0x2bbc(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xbce(%rip),%rdi
mov    %eax,%esi
call   1090 <err_exit@plt>
mov    0x10(%rsp),%ebx
mov    0xc(%rsp),%ebp
mov    0x8(%rsp),%r14d
mov    $0xffffffff,%edi
call   1070 <setfsuid@plt>
lea    0xca1(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdaa(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
mov    $0x7d0,%esi
mov    $0xbb8,%edx
call   1050 <setresuid@plt>
cmp    $0xffffffff,%eax
jne    14a9 <main+0x2e9>
mov    0x2b4c(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xc3f(%rip),%rdi
mov    %eax,%esi
call   1090 <err_exit@plt>
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1080 <getresuid@plt>
cmp    $0xffffffff,%eax
jne    14de <main+0x31e>
mov    0x2b17(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xb29(%rip),%rdi
mov    %eax,%esi
call   1090 <err_exit@plt>
mov    0x10(%rsp),%ebx
mov    0xc(%rsp),%ebp
mov    0x8(%rsp),%r14d
mov    $0xfa0,%edi
call   1070 <setfsuid@plt>
lea    0xbfc(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2ac4(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Error on getresuid %s\0A\00"
@errno = global i32 0
@.str.1 = [62 x i8] c"Real User ID: %d\0AEffective User ID: %d\0ASaved Set User ID: %d\0A\00"
@.str.2 = [23 x i8] c"Error on getresgid %s\0A\00"
@.str.3 = [66 x i8] c"\0AReal Group ID: %d\0AEffective Group ID: %d\0ASaved Set Group ID: %d\0A\00"
@.str.4 = [51 x i8] c"\0AFile system User ID: %d\0AFile System Group ID: %d\0A\00"
@.str.5 = [79 x i8] c"\0AModifying the Real User ID: 1000, Effective User ID: 0, Saved Set User ID: 0\0A\00"
@.str.6 = [23 x i8] c"Error on setresuid %s\0A\00"
@.str.7 = [104 x i8] c"\0AAfter modifying:\0AReal User ID: %d\0AEffective User ID: %d\0ASaved Set User ID: %d\0AFile System User ID: %d\0A\00"
@.str.8 = [31 x i8] c"\0ASetting Real User ID to 2000\0A\00"
@.str.9 = [20 x i8] c"Error on setuid %s\0A\00"
@.str.10 = [36 x i8] c"\0ASetting Effective User ID to 2000\0A\00"
@.str.11 = [22 x i8] c"Error on setreuid %s\0A\00"
@.str.12 = [92 x i8] c"\0ASetting Effective User ID to 2000, Saved Set User ID to 3000, File System User ID to 4000\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 @getresuid(i32* %6, i32* %7, i32* %8)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* @errno
%16 = call i32 @strerror(i32 %15)
%17 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %14, %2
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = load i32, i32* %8
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %20, i32 %21)
%23 = call i32 @getresgid(i32* %9, i32* %10, i32* %11)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %29
25: ; preds = %18
%26 = load i32, i32* @errno
%27 = call i32 @strerror(i32 %26)
%28 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %25, %18
%30 = load i32, i32* %9
%31 = load i32, i32* %10
%32 = load i32, i32* %11
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i32 %30, i32 %31, i32 %32)
%34 = call i32 @setfsuid(i32 -1)
%35 = call i32 @setfsgid(i32 -1)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %34, i32 %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.5, i64 0, i64 0))
%38 = call i32 @setresuid(i32 1000, i32 0, i32 0)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %44
40: ; preds = %29
%41 = load i32, i32* @errno
%42 = call i32 @strerror(i32 %41)
%43 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %40, %29
%45 = call i32 @getresuid(i32* %6, i32* %7, i32* %8)
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = load i32, i32* @errno
%49 = call i32 @strerror(i32 %48)
%50 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %47, %44
%52 = load i32, i32* %6
%53 = load i32, i32* %7
%54 = load i32, i32* %8
%55 = call i32 @setfsuid(i32 -1)
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.7, i64 0, i64 0), i32 %52, i32 %53, i32 %54, i32 %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
%58 = call i32 @setuid(i32 2000)
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %64
60: ; preds = %51
%61 = load i32, i32* @errno
%62 = call i32 @strerror(i32 %61)
%63 = call i32 @err_exit(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %60, %51
%65 = call i32 @getresuid(i32* %6, i32* %7, i32* %8)
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %71
67: ; preds = %64
%68 = load i32, i32* @errno
%69 = call i32 @strerror(i32 %68)
%70 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %67, %64
%72 = load i32, i32* %6
%73 = load i32, i32* %7
%74 = load i32, i32* %8
%75 = call i32 @setfsuid(i32 -1)
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.7, i64 0, i64 0), i32 %72, i32 %73, i32 %74, i32 %75)
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
%78 = call i32 @setreuid(i32 -1, i32 2000)
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %84
80: ; preds = %71
%81 = load i32, i32* @errno
%82 = call i32 @strerror(i32 %81)
%83 = call i32 @err_exit(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i32 %82)
br label %84
84: ; preds = %80, %71
%85 = call i32 @getresuid(i32* %6, i32* %7, i32* %8)
%86 = icmp eq i32 %85, -1
br i1 %86, label %87, label %91
87: ; preds = %84
%88 = load i32, i32* @errno
%89 = call i32 @strerror(i32 %88)
%90 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %89)
br label %91
91: ; preds = %87, %84
%92 = load i32, i32* %6
%93 = load i32, i32* %7
%94 = load i32, i32* %8
%95 = call i32 @setfsuid(i32 -1)
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.7, i64 0, i64 0), i32 %92, i32 %93, i32 %94, i32 %95)
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.12, i64 0, i64 0))
%98 = call i32 @setresuid(i32 -1, i32 2000, i32 3000)
%99 = icmp eq i32 %98, -1
br i1 %99, label %100, label %104
100: ; preds = %91
%101 = load i32, i32* @errno
%102 = call i32 @strerror(i32 %101)
%103 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %102)
br label %104
104: ; preds = %100, %91
%105 = call i32 @getresuid(i32* %6, i32* %7, i32* %8)
%106 = icmp eq i32 %105, -1
br i1 %106, label %107, label %111
107: ; preds = %104
%108 = load i32, i32* @errno
%109 = call i32 @strerror(i32 %108)
%110 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %109)
br label %111
111: ; preds = %107, %104
%112 = load i32, i32* %6
%113 = load i32, i32* %7
%114 = load i32, i32* %8
%115 = call i32 @setfsuid(i32 4000)
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.7, i64 0, i64 0), i32 %112, i32 %113, i32 %114, i32 %115)
%117 = load i32, i32* @EXIT_SUCCESS
%118 = call i32 @exit(i32 %117)
unreachable
}

LLVM IR (-O2):
@.str = [23 x i8] c"Error on getresuid %s\0A\00"
@errno = global i32 0
@.str.1 = [62 x i8] c"Real User ID: %d\0AEffective User ID: %d\0ASaved Set User ID: %d\0A\00"
@.str.2 = [23 x i8] c"Error on getresgid %s\0A\00"
@.str.3 = [66 x i8] c"\0AReal Group ID: %d\0AEffective Group ID: %d\0ASaved Set Group ID: %d\0A\00"
@.str.4 = [51 x i8] c"\0AFile system User ID: %d\0AFile System Group ID: %d\0A\00"
@.str.6 = [23 x i8] c"Error on setresuid %s\0A\00"
@.str.7 = [104 x i8] c"\0AAfter modifying:\0AReal User ID: %d\0AEffective User ID: %d\0ASaved Set User ID: %d\0AFile System User ID: %d\0A\00"
@.str.9 = [20 x i8] c"Error on setuid %s\0A\00"
@.str.11 = [22 x i8] c"Error on setreuid %s\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [78 x i8] c"\0AModifying the Real User ID: 1000, Effective User ID: 0, Saved Set User ID: 0\00"
@str.13 = [30 x i8] c"\0ASetting Real User ID to 2000\00"
@str.14 = [35 x i8] c"\0ASetting Effective User ID to 2000\00"
@str.15 = [91 x i8] c"\0ASetting Effective User ID to 2000, Saved Set User ID to 3000, File System User ID to 4000\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = bitcast i32* %8 to i8*
%15 = call i32 @getresuid(i32* %3, i32* %4, i32* %5)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %21
17: ; preds = %2
%18 = load i32, i32* @errno
%19 = call i32 @strerror(i32 %18)
%20 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %17, %2
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23, i32 %24)
%26 = call i32 @getresgid(i32* %6, i32* %7, i32* %8)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %32
28: ; preds = %21
%29 = load i32, i32* @errno
%30 = call i32 @strerror(i32 %29)
%31 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %28, %21
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i32 %33, i32 %34, i32 %35)
%37 = call i32 @setfsuid(i32 -1)
%38 = call i32 @setfsgid(i32 -1)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %37, i32 %38)
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str, i64 0, i64 0))
%41 = call i32 @setresuid(i32 1000, i32 0, i32 0)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %47
43: ; preds = %32
%44 = load i32, i32* @errno
%45 = call i32 @strerror(i32 %44)
%46 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %43, %32
%48 = call i32 @getresuid(i32* %3, i32* %4, i32* %5)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %54
50: ; preds = %47
%51 = load i32, i32* @errno
%52 = call i32 @strerror(i32 %51)
%53 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %50, %47
%55 = load i32, i32* %3
%56 = load i32, i32* %4
%57 = load i32, i32* %5
%58 = call i32 @setfsuid(i32 -1)
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([104 x i8], [104 x i8]* @.str.7, i64 0, i64 0), i32 %55, i32 %56, i32 %57, i32 %58)
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.13, i64 0, i64 0))
%61 = call i32 @setuid(i32 2000)
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %67
63: ; preds = %54
%64 = load i32, i32* @errno
%65 = call i32 @strerror(i32 %64)
%66 = call i32 @err_exit(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %65)
br label %67
67: ; preds = %63, %54
%68 = call i32 @getresuid(i32* %3, i32* %4, i32* %5)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %74
70: ; preds = %67
%71 = load i32, i32* @errno
%72 = call i32 @strerror(i32 %71)
%73 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %72)
br label %74
74: ; preds = %70, %67
%75 = load i32, i32* %3
%76 = load i32, i32* %4
%77 = load i32, i32* %5
%78 = call i32 @setfsuid(i32 -1)
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([104 x i8], [104 x i8]* @.str.7, i64 0, i64 0), i32 %75, i32 %76, i32 %77, i32 %78)
%80 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.14, i64 0, i64 0))
%81 = call i32 @setreuid(i32 -1, i32 2000)
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %87
83: ; preds = %74
%84 = load i32, i32* @errno
%85 = call i32 @strerror(i32 %84)
%86 = call i32 @err_exit(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0), i32 %85)
br label %87
87: ; preds = %83, %74
%88 = call i32 @getresuid(i32* %3, i32* %4, i32* %5)
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %94
90: ; preds = %87
%91 = load i32, i32* @errno
%92 = call i32 @strerror(i32 %91)
%93 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %92)
br label %94
94: ; preds = %90, %87
%95 = load i32, i32* %3
%96 = load i32, i32* %4
%97 = load i32, i32* %5
%98 = call i32 @setfsuid(i32 -1)
%99 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([104 x i8], [104 x i8]* @.str.7, i64 0, i64 0), i32 %95, i32 %96, i32 %97, i32 %98)
%100 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @str.15, i64 0, i64 0))
%101 = call i32 @setresuid(i32 -1, i32 2000, i32 3000)
%102 = icmp eq i32 %101, -1
br i1 %102, label %103, label %107
103: ; preds = %94
%104 = load i32, i32* @errno
%105 = call i32 @strerror(i32 %104)
%106 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %105)
br label %107
107: ; preds = %103, %94
%108 = call i32 @getresuid(i32* %3, i32* %4, i32* %5)
%109 = icmp eq i32 %108, -1
br i1 %109, label %110, label %114
110: ; preds = %107
%111 = load i32, i32* @errno
%112 = call i32 @strerror(i32 %111)
%113 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %112)
br label %114
114: ; preds = %110, %107
%115 = load i32, i32* %3
%116 = load i32, i32* %4
%117 = load i32, i32* %5
%118 = call i32 @setfsuid(i32 4000)
%119 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([104 x i8], [104 x i8]* @.str.7, i64 0, i64 0), i32 %115, i32 %116, i32 %117, i32 %118)
%120 = load i32, i32* @EXIT_SUCCESS
%121 = call i32 @exit(i32 %120)
unreachable
}