#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 */
struct passwd {
  scalar_t__ pw_uid;
};
struct group {
  scalar_t__ gr_gid;
};

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ endgrent();
int /*<<< orphan*/ endpwent();
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
struct group *getgrnam(char *);
struct passwd *getpwnam(char *);
scalar_t__ kill(int, int);
scalar_t__ setgid(int);
scalar_t__ setuid(int);
int /*<<< orphan*/ stderr;
int strtol(char *, char **, int);
int main(int argc, char **argv) {
  if (argc != 3) {
    fprintf(stderr, "%s: wrong number of arguments\n", argv[0]);
    abort();
  }
  struct passwd *pwd = getpwnam("ejexec");
  struct group *grp = getgrnam("ejexec");
  endpwent();
  endgrent();
  if (!pwd) {
    fprintf(stderr, "%s: user '%s' does not exist\n", argv[0], "ejexec");
    abort();
  }
  if (pwd->pw_uid <= 0) {
    fprintf(stderr, "%s: user '%s' has uid %d\n", argv[0], "ejexec",
            pwd->pw_uid);
    abort();
  }
  if (!grp) {
    fprintf(stderr, "%s: group '%s' does not exist\n", argv[0], "ejexec");
    abort();
  }
  if (grp->gr_gid <= 0) {
    fprintf(stderr, "%s: group '%s' has gid %d\n", argv[0], "ejexec",
            grp->gr_gid);
    abort();
  }
  errno = 0;
  char *eptr = NULL;
  int dst_pid = strtol(argv[1], &eptr, 10);
  if (errno || *eptr || dst_pid < -1000000 || dst_pid > 1000000 ||
      dst_pid == 0) {
    fprintf(stderr, "%s: invalid pid '%s'\n", argv[0], argv[1]);
    abort();
  }
  int kill_sig = strtol(argv[2], &eptr, 10);
  if (errno || *eptr || kill_sig < 0 || kill_sig > 64) {
    fprintf(stderr, "%s: invalid signal '%s'\n", argv[0], argv[1]);
    abort();
  }
  if (setgid(grp->gr_gid) < 0) {
    fprintf(stderr, "%s: setgid failed\n", argv[0]);
    abort();
  }
  if (setuid(pwd->pw_uid) < 0) {
    fprintf(stderr, "%s: setuid failed\n", argv[0]);
    abort();
  }
  return kill(dst_pid, kill_sig) < 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11e5 <main+0x45>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe29(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
lea    0xe33(%rip),%rdi
call   1050 <getpwnam@plt>
mov    %rax,-0x18(%rbp)
lea    0xe23(%rip),%rdi
call   1080 <getgrnam@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   10a0 <endpwent@plt>
mov    $0x0,%al
call   1030 <endgrent@plt>
cmpq   $0x0,-0x18(%rbp)
jne    124a <main+0xaa>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdf1(%rip),%rsi
lea    0xde3(%rip),%rcx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jg     128b <main+0xeb>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%r8
lea    0xdce(%rip),%rsi
lea    0xda2(%rip),%rcx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
cmpq   $0x0,-0x20(%rbp)
jne    12c2 <main+0x122>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdb1(%rip),%rsi
lea    0xd6b(%rip),%rcx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jg     1303 <main+0x163>
mov    0x2d09(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rax
mov    (%rax),%r8
lea    0xd8f(%rip),%rsi
lea    0xd2a(%rip),%rcx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    0x2cce(%rip),%rax
movq   $0x0,(%rax)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2c9f(%rip),%rax
cmpq   $0x0,(%rax)
jne    1377 <main+0x1d7>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1377 <main+0x1d7>
cmpl   $0xfff0bdc0,-0x2c(%rbp)
jl     1377 <main+0x1d7>
cmpl   $0xf4240,-0x2c(%rbp)
jg     1377 <main+0x1d7>
cmpl   $0x0,-0x2c(%rbp)
jne    13a4 <main+0x204>
mov    0x2c62(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xd02(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %eax,-0x30(%rbp)
mov    0x2c14(%rip),%rax
cmpq   $0x0,(%rax)
jne    13f2 <main+0x252>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    13f2 <main+0x252>
cmpl   $0x0,-0x30(%rbp)
jl     13f2 <main+0x252>
cmpl   $0x40,-0x30(%rbp)
jle    141f <main+0x27f>
mov    0x2be7(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xc9d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %eax,%edi
call   10b0 <setgid@plt>
cmp    $0x0,%rax
jge    145c <main+0x2bc>
mov    0x2ba2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xc79(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %eax,%edi
call   10c0 <setuid@plt>
cmp    $0x0,%rax
jge    1499 <main+0x2f9>
mov    0x2b65(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xc4f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1090 <kill@plt>
cmp    $0x0,%rax
setl   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x3,%edi
jne    12fc <main+0x15c>
lea    0xe61(%rip),%rbx
mov    %rbx,%rdi
call   1050 <getpwnam@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1080 <getgrnam@plt>
mov    %rax,%r12
xor    %eax,%eax
call   10a0 <endpwent@plt>
xor    %eax,%eax
call   1030 <endgrent@plt>
test   %r15,%r15
je     1314 <main+0x174>
mov    (%r15),%r8
test   %r8,%r8
jle    1329 <main+0x189>
test   %r12,%r12
je     133e <main+0x19e>
mov    (%r12),%r8
test   %r8,%r8
jle    1366 <main+0x1c6>
mov    0x2dc4(%rip),%r13
movq   $0x0,0x0(%r13)
movq   $0x0,(%rsp)
mov    0x8(%r14),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1070 <strtol@plt>
cmpq   $0x0,0x0(%r13)
jne    12ca <main+0x12a>
mov    %eax,%ebp
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
jne    12ca <main+0x12a>
cmp    $0xfff0bdc0,%ebp
jl     12ca <main+0x12a>
cmp    $0xf4240,%ebp
jg     12ca <main+0x12a>
test   %ebp,%ebp
je     12ca <main+0x12a>
mov    0x10(%r14),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1070 <strtol@plt>
cmpq   $0x0,0x0(%r13)
jne    12e3 <main+0x143>
mov    %eax,%ebx
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
jne    12e3 <main+0x143>
test   %ebx,%ebx
js     12e3 <main+0x143>
cmp    $0x41,%ebx
jge    12e3 <main+0x143>
mov    (%r12),%edi
call   10b0 <setgid@plt>
test   %rax,%rax
js     138e <main+0x1ee>
mov    (%r15),%edi
call   10c0 <setuid@plt>
test   %rax,%rax
js     13a3 <main+0x203>
mov    %ebp,%edi
mov    %ebx,%esi
call   1090 <kill@plt>
shr    $0x3f,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d0f(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x8(%r14),%rcx
lea    0xdb7(%rip),%rsi
jmp    1358 <main+0x1b8>
mov    0x2cf6(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x8(%r14),%rcx
lea    0xdb4(%rip),%rsi
jmp    1358 <main+0x1b8>
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xcf1(%rip),%rsi
jmp    13b6 <main+0x216>
mov    0x2cc5(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xcff(%rip),%rsi
jmp    1351 <main+0x1b1>
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xd08(%rip),%rsi
jmp    1379 <main+0x1d9>
mov    0x2c9b(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xd0d(%rip),%rsi
lea    0xcc7(%rip),%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1040 <abort@plt>
mov    0x2c73(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xd04(%rip),%rsi
lea    0xc9f(%rip),%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1040 <abort@plt>
mov    0x2c4b(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xd26(%rip),%rsi
jmp    13b6 <main+0x216>
mov    0x2c36(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xd24(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
%struct.passwd = type { i64 }
%struct.group = type { i64 }
@stderr = global i32 0
@.str = [31 x i8] c"%s: wrong number of arguments\0A\00"
@.str.1 = [7 x i8] c"ejexec\00"
@.str.2 = [30 x i8] c"%s: user '%s' does not exist\0A\00"
@.str.3 = [26 x i8] c"%s: user '%s' has uid %d\0A\00"
@.str.4 = [31 x i8] c"%s: group '%s' does not exist\0A\00"
@.str.5 = [27 x i8] c"%s: group '%s' has gid %d\0A\00"
@errno = global i64 0
@.str.6 = [22 x i8] c"%s: invalid pid '%s'\0A\00"
@.str.7 = [25 x i8] c"%s: invalid signal '%s'\0A\00"
@.str.8 = [19 x i8] c"%s: setgid failed\0A\00"
@.str.9 = [19 x i8] c"%s: setuid failed\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.passwd*
%7 = alloca %struct.group*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 (...) @abort()
unreachable
20: ; preds = %2
%21 = call %struct.passwd* @getpwnam(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store %struct.passwd* %21, %struct.passwd** %6
%22 = call %struct.group* @getgrnam(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store %struct.group* %22, %struct.group** %7
%23 = call i32 (...) @endpwent()
%24 = call i32 (...) @endgrent()
%25 = load %struct.passwd*, %struct.passwd** %6
%26 = icmp ne %struct.passwd* %25, null
br i1 %26, label %34, label %27
27: ; preds = %20
%28 = load i32, i32* @stderr
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 (...) @abort()
unreachable
34: ; preds = %20
%35 = load %struct.passwd*, %struct.passwd** %6
%36 = getelementptr inbounds %struct.passwd, %struct.passwd* %35, i32 0, i32 0
%37 = load i64, i64* %36
%38 = icmp sle i64 %37, 0
br i1 %38, label %39, label %49
39: ; preds = %34
%40 = load i32, i32* @stderr
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = load %struct.passwd*, %struct.passwd** %6
%45 = getelementptr inbounds %struct.passwd, %struct.passwd* %44, i32 0, i32 0
%46 = load i64, i64* %45
%47 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %43, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %46)
%48 = call i32 (...) @abort()
unreachable
49: ; preds = %34
%50 = load %struct.group*, %struct.group** %7
%51 = icmp ne %struct.group* %50, null
br i1 %51, label %59, label %52
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 0
%56 = load i8*, i8** %55
%57 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %56, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%58 = call i32 (...) @abort()
unreachable
59: ; preds = %49
%60 = load %struct.group*, %struct.group** %7
%61 = getelementptr inbounds %struct.group, %struct.group* %60, i32 0, i32 0
%62 = load i64, i64* %61
%63 = icmp sle i64 %62, 0
br i1 %63, label %64, label %74
64: ; preds = %59
%65 = load i32, i32* @stderr
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 0
%68 = load i8*, i8** %67
%69 = load %struct.group*, %struct.group** %7
%70 = getelementptr inbounds %struct.group, %struct.group* %69, i32 0, i32 0
%71 = load i64, i64* %70
%72 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %68, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %71)
%73 = call i32 (...) @abort()
unreachable
74: ; preds = %59
store i64 0, i64* @errno
store i8* null, i8** %8
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 1
%77 = load i8*, i8** %76
%78 = call i32 @strtol(i8* %77, i8** %8, i32 10)
store i32 %78, i32* %9
%79 = load i64, i64* @errno
%80 = icmp ne i64 %79, 0
br i1 %80, label %95, label %81
81: ; preds = %74
%82 = load i8*, i8** %8
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = icmp ne i32 %84, 0
br i1 %85, label %95, label %86
86: ; preds = %81
%87 = load i32, i32* %9
%88 = icmp slt i32 %87, -1000000
br i1 %88, label %95, label %89
89: ; preds = %86
%90 = load i32, i32* %9
%91 = icmp sgt i32 %90, 1000000
br i1 %91, label %95, label %92
92: ; preds = %89
%93 = load i32, i32* %9
%94 = icmp eq i32 %93, 0
br i1 %94, label %95, label %105
95: ; preds = %92, %89, %86, %81, %74
%96 = load i32, i32* @stderr
%97 = load i8**, i8*** %5
%98 = getelementptr inbounds i8*, i8** %97, i64 0
%99 = load i8*, i8** %98
%100 = load i8**, i8*** %5
%101 = getelementptr inbounds i8*, i8** %100, i64 1
%102 = load i8*, i8** %101
%103 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %99, i8* %102)
%104 = call i32 (...) @abort()
unreachable
105: ; preds = %92
%106 = load i8**, i8*** %5
%107 = getelementptr inbounds i8*, i8** %106, i64 2
%108 = load i8*, i8** %107
%109 = call i32 @strtol(i8* %108, i8** %8, i32 10)
store i32 %109, i32* %10
%110 = load i64, i64* @errno
%111 = icmp ne i64 %110, 0
br i1 %111, label %123, label %112
112: ; preds = %105
%113 = load i8*, i8** %8
%114 = load i8, i8* %113
%115 = sext i8 %114 to i32
%116 = icmp ne i32 %115, 0
br i1 %116, label %123, label %117
117: ; preds = %112
%118 = load i32, i32* %10
%119 = icmp slt i32 %118, 0
br i1 %119, label %123, label %120
120: ; preds = %117
%121 = load i32, i32* %10
%122 = icmp sgt i32 %121, 64
br i1 %122, label %123, label %133
123: ; preds = %120, %117, %112, %105
%124 = load i32, i32* @stderr
%125 = load i8**, i8*** %5
%126 = getelementptr inbounds i8*, i8** %125, i64 0
%127 = load i8*, i8** %126
%128 = load i8**, i8*** %5
%129 = getelementptr inbounds i8*, i8** %128, i64 1
%130 = load i8*, i8** %129
%131 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %127, i8* %130)
%132 = call i32 (...) @abort()
unreachable
133: ; preds = %120
%134 = load %struct.group*, %struct.group** %7
%135 = getelementptr inbounds %struct.group, %struct.group* %134, i32 0, i32 0
%136 = load i64, i64* %135
%137 = trunc i64 %136 to i32
%138 = call i64 @setgid(i32 %137)
%139 = icmp slt i64 %138, 0
br i1 %139, label %140, label %147
140: ; preds = %133
%141 = load i32, i32* @stderr
%142 = load i8**, i8*** %5
%143 = getelementptr inbounds i8*, i8** %142, i64 0
%144 = load i8*, i8** %143
%145 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %141, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %144)
%146 = call i32 (...) @abort()
unreachable
147: ; preds = %133
%148 = load %struct.passwd*, %struct.passwd** %6
%149 = getelementptr inbounds %struct.passwd, %struct.passwd* %148, i32 0, i32 0
%150 = load i64, i64* %149
%151 = trunc i64 %150 to i32
%152 = call i64 @setuid(i32 %151)
%153 = icmp slt i64 %152, 0
br i1 %153, label %154, label %161
154: ; preds = %147
%155 = load i32, i32* @stderr
%156 = load i8**, i8*** %5
%157 = getelementptr inbounds i8*, i8** %156, i64 0
%158 = load i8*, i8** %157
%159 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %155, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* %158)
%160 = call i32 (...) @abort()
unreachable
161: ; preds = %147
%162 = load i32, i32* %9
%163 = load i32, i32* %10
%164 = call i64 @kill(i32 %162, i32 %163)
%165 = icmp slt i64 %164, 0
%166 = zext i1 %165 to i32
ret i32 %166
}

LLVM IR (-O2):
%struct.passwd = type { i64 }
%struct.group = type { i64 }
@stderr = global i32 0
@.str = [31 x i8] c"%s: wrong number of arguments\0A\00"
@.str.1 = [7 x i8] c"ejexec\00"
@.str.2 = [30 x i8] c"%s: user '%s' does not exist\0A\00"
@.str.3 = [26 x i8] c"%s: user '%s' has uid %d\0A\00"
@.str.4 = [31 x i8] c"%s: group '%s' does not exist\0A\00"
@.str.5 = [27 x i8] c"%s: group '%s' has gid %d\0A\00"
@errno = global i64 0
@.str.6 = [22 x i8] c"%s: invalid pid '%s'\0A\00"
@.str.7 = [25 x i8] c"%s: invalid signal '%s'\0A\00"
@.str.8 = [19 x i8] c"%s: setgid failed\0A\00"
@.str.9 = [19 x i8] c"%s: setuid failed\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = icmp eq i32 %0, 3
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %2
%11 = tail call %struct.passwd* @getpwnam(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call %struct.group* @getgrnam(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 (...) @endpwent()
%14 = tail call i32 (...) @endgrent()
%15 = icmp eq %struct.passwd* %11, null
br i1 %15, label %16, label %21
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %1
%19 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32 (...) @abort()
unreachable
21: ; preds = %10
%22 = getelementptr inbounds %struct.passwd, %struct.passwd* %11, i64 0, i32 0
%23 = load i64, i64* %22
%24 = icmp slt i64 %23, 1
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %1
%28 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %23)
%29 = tail call i32 (...) @abort()
unreachable
30: ; preds = %21
%31 = icmp eq %struct.group* %12, null
br i1 %31, label %32, label %37
32: ; preds = %30
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %1
%35 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%36 = tail call i32 (...) @abort()
unreachable
37: ; preds = %30
%38 = getelementptr inbounds %struct.group, %struct.group* %12, i64 0, i32 0
%39 = load i64, i64* %38
%40 = icmp slt i64 %39, 1
br i1 %40, label %41, label %46
41: ; preds = %37
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %1
%44 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %43, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %39)
%45 = tail call i32 (...) @abort()
unreachable
46: ; preds = %37
store i64 0, i64* @errno
%47 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%48 = getelementptr inbounds i8*, i8** %1, i64 1
%49 = load i8*, i8** %48
%50 = call i32 @strtol(i8* %49, i8** %3, i32 10)
%51 = load i64, i64* @errno
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %63
53: ; preds = %46
%54 = load i8*, i8** %3
%55 = load i8, i8* %54
%56 = icmp ne i8 %55, 0
%57 = icmp slt i32 %50, -1000000
%58 = select i1 %56, i1 true, i1 %57
%59 = icmp sgt i32 %50, 1000000
%60 = select i1 %58, i1 true, i1 %59
%61 = icmp eq i32 %50, 0
%62 = select i1 %60, i1 true, i1 %61
br i1 %62, label %63, label %69
63: ; preds = %53, %46
%64 = load i32, i32* @stderr
%65 = load i8*, i8** %1
%66 = load i8*, i8** %48
%67 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %65, i8* %66)
%68 = tail call i32 (...) @abort()
unreachable
69: ; preds = %53
%70 = getelementptr inbounds i8*, i8** %1, i64 2
%71 = load i8*, i8** %70
%72 = call i32 @strtol(i8* %71, i8** %3, i32 10)
%73 = load i64, i64* @errno
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %83
75: ; preds = %69
%76 = load i8*, i8** %3
%77 = load i8, i8* %76
%78 = icmp ne i8 %77, 0
%79 = icmp slt i32 %72, 0
%80 = select i1 %78, i1 true, i1 %79
%81 = icmp sgt i32 %72, 64
%82 = select i1 %80, i1 true, i1 %81
br i1 %82, label %83, label %89
83: ; preds = %75, %69
%84 = load i32, i32* @stderr
%85 = load i8*, i8** %1
%86 = load i8*, i8** %48
%87 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %85, i8* %86)
%88 = tail call i32 (...) @abort()
unreachable
89: ; preds = %75
%90 = load i64, i64* %38
%91 = trunc i64 %90 to i32
%92 = tail call i64 @setgid(i32 %91)
%93 = icmp slt i64 %92, 0
br i1 %93, label %94, label %99
94: ; preds = %89
%95 = load i32, i32* @stderr
%96 = load i8*, i8** %1
%97 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %96)
%98 = tail call i32 (...) @abort()
unreachable
99: ; preds = %89
%100 = load i64, i64* %22
%101 = trunc i64 %100 to i32
%102 = tail call i64 @setuid(i32 %101)
%103 = icmp slt i64 %102, 0
br i1 %103, label %104, label %109
104: ; preds = %99
%105 = load i32, i32* @stderr
%106 = load i8*, i8** %1
%107 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* %106)
%108 = tail call i32 (...) @abort()
unreachable
109: ; preds = %99
%110 = tail call i64 @kill(i32 %50, i32 %72)
%111 = lshr i64 %110, 63
%112 = trunc i64 %111 to i32
ret i32 %112
}