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

/* Variables and functions */
int /*<<< orphan*/ error_msg_and_die(char *, char *);
int /*<<< orphan*/ execvp(char *, char **);
scalar_t__ getegid();
scalar_t__ geteuid();
scalar_t__ getgid();
scalar_t__ getuid();
int /*<<< orphan*/ putenv(char *);
int /*<<< orphan*/ setregid(scalar_t__, scalar_t__);
int /*<<< orphan*/ setreuid(scalar_t__, scalar_t__);
scalar_t__ strlen(char const *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ unsetenv(char const *);
int main(int argc, char **argv) {
  char **pp = argv;
  char *arg;
  while ((arg = *++pp) != NULL) {
    if (strncmp(arg, "--cache", 7) == 0)
      error_msg_and_die("bad option", arg);
    if (strncmp(arg, "--tmpdir", 8) == 0)
      error_msg_and_die("bad option", arg);
    if (strncmp(arg, "--ids", 5) == 0)
      error_msg_and_die("bad option", arg);
  }
  gid_t g = getegid();
  if (g != getgid())
    setregid(g, g);
  uid_t u = geteuid();
  if (u != getuid()) {
    setreuid(u, u);
    if (u == 0)
      putenv((char *)"PATH=/usr/sbin:/sbin:/usr/bin:/bin");
    else
      putenv((char *)"PATH=/usr/bin:/bin");
    static const char forbid[] = "LD_LIBRARY_PATH"
                                 "\0"
                                 "LD_PRELOAD"
                                 "\0"
                                 "LD_TRACE_LOADED_OBJECTS"
                                 "\0"
                                 "LD_BIND_NOW"
                                 "\0"
                                 "LD_AOUT_LIBRARY_PATH"
                                 "\0"
                                 "LD_AOUT_PRELOAD"
                                 "\0"
                                 "LD_NOWARN"
                                 "\0"
                                 "LD_KEEPDIR"
                                 "\0";
    const char *p = forbid;
    do {
      unsetenv(p);
      p += strlen(p) + 1;
    } while (*p);
  }
  execvp("abrt-action-install-debuginfo.py", argv);
  error_msg_and_die("Can't execute", "abrt-action-install-debuginfo.py");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1291 <main+0xd1>
mov    -0x20(%rbp),%rdi
lea    0xdf6(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    122e <main+0x6e>
mov    -0x20(%rbp),%rsi
lea    0xddf(%rip),%rdi
call   1070 <error_msg_and_die@plt>
mov    -0x20(%rbp),%rdi
lea    0xdda(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    125d <main+0x9d>
mov    -0x20(%rbp),%rsi
lea    0xdb0(%rip),%rdi
call   1070 <error_msg_and_die@plt>
mov    -0x20(%rbp),%rdi
lea    0xdb4(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    128c <main+0xcc>
mov    -0x20(%rbp),%rsi
lea    0xd81(%rip),%rdi
call   1070 <error_msg_and_die@plt>
jmp    11de <main+0x1e>
mov    $0x0,%al
call   10a0 <getegid@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1090 <getgid@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
je     12c8 <main+0x108>
mov    -0x28(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10c0 <setregid@plt>
mov    $0x0,%al
call   1060 <geteuid@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    $0x0,%al
call   1050 <getuid@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
je     1362 <main+0x1a2>
mov    -0x30(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10b0 <setreuid@plt>
cmpq   $0x0,-0x30(%rbp)
jne    131b <main+0x15b>
lea    0xd11(%rip),%rdi
call   1080 <putenv@plt>
jmp    1327 <main+0x167>
lea    0xd23(%rip),%rdi
call   1080 <putenv@plt>
lea    0xd62(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   10d0 <unsetenv@plt>
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1332 <main+0x172>
jmp    1362 <main+0x1a2>
mov    -0x10(%rbp),%rsi
lea    0xceb(%rip),%rdi
call   10e0 <execvp@plt>
lea    0xd00(%rip),%rdi
lea    0xcd8(%rip),%rsi
call   1070 <error_msg_and_die@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%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,(%rsp)
mov    0x8(%rsi),%rbx
test   %rbx,%rbx
je     127e <main+0xbe>
mov    (%rsp),%rax
lea    0x10(%rax),%r14
lea    0xe15(%rip),%r15
lea    0xe16(%rip),%r12
lea    0xe1a(%rip),%r13
lea    0xe1c(%rip),%rbp
jmp    121c <main+0x5c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r14),%rbx
add    $0x8,%r14
test   %rbx,%rbx
je     127e <main+0xbe>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    123c <main+0x7c>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <error_msg_and_die@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    125c <main+0x9c>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <error_msg_and_die@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1210 <main+0x50>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <error_msg_and_die@plt>
jmp    1210 <main+0x50>
xor    %eax,%eax
call   10a0 <getegid@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1090 <getgid@plt>
cmp    %rax,%rbx
je     129f <main+0xdf>
mov    %rbx,%rdi
mov    %rbx,%rsi
call   10c0 <setregid@plt>
xor    %eax,%eax
call   1060 <geteuid@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <getuid@plt>
cmp    %rax,%rbx
je     130c <main+0x14c>
mov    %rbx,%rdi
mov    %rbx,%rsi
call   10b0 <setreuid@plt>
test   %rbx,%rbx
lea    0xd58(%rip),%rax
lea    0xd74(%rip),%rdi
cmove  %rax,%rdi
call   1080 <putenv@plt>
lea    0xdaf(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10d0 <unsetenv@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmpb   $0x0,0x1(%rax,%rbx,1)
lea    0x1(%rax,%rbx,1),%rbx
jne    12f0 <main+0x130>
lea    0xd45(%rip),%rbx
mov    %rbx,%rdi
mov    (%rsp),%rsi
call   10e0 <execvp@plt>
lea    0xd53(%rip),%rdi
mov    %rbx,%rsi
call   1070 <error_msg_and_die@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"--cache\00"
@.str.1 = [11 x i8] c"bad option\00"
@.str.2 = [9 x i8] c"--tmpdir\00"
@.str.3 = [6 x i8] c"--ids\00"
@.str.4 = [35 x i8] c"PATH=/usr/sbin:/sbin:/usr/bin:/bin\00"
@.str.5 = [19 x i8] c"PATH=/usr/bin:/bin\00"
@main.forbid = internal constant [122 x i8] c"LD_LIBRARY_PATH\00LD_PRELOAD\00LD_TRACE_LOADED_OBJECTS\00LD_BIND_NOW\00LD_AOUT_LIBRARY_PATH\00LD_AOUT_PRELOAD\00LD_NOWARN\00LD_KEEPDIR\00\00"
@.str.6 = [33 x i8] c"abrt-action-install-debuginfo.py\00"
@.str.7 = [14 x i8] c"Can't execute\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
store i8** %11, i8*** %6
br label %12
12: ; preds = %38, %2
%13 = load i8**, i8*** %6
%14 = getelementptr inbounds i8*, i8** %13, i32 1
store i8** %14, i8*** %6
%15 = load i8*, i8** %14
store i8* %15, i8** %7
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %39
17: ; preds = %12
%18 = load i8*, i8** %7
%19 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i8*, i8** %7
%23 = call i32 @error_msg_and_die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %21, %17
%25 = load i8*, i8** %7
%26 = call i64 @strncmp(i8* %25, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i8*, i8** %7
%30 = call i32 @error_msg_and_die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %28, %24
%32 = load i8*, i8** %7
%33 = call i64 @strncmp(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %31
%36 = load i8*, i8** %7
%37 = call i32 @error_msg_and_die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %35, %31
br label %12
39: ; preds = %12
%40 = call i64 (...) @getegid()
store i64 %40, i64* %8
%41 = load i64, i64* %8
%42 = call i64 (...) @getgid()
%43 = icmp ne i64 %41, %42
br i1 %43, label %44, label %48
44: ; preds = %39
%45 = load i64, i64* %8
%46 = load i64, i64* %8
%47 = call i32 @setregid(i64 %45, i64 %46)
br label %48
48: ; preds = %44, %39
%49 = call i64 (...) @geteuid()
store i64 %49, i64* %9
%50 = load i64, i64* %9
%51 = call i64 (...) @getuid()
%52 = icmp ne i64 %50, %51
br i1 %52, label %53, label %77
53: ; preds = %48
%54 = load i64, i64* %9
%55 = load i64, i64* %9
%56 = call i32 @setreuid(i64 %54, i64 %55)
%57 = load i64, i64* %9
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %53
%60 = call i32 @putenv(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
br label %63
61: ; preds = %53
%62 = call i32 @putenv(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %63
63: ; preds = %61, %59
store i8* getelementptr inbounds ([122 x i8], [122 x i8]* @main.forbid, i64 0, i64 0), i8** %10
br label %64
64: ; preds = %72, %63
%65 = load i8*, i8** %10
%66 = call i32 @unsetenv(i8* %65)
%67 = load i8*, i8** %10
%68 = call i64 @strlen(i8* %67)
%69 = add nsw i64 %68, 1
%70 = load i8*, i8** %10
%71 = getelementptr inbounds i8, i8* %70, i64 %69
store i8* %71, i8** %10
br label %72
72: ; preds = %64
%73 = load i8*, i8** %10
%74 = load i8, i8* %73
%75 = icmp ne i8 %74, 0
br i1 %75, label %64, label %76
76: ; preds = %72
br label %77
77: ; preds = %76, %48
%78 = load i8**, i8*** %5
%79 = call i32 @execvp(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8** %78)
%80 = call i32 @error_msg_and_die(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%81 = load i32, i32* %3
ret i32 %81
}

LLVM IR (-O2):
@.str = [8 x i8] c"--cache\00"
@.str.1 = [11 x i8] c"bad option\00"
@.str.2 = [9 x i8] c"--tmpdir\00"
@.str.3 = [6 x i8] c"--ids\00"
@.str.4 = [35 x i8] c"PATH=/usr/sbin:/sbin:/usr/bin:/bin\00"
@.str.5 = [19 x i8] c"PATH=/usr/bin:/bin\00"
@main.forbid = internal constant [122 x i8] c"LD_LIBRARY_PATH\00LD_PRELOAD\00LD_TRACE_LOADED_OBJECTS\00LD_BIND_NOW\00LD_AOUT_LIBRARY_PATH\00LD_AOUT_PRELOAD\00LD_NOWARN\00LD_KEEPDIR\00\00"
@.str.6 = [33 x i8] c"abrt-action-install-debuginfo.py\00"
@.str.7 = [14 x i8] c"Can't execute\00"
define i32 @main(i32 %0, i8** %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %27, label %6
6: ; preds = %2, %23
%7 = phi i8* [ %25, %23 ], [ %4, %2 ]
%8 = phi i8** [ %24, %23 ], [ %3, %2 ]
%9 = tail call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @error_msg_and_die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %13
13: ; preds = %11, %6
%14 = tail call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @error_msg_and_die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %18
18: ; preds = %16, %13
%19 = tail call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 @error_msg_and_die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %23
23: ; preds = %21, %18
%24 = getelementptr inbounds i8*, i8** %8, i64 1
%25 = load i8*, i8** %24
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %6
27: ; preds = %23, %2
%28 = tail call i64 (...) @getegid()
%29 = tail call i64 (...) @getgid()
%30 = icmp eq i64 %28, %29
br i1 %30, label %33, label %31
31: ; preds = %27
%32 = tail call i32 @setregid(i64 %28, i64 %28)
br label %33
33: ; preds = %31, %27
%34 = tail call i64 (...) @geteuid()
%35 = tail call i64 (...) @getuid()
%36 = icmp eq i64 %34, %35
br i1 %36, label %50, label %37
37: ; preds = %33
%38 = tail call i32 @setreuid(i64 %34, i64 %34)
%39 = icmp eq i64 %34, 0
%40 = select i1 %39, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0)
%41 = tail call i32 @putenv(i8* %40)
br label %42
42: ; preds = %42, %37
%43 = phi i8* [ getelementptr inbounds ([122 x i8], [122 x i8]* @main.forbid, i64 0, i64 0), %37 ], [ %47, %42 ]
%44 = tail call i32 @unsetenv(i8* %43)
%45 = tail call i64 @strlen(i8* dereferenceable(1) %43)
%46 = add nsw i64 %45, 1
%47 = getelementptr inbounds i8, i8* %43, i64 %46
%48 = load i8, i8* %47
%49 = icmp eq i8 %48, 0
br i1 %49, label %50, label %42
50: ; preds = %42, %33
%51 = tail call i32 @execvp(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8** %1)
%52 = tail call i32 @error_msg_and_die(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}