#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char *);
scalar_t__ setegid(int);
scalar_t__ seteuid(int);
int /*<<< orphan*/ stderr;
int strtoul(char *, char **, int);
scalar_t__ unlink(char *);
int main(int argc, char **argv) {
  char *end;
  int uid, gid;
  if (argc != 4) {
    fprintf(stderr, "Usage: yamssRemoveWrapper UID GID FILE\n");
    exit(1);
  }
  uid = strtoul(argv[1], &end, 10);
  if (*end != '\0') {
    fprintf(stderr,
            "yamssRemoveWrapper: Error: uid %s for file %s is not a number\n",
            argv[1], argv[3]);
    exit(1);
  }
  gid = strtoul(argv[2], &end, 10);
  if (*end != '\0') {
    fprintf(stderr,
            "yamssRemoveWrapper: Error: gid %s for file %s is not a number\n",
            argv[2], argv[3]);
    exit(1);
  }
  if (setegid(gid) < 0) {
    perror("setegid");
    fprintf(stderr,
            "yamssRemoveWrapper: Error: cannot set gid %s for file %s\n",
            argv[2], argv[3]);
    exit(1);
  }
  if (seteuid(uid) < 0) {
    perror("seteuid");
    fprintf(stderr,
            "yamssRemoveWrapper: Error: cannot set uid %s for file %s\n",
            argv[1], argv[3]);
    exit(1);
  }
  if (unlink(argv[3]) < 0) {
    perror("unlink");
    fprintf(stderr,
            "yamssRemoveWrapper: Error: cannot remove file %s as uid %s and "
            "gid %s\n",
            argv[3], argv[1], argv[2]);
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11b1 <main+0x41>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     120b <main+0x9b>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1265 <main+0xf5>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
lea    0xe13(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%edi
call   1080 <setegid@plt>
cmp    $0x0,%rax
jge    12b4 <main+0x144>
lea    0xe28(%rip),%rdi
call   1050 <perror@plt>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x1c(%rbp),%edi
call   1090 <seteuid@plt>
cmp    $0x0,%rax
jge    1303 <main+0x193>
lea    0xe1b(%rip),%rdi
call   1050 <perror@plt>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jge    135f <main+0x1ef>
lea    0xe09(%rip),%rdi
call   1050 <perror@plt>
mov    0x2cb3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8
lea    0xde3(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x4,%edi
jne    11ec <main+0x7c>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    %eax,%ebp
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
jne    120d <main+0x9d>
mov    0x10(%rbx),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1060 <strtoul@plt>
mov    (%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    1227 <main+0xb7>
mov    %eax,%edi
call   1080 <setegid@plt>
test   %rax,%rax
js     1241 <main+0xd1>
mov    %ebp,%edi
call   1090 <seteuid@plt>
test   %rax,%rax
js     1267 <main+0xf7>
mov    0x18(%rbx),%rdi
call   1030 <unlink@plt>
test   %rax,%rax
js     129c <main+0x12c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
lea    0xe04(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
mov    0x18(%rbx),%rcx
lea    0xe03(%rip),%rsi
jmp    128b <main+0x11b>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
mov    0x18(%rbx),%rcx
lea    0xe28(%rip),%rsi
jmp    128b <main+0x11b>
lea    0xe5e(%rip),%rdi
call   1050 <perror@plt>
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
mov    0x18(%rbx),%rcx
lea    0xe49(%rip),%rsi
jmp    128b <main+0x11b>
lea    0xe7a(%rip),%rdi
call   1050 <perror@plt>
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
mov    0x18(%rbx),%rcx
lea    0xe65(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe87(%rip),%rdi
call   1050 <perror@plt>
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
mov    0x18(%rbx),%rdx
mov    0x8(%rbx),%rcx
mov    0x10(%rbx),%r8
lea    0xe6d(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [40 x i8] c"Usage: yamssRemoveWrapper UID GID FILE\0A\00"
@.str.1 = [63 x i8] c"yamssRemoveWrapper: Error: uid %s for file %s is not a number\0A\00"
@.str.2 = [63 x i8] c"yamssRemoveWrapper: Error: gid %s for file %s is not a number\0A\00"
@.str.3 = [8 x i8] c"setegid\00"
@.str.4 = [58 x i8] c"yamssRemoveWrapper: Error: cannot set gid %s for file %s\0A\00"
@.str.5 = [8 x i8] c"seteuid\00"
@.str.6 = [58 x i8] c"yamssRemoveWrapper: Error: cannot set uid %s for file %s\0A\00"
@.str.7 = [7 x i8] c"unlink\00"
@.str.8 = [71 x i8] c"yamssRemoveWrapper: Error: cannot remove file %s as uid %s and gid %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 4
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strtoul(i8* %18, i8** %6, i32 10)
store i32 %19, i32* %7
%20 = load i8*, i8** %6
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %15
%25 = load i32, i32* @stderr
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0), i8* %28, i8* %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %15
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @strtoul(i8* %37, i8** %6, i32 10)
store i32 %38, i32* %8
%39 = load i8*, i8** %6
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %53
43: ; preds = %34
%44 = load i32, i32* @stderr
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 2
%47 = load i8*, i8** %46
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 3
%50 = load i8*, i8** %49
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i8* %47, i8* %50)
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %34
%54 = load i32, i32* %8
%55 = call i64 @setegid(i32 %54)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %68
57: ; preds = %53
%58 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%59 = load i32, i32* @stderr
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 2
%62 = load i8*, i8** %61
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 3
%65 = load i8*, i8** %64
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0), i8* %62, i8* %65)
%67 = call i32 @exit(i32 1)
unreachable
68: ; preds = %53
%69 = load i32, i32* %7
%70 = call i64 @seteuid(i32 %69)
%71 = icmp slt i64 %70, 0
br i1 %71, label %72, label %83
72: ; preds = %68
%73 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%74 = load i32, i32* @stderr
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 1
%77 = load i8*, i8** %76
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 3
%80 = load i8*, i8** %79
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.6, i64 0, i64 0), i8* %77, i8* %80)
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %68
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i64 3
%86 = load i8*, i8** %85
%87 = call i64 @unlink(i8* %86)
%88 = icmp slt i64 %87, 0
br i1 %88, label %89, label %103
89: ; preds = %83
%90 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%91 = load i32, i32* @stderr
%92 = load i8**, i8*** %5
%93 = getelementptr inbounds i8*, i8** %92, i64 3
%94 = load i8*, i8** %93
%95 = load i8**, i8*** %5
%96 = getelementptr inbounds i8*, i8** %95, i64 1
%97 = load i8*, i8** %96
%98 = load i8**, i8*** %5
%99 = getelementptr inbounds i8*, i8** %98, i64 2
%100 = load i8*, i8** %99
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.8, i64 0, i64 0), i8* %94, i8* %97, i8* %100)
%102 = call i32 @exit(i32 1)
unreachable
103: ; preds = %83
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [40 x i8] c"Usage: yamssRemoveWrapper UID GID FILE\0A\00"
@.str.1 = [63 x i8] c"yamssRemoveWrapper: Error: uid %s for file %s is not a number\0A\00"
@.str.2 = [63 x i8] c"yamssRemoveWrapper: Error: gid %s for file %s is not a number\0A\00"
@.str.3 = [8 x i8] c"setegid\00"
@.str.4 = [58 x i8] c"yamssRemoveWrapper: Error: cannot set gid %s for file %s\0A\00"
@.str.5 = [8 x i8] c"seteuid\00"
@.str.6 = [58 x i8] c"yamssRemoveWrapper: Error: cannot set uid %s for file %s\0A\00"
@.str.7 = [7 x i8] c"unlink\00"
@.str.8 = [71 x i8] c"yamssRemoveWrapper: Error: cannot remove file %s as uid %s and gid %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp eq i32 %0, 4
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @strtoul(i8* %12, i8** %3, i32 10)
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %24, label %17
17: ; preds = %10
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %11
%20 = getelementptr inbounds i8*, i8** %1, i64 3
%21 = load i8*, i8** %20
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* %21)
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %10
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @strtoul(i8* %26, i8** %3, i32 10)
%28 = load i8*, i8** %3
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %38, label %31
31: ; preds = %24
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %25
%34 = getelementptr inbounds i8*, i8** %1, i64 3
%35 = load i8*, i8** %34
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i8* %33, i8* %35)
%37 = tail call i32 @exit(i32 1)
unreachable
38: ; preds = %24
%39 = tail call i64 @setegid(i32 %27)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %49
41: ; preds = %38
%42 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%43 = load i32, i32* @stderr
%44 = load i8*, i8** %25
%45 = getelementptr inbounds i8*, i8** %1, i64 3
%46 = load i8*, i8** %45
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0), i8* %44, i8* %46)
%48 = tail call i32 @exit(i32 1)
unreachable
49: ; preds = %38
%50 = tail call i64 @seteuid(i32 %13)
%51 = icmp slt i64 %50, 0
br i1 %51, label %52, label %60
52: ; preds = %49
%53 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%54 = load i32, i32* @stderr
%55 = load i8*, i8** %11
%56 = getelementptr inbounds i8*, i8** %1, i64 3
%57 = load i8*, i8** %56
%58 = tail call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.6, i64 0, i64 0), i8* %55, i8* %57)
%59 = tail call i32 @exit(i32 1)
unreachable
60: ; preds = %49
%61 = getelementptr inbounds i8*, i8** %1, i64 3
%62 = load i8*, i8** %61
%63 = tail call i64 @unlink(i8* %62)
%64 = icmp slt i64 %63, 0
br i1 %64, label %65, label %73
65: ; preds = %60
%66 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%67 = load i32, i32* @stderr
%68 = load i8*, i8** %61
%69 = load i8*, i8** %11
%70 = load i8*, i8** %25
%71 = tail call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.8, i64 0, i64 0), i8* %68, i8* %69, i8* %70)
%72 = tail call i32 @exit(i32 1)
unreachable
73: ; preds = %60
ret i32 0
}