#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*/ getuid();
int /*<<< orphan*/ perror(char *);
int setuid(int /*<<< orphan*/);
int /*<<< orphan*/ task(char const *);
int main(int argc, char const *argv[]) {
  task(argv[1]);
  if (-1 == setuid(getuid())) {
    perror("Can't set effective uid to real id");
    return 1;
  }
  task(argv[1]);
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <task@plt>
mov    $0x0,%al
call   1030 <getuid@plt>
mov    %eax,%edi
call   1060 <setuid@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1198 <main+0x58>
lea    0xe79(%rip),%rdi
call   1050 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a5 <main+0x65>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <task@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1040 <task@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <getuid@plt>
mov    %eax,%edi
call   1060 <setuid@plt>
cmp    $0xffffffff,%eax
je     1176 <main+0x36>
mov    0x8(%rbx),%rdi
call   1040 <task@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe83(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%ebp
jmp    116d <main+0x2d>

LLVM IR (-O0):
@.str = [35 x i8] c"Can't set effective uid to real id\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 i8**, i8*** %5
%7 = getelementptr inbounds i8*, i8** %6, i64 1
%8 = load i8*, i8** %7
%9 = call i32 @task(i8* %8)
%10 = call i32 (...) @getuid()
%11 = call i32 @setuid(i32 %10)
%12 = icmp eq i32 -1, %11
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %20
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @task(i8* %18)
br label %20
20: ; preds = %15, %13
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@.str = [35 x i8] c"Can't set effective uid to real id\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @task(i8* %4)
%6 = tail call i32 (...) @getuid()
%7 = tail call i32 @setuid(i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %14
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = tail call i32 @task(i8* %12)
br label %14
14: ; preds = %11, %9
%15 = phi i32 [ 1, %9 ], [ 0, %11 ]
ret i32 %15
}