#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 EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ chdir(char *);
scalar_t__ symlink(char *, char *);
int main(int argc, char **argv) {
  char *long_dir, *sname, *tname;
  if (4 > argc)
    return EXIT_FAILURE;
  else {
    long_dir = argv[1];
    tname = argv[2];
    sname = argv[3];
  }
  for (int i = 0; i < 64; i++) {
    if (0 > chdir(long_dir))
      return EXIT_FAILURE;
  }
  if (0 > symlink(tname, sname))
    return EXIT_FAILURE;
  else
    return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x4,%eax
cmp    -0x8(%rbp),%eax
jle    1155 <main+0x35>
mov    0x2e95(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11fd <main+0xdd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x40,-0x2c(%rbp)
jge    11c5 <main+0xa5>
mov    -0x18(%rbp),%rdi
call   1030 <chdir@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    11b2 <main+0x92>
mov    0x2e38(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11fd <main+0xdd>
jmp    11b7 <main+0x97>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1180 <main+0x60>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <symlink@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jle    11f1 <main+0xd1>
mov    0x2df9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11fd <main+0xdd>
mov    0x2de0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2eb1(%rip),%r12
cmp    $0x4,%edi
jl     1182 <main+0x62>
mov    0x8(%rsi),%rbx
mov    0x10(%rsi),%r15
mov    0x18(%rsi),%r14
mov    $0x40,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1030 <chdir@plt>
test   %rax,%rax
js     1182 <main+0x62>
add    $0xffffffff,%ebp
jne    1150 <main+0x30>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <symlink@plt>
test   %rax,%rax
jns    117b <main+0x5b>
mov    0x2e67(%rip),%r12
jmp    1182 <main+0x62>
mov    0x2e56(%rip),%r12
mov    (%r12),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp sgt i32 4, %10
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %3
br label %47
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %6
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
store i8* %20, i8** %8
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 3
%23 = load i8*, i8** %22
store i8* %23, i8** %7
br label %24
24: ; preds = %14
store i32 0, i32* %9
br label %25
25: ; preds = %35, %24
%26 = load i32, i32* %9
%27 = icmp slt i32 %26, 64
br i1 %27, label %28, label %38
28: ; preds = %25
%29 = load i8*, i8** %6
%30 = call i64 @chdir(i8* %29)
%31 = icmp sgt i64 0, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load i32, i32* @EXIT_FAILURE
store i32 %33, i32* %3
br label %47
34: ; preds = %28
br label %35
35: ; preds = %34
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %25
38: ; preds = %25
%39 = load i8*, i8** %8
%40 = load i8*, i8** %7
%41 = call i64 @symlink(i8* %39, i8* %40)
%42 = icmp sgt i64 0, %41
br i1 %42, label %43, label %45
43: ; preds = %38
%44 = load i32, i32* @EXIT_FAILURE
store i32 %44, i32* %3
br label %47
45: ; preds = %38
%46 = load i32, i32* @EXIT_SUCCESS
store i32 %46, i32* %3
br label %47
47: ; preds = %45, %43, %32, %12
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %22, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = getelementptr inbounds i8*, i8** %1, i64 3
%10 = load i8*, i8** %9
br label %14
11: ; preds = %14
%12 = add nuw nsw i32 %15, 1
%13 = icmp eq i32 %12, 64
br i1 %13, label %18, label %14
14: ; preds = %4, %11
%15 = phi i32 [ 0, %4 ], [ %12, %11 ]
%16 = tail call i64 @chdir(i8* %6)
%17 = icmp slt i64 %16, 0
br i1 %17, label %22, label %11
18: ; preds = %11
%19 = tail call i64 @symlink(i8* %8, i8* %10)
%20 = icmp slt i64 %19, 0
%21 = select i1 %20, i32* @EXIT_FAILURE, i32* @EXIT_SUCCESS
br label %22
22: ; preds = %14, %18, %2
%23 = phi i32* [ @EXIT_FAILURE, %2 ], [ %21, %18 ], [ @EXIT_FAILURE, %14 ]
%24 = load i32, i32* %23
ret i32 %24
}