#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 S_IRWXG;
int S_IRWXO;
int S_IRWXU;
int chmod(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ setuid(int /*<<< orphan*/);
int main(int argc, char **argv, char **envp) {
  setuid(0);
  int ret = chmod("/var/log/squid/access.log", S_IRWXU | S_IRWXG | S_IRWXO);
  int dir = chmod("/var/log/squid/", S_IRWXU | S_IRWXG | S_IRWXO);
  if (ret == -1)
    perror("No se pudo cambiar los permisos de forma correcta");
  if (dir == -1)
    perror("No se pudo cambiar los permisos de forma correcta");
  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)
mov    %rdx,-0x18(%rbp)
xor    %edi,%edi
call   1050 <setuid@plt>
mov    0x2e88(%rip),%rax
mov    (%rax),%esi
mov    0x2e77(%rip),%rax
or     (%rax),%esi
mov    0x2e86(%rip),%rax
or     (%rax),%esi
lea    0xe8d(%rip),%rdi
call   1030 <chmod@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e5e(%rip),%rax
mov    (%rax),%esi
mov    0x2e4d(%rip),%rax
or     (%rax),%esi
mov    0x2e5c(%rip),%rax
or     (%rax),%esi
lea    0xe7d(%rip),%rdi
call   1030 <chmod@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    11bb <main+0x8b>
lea    0xe74(%rip),%rdi
call   1040 <perror@plt>
cmpl   $0xffffffff,-0x20(%rbp)
jne    11d1 <main+0xa1>
lea    0xe5e(%rip),%rdi
call   1040 <perror@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <setuid@plt>
mov    0x2e9b(%rip),%r14
mov    0x2e8c(%rip),%rbx
mov    (%rbx),%esi
or     (%r14),%esi
mov    0x2e98(%rip),%r15
or     (%r15),%esi
lea    0xe9e(%rip),%rdi
call   1030 <chmod@plt>
mov    %eax,%ebp
mov    (%rbx),%esi
or     (%r14),%esi
or     (%r15),%esi
lea    0xea2(%rip),%rdi
call   1030 <chmod@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%ebp
je     1196 <main+0x66>
cmp    $0xffffffff,%ebx
je     11a7 <main+0x77>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe8d(%rip),%rdi
call   1040 <perror@plt>
cmp    $0xffffffff,%ebx
jne    1189 <main+0x59>
lea    0xe7c(%rip),%rdi
call   1040 <perror@plt>
jmp    1189 <main+0x59>

LLVM IR (-O0):
@.str = [26 x i8] c"/var/log/squid/access.log\00"
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = global i32 0
@.str.1 = [16 x i8] c"/var/log/squid/\00"
@.str.2 = [50 x i8] c"No se pudo cambiar los permisos de forma correcta\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%10 = call i32 @setuid(i32 0)
%11 = load i32, i32* @S_IRWXU
%12 = load i32, i32* @S_IRWXG
%13 = or i32 %11, %12
%14 = load i32, i32* @S_IRWXO
%15 = or i32 %13, %14
%16 = call i32 @chmod(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %15)
store i32 %16, i32* %8
%17 = load i32, i32* @S_IRWXU
%18 = load i32, i32* @S_IRWXG
%19 = or i32 %17, %18
%20 = load i32, i32* @S_IRWXO
%21 = or i32 %19, %20
%22 = call i32 @chmod(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %21)
store i32 %22, i32* %9
%23 = load i32, i32* %8
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %27
25: ; preds = %3
%26 = call i32 @perror(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %25, %3
%28 = load i32, i32* %9
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @perror(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"/var/log/squid/access.log\00"
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@S_IRWXO = global i32 0
@.str.1 = [16 x i8] c"/var/log/squid/\00"
@.str.2 = [50 x i8] c"No se pudo cambiar los permisos de forma correcta\00"
define i32 @main(i32 %0, i8** nocapture readnone %1, i8** nocapture readnone %2) {
%4 = tail call i32 @setuid(i32 0)
%5 = load i32, i32* @S_IRWXU
%6 = load i32, i32* @S_IRWXG
%7 = or i32 %6, %5
%8 = load i32, i32* @S_IRWXO
%9 = or i32 %7, %8
%10 = tail call i32 @chmod(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* @S_IRWXU
%12 = load i32, i32* @S_IRWXG
%13 = or i32 %12, %11
%14 = load i32, i32* @S_IRWXO
%15 = or i32 %13, %14
%16 = tail call i32 @chmod(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = icmp eq i32 %10, -1
br i1 %17, label %18, label %20
18: ; preds = %3
%19 = tail call i32 @perror(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %3
%21 = icmp eq i32 %16, -1
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = tail call i32 @perror(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
ret i32 0
}