#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 link(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    printf("Usage: %s <src_file><dest_file>\n", argv[0]);
    return 0;
  }
  if (link(argv[1], argv[2]) == -1) {
    printf("Link Error\n");
    return 1;
  }
  printf("Files Linked\n");
  printf("Inode number of linked files\n");
  char str[100];
  sprintf(str, "ls -i %s %s\n", argv[1], argv[2]);
  system(str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1184 <main+0x44>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1208 <main+0xc8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1060 <link@plt>
cmp    $0xffffffff,%eax
jne    11bc <main+0x7c>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1208 <main+0xc8>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xe66(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x80(%rbp),%rdi
call   1030 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    11ad <main+0x5d>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
call   1070 <link@plt>
cmp    $0xffffffff,%eax
je     11c2 <main+0x72>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rbx),%rdx
mov    0x10(%rbx),%rcx
lea    0xe8b(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
xor    %ebx,%ebx
jmp    11d3 <main+0x83>
mov    (%rbx),%rsi
lea    0xe49(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11d3 <main+0x83>
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Usage: %s <src_file><dest_file>\0A\00"
@.str.1 = [12 x i8] c"Link Error\0A\00"
@.str.2 = [14 x i8] c"Files Linked\0A\00"
@.str.3 = [30 x i8] c"Inode number of linked files\0A\00"
@.str.4 = [13 x i8] c"ls -i %s %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 3
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 0, i32* %3
br label %38
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @link(i8* %17, i8* %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %25
23: ; preds = %14
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %38
25: ; preds = %14
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %31, i8* %34)
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%37 = call i32 @system(i8* %36)
store i32 0, i32* %3
br label %38
38: ; preds = %25, %23, %9
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [33 x i8] c"Usage: %s <src_file><dest_file>\0A\00"
@.str.4 = [13 x i8] c"ls -i %s %s\0A\00"
@str = [13 x i8] c"Files Linked\00"
@str.5 = [29 x i8] c"Inode number of linked files\00"
@str.6 = [11 x i8] c"Link Error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = icmp eq i32 %0, 3
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %25
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32 @link(i8* %10, i8* %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %8
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.6, i64 0, i64 0))
br label %25
17: ; preds = %8
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.5, i64 0, i64 0))
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%21 = load i8*, i8** %9
%22 = load i8*, i8** %11
%23 = call i32 @sprintf(i8* %20, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %21, i8* %22)
%24 = call i32 @system(i8* %20)
br label %25
25: ; preds = %17, %15, %5
%26 = phi i32 [ 0, %5 ], [ 1, %15 ], [ 0, %17 ]
ret i32 %26
}