#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*/ assert(int);
int chdir(char *);
int chmod(char *, int);
int chown(char *, int, int);
int strtol(char *, int /*<<< orphan*/, int);
int main() {
  int x = chdir("..");
  assert(x == 0);
  int y = chdir("..");
  assert(y == 0);
  char mode1[] = "0700";
  char mode2[] = "0400";
  int j;
  j = strtol(mode1, 0, 8);
  int a = chmod("/home/siddharth/Desktop/foo.txt", j);
  assert(a != -1);
  j = strtol(mode2, 0, 8);
  a = chmod("/home/siddharth/Desktop/foo.txt", j);
  assert(a != -1);
  int b = chown("/home/siddharth/Desktop/foo.txt", 0, 0);
  assert(b != -1);
  b = chown("/home/siddharth/Desktop/foo.txt", 1000, 1000);
  assert(b != -1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <chdir@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe7a(%rip),%rdi
call   1030 <chdir@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    0xe5e(%rip),%eax
mov    %eax,-0x11(%rbp)
mov    0xe59(%rip),%al
mov    %al,-0xd(%rbp)
mov    0xe51(%rip),%eax
mov    %eax,-0x16(%rbp)
mov    0xe4c(%rip),%al
mov    %al,-0x12(%rbp)
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe2d(%rip),%rdi
call   1070 <chmod@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x16(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xdf7(%rip),%rdi
call   1070 <chmod@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xdd7(%rip),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1060 <chown@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xdb3(%rip),%rdi
mov    $0x3e8,%edx
mov    %edx,%esi
call   1060 <chown@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rbx
mov    %rbx,%rdi
call   1030 <chdir@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
call   1030 <chdir@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
movb   $0x0,0xc(%rsp)
movl   $0x30303730,0x8(%rsp)
30
movb   $0x0,0x4(%rsp)
movl   $0x30303430,(%rsp)
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <strtol@plt>
lea    0xe56(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <chmod@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1040 <assert@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <strtol@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <chmod@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <chown@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    $0x3e8,%edx
call   1060 <chown@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"..\00"
@__const.main.mode1 = [5 x i8] c"0700\00"
@__const.main.mode2 = [5 x i8] c"0400\00"
@.str.1 = [32 x i8] c"/home/siddharth/Desktop/foo.txt\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [5 x i8]
%5 = alloca [5 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = bitcast [5 x i8]* %4 to i8*
%20 = bitcast [5 x i8]* %5 to i8*
%21 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%22 = call i32 @strtol(i8* %21, i32 0, i32 8)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = call i32 @chmod(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %23)
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = icmp ne i32 %25, -1
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%30 = call i32 @strtol(i8* %29, i32 0, i32 8)
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = call i32 @chmod(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %31)
store i32 %32, i32* %7
%33 = load i32, i32* %7
%34 = icmp ne i32 %33, -1
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = call i32 @chown(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0)
store i32 %37, i32* %8
%38 = load i32, i32* %8
%39 = icmp ne i32 %38, -1
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = call i32 @chown(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 1000, i32 1000)
store i32 %42, i32* %8
%43 = load i32, i32* %8
%44 = icmp ne i32 %43, -1
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"..\00"
@__const.main.mode1 = [5 x i8] c"0700\00"
@__const.main.mode2 = [5 x i8] c"0400\00"
@.str.1 = [32 x i8] c"/home/siddharth/Desktop/foo.txt\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = alloca [5 x i8]
%3 = tail call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i32 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%13 = call i32 @strtol(i8* %11, i32 0, i32 8)
%14 = call i32 @chmod(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = icmp ne i32 %14, -1
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = call i32 @strtol(i8* %12, i32 0, i32 8)
%19 = call i32 @chmod(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = icmp ne i32 %19, -1
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = call i32 @chown(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0)
%24 = icmp ne i32 %23, -1
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = call i32 @chown(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 1000, i32 1000)
%28 = icmp ne i32 %27, -1
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
ret i32 0
}