#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*/ doTest(char *);
int /*<<< orphan*/ getuid();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setuid(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("Please enter the filename \r\n");
    return 1;
  }
  char *file = argv[1];
  doTest(file);
  setuid(getuid());
  doTest(file);
  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   $0x2,-0x8(%rbp)
jge    1178 <main+0x38>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ab <main+0x6b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <doTest@plt>
mov    $0x0,%al
call   1030 <getuid@plt>
mov    %eax,%edi
call   1060 <setuid@plt>
mov    -0x18(%rbp),%rdi
call   1050 <doTest@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     115c <main+0x1c>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
jmp    1180 <main+0x40>
mov    0x8(%rsi),%r14
mov    %r14,%rdi
call   1050 <doTest@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getuid@plt>
mov    %eax,%edi
call   1060 <setuid@plt>
mov    %r14,%rdi
call   1050 <doTest@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Please enter the filename \0D\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %21
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
store i8* %14, i8** %6
%15 = load i8*, i8** %6
%16 = call i32 @doTest(i8* %15)
%17 = call i32 (...) @getuid()
%18 = call i32 @setuid(i32 %17)
%19 = load i8*, i8** %6
%20 = call i32 @doTest(i8* %19)
store i32 0, i32* %3
br label %21
21: ; preds = %11, %9
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@str = [28 x i8] c"Please enter the filename \0D\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %13
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @doTest(i8* %8)
%10 = tail call i32 (...) @getuid()
%11 = tail call i32 @setuid(i32 %10)
%12 = tail call i32 @doTest(i8* %8)
br label %13
13: ; preds = %6, %4
%14 = phi i32 [ 1, %4 ], [ 0, %6 ]
ret i32 %14
}