#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ install(char *, char *);
int /*<<< orphan*/ installPython(char *, char *);
scalar_t__ setuid(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 3) {
    fprintf(stderr, "Incorrect number of arguments!\n");
    return -1;
  }
  if (setuid(0) != 0) {
    fprintf(stderr, "setuid(): failed!\n");
    return -1;
  }
  install(argv[1], "mitsuba");
  install(argv[1], "mtsgui");
  install(argv[1], "mtssrv");
  install(argv[1], "mtsutil");
  install(argv[1], "mtsimport");
  installPython(argv[1], "2.6");
  installPython(argv[1], "2.7");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1181 <main+0x41>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1246 <main+0x106>
xor    %edi,%edi
call   1060 <setuid@plt>
cmp    $0x0,%rax
je     11b3 <main+0x73>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1246 <main+0x106>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe71(%rip),%rsi
call   1040 <install@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe65(%rip),%rsi
call   1040 <install@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe58(%rip),%rsi
call   1040 <install@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4b(%rip),%rsi
call   1040 <install@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3f(%rip),%rsi
call   1040 <install@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe35(%rip),%rsi
call   1030 <installPython@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe25(%rip),%rsi
call   1030 <installPython@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    116b <main+0x2b>
mov    %rsi,%rbx
xor    %ebp,%ebp
xor    %edi,%edi
call   1060 <setuid@plt>
test   %rax,%rax
je     1187 <main+0x47>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
lea    0xeb7(%rip),%rsi
jmp    117b <main+0x3b>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    11f7 <main+0xb7>
mov    0x8(%rbx),%rdi
lea    0xea1(%rip),%rsi
call   1040 <install@plt>
mov    0x8(%rbx),%rdi
lea    0xe99(%rip),%rsi
call   1040 <install@plt>
mov    0x8(%rbx),%rdi
lea    0xe90(%rip),%rsi
call   1040 <install@plt>
mov    0x8(%rbx),%rdi
lea    0xe87(%rip),%rsi
call   1040 <install@plt>
mov    0x8(%rbx),%rdi
lea    0xe7f(%rip),%rsi
call   1040 <install@plt>
mov    0x8(%rbx),%rdi
lea    0xe79(%rip),%rsi
call   1030 <installPython@plt>
mov    0x8(%rbx),%rdi
lea    0xe6d(%rip),%rsi
call   1030 <installPython@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"Incorrect number of arguments!\0A\00"
@.str.1 = [19 x i8] c"setuid(): failed!\0A\00"
@.str.2 = [8 x i8] c"mitsuba\00"
@.str.3 = [7 x i8] c"mtsgui\00"
@.str.4 = [7 x i8] c"mtssrv\00"
@.str.5 = [8 x i8] c"mtsutil\00"
@.str.6 = [10 x i8] c"mtsimport\00"
@.str.7 = [4 x i8] c"2.6\00"
@.str.8 = [4 x i8] c"2.7\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 3
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %46
11: ; preds = %2
%12 = call i64 @setuid(i32 0)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %46
17: ; preds = %11
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @install(i8* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @install(i8* %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @install(i8* %28, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @install(i8* %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @install(i8* %36, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @installPython(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = load i8*, i8** %43
%45 = call i32 @installPython(i8* %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %3
br label %46
46: ; preds = %17, %14, %8
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"Incorrect number of arguments!\0A\00"
@.str.1 = [19 x i8] c"setuid(): failed!\0A\00"
@.str.2 = [8 x i8] c"mitsuba\00"
@.str.3 = [7 x i8] c"mtsgui\00"
@.str.4 = [7 x i8] c"mtssrv\00"
@.str.5 = [8 x i8] c"mtsutil\00"
@.str.6 = [10 x i8] c"mtsimport\00"
@.str.7 = [4 x i8] c"2.6\00"
@.str.8 = [4 x i8] c"2.7\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %29
7: ; preds = %2
%8 = tail call i64 @setuid(i32 0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %29
13: ; preds = %7
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 @install(i8* %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%17 = load i8*, i8** %14
%18 = tail call i32 @install(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%19 = load i8*, i8** %14
%20 = tail call i32 @install(i8* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%21 = load i8*, i8** %14
%22 = tail call i32 @install(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
%23 = load i8*, i8** %14
%24 = tail call i32 @install(i8* %23, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%25 = load i8*, i8** %14
%26 = tail call i32 @installPython(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%27 = load i8*, i8** %14
%28 = tail call i32 @installPython(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %29
29: ; preds = %13, %10, %4
%30 = phi i32 [ -1, %4 ], [ -1, %10 ], [ 0, %13 ]
ret i32 %30
}