#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*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int link(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (3 != argc) {
    fprintf(stderr, "usage: %s old_file new_link\n", argv[0]);
    return -1;
  }
  int ret = link(argv[1], argv[2]);
  if (0 != ret) {
    fprintf(stderr, "[%s:%d] %s\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/chuanqinggao/daily-mark/refs/heads/"
            "master/cplusplus/link.c",
            18, strerror(errno));
    perror("defined error");
    return -1;
  } else {
    fprintf(stderr, "done success.\n");
  }
  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    $0x3,%eax
cmp    -0x8(%rbp),%eax
je     118e <main+0x4e>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1221 <main+0xe1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1050 <link@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
je     1203 <main+0xc3>
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x18(%rbp),%edi
mov    %rax,%r8
lea    0xe45(%rip),%rsi
lea    0xe4a(%rip),%rdx
mov    $0x12,%ecx
mov    $0x0,%al
call   1030 <fprintf@plt>
lea    0xecc(%rip),%rdi
call   1040 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1221 <main+0xe1>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xeb9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    1176 <main+0x36>
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rsi
call   1050 <link@plt>
mov    0x2e84(%rip),%rcx
mov    (%rcx),%ebx
test   %eax,%eax
jne    119e <main+0x5e>
lea    0xf63(%rip),%rsi
xor    %ebp,%ebp
mov    %ebx,%edi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1195 <main+0x55>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe77(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe6a(%rip),%rsi
lea    0xe6f(%rip),%rdx
mov    %ebx,%edi
mov    $0x12,%ecx
mov    %rax,%r8
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0xeec(%rip),%rdi
call   1040 <perror@plt>
jmp    1190 <main+0x50>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"usage: %s old_file new_link\0A\00"
@.str.1 = [12 x i8] c"[%s:%d] %s\0A\00"
@.str.2 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/chuanqinggao/daily-mark/refs/heads/master/cplusplus/link.c\00"
@errno = global i32 0
@.str.3 = [14 x i8] c"defined error\00"
@.str.4 = [15 x i8] c"done success.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 3, %7
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 -1, i32* %3
br label %35
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @link(i8* %18, i8* %21)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = icmp ne i32 0, %23
br i1 %24, label %25, label %31
25: ; preds = %15
%26 = load i32, i32* @stderr
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 18, i8* %28)
%30 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %35
31: ; preds = %15
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %31
store i32 0, i32* %3
br label %35
35: ; preds = %34, %25, %9
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"usage: %s old_file new_link\0A\00"
@.str.1 = [12 x i8] c"[%s:%d] %s\0A\00"
@.str.2 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/chuanqinggao/daily-mark/refs/heads/master/cplusplus/link.c\00"
@errno = global i32 0
@.str.3 = [14 x i8] c"defined error\00"
@.str.4 = [15 x i8] c"done success.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %23
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, 0
%15 = load i32, i32* @stderr
br i1 %14, label %21, label %16
16: ; preds = %8
%17 = load i32, i32* @errno
%18 = tail call i8* @strerror(i32 %17)
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 18, i8* %18)
%20 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %23
21: ; preds = %8
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %23
23: ; preds = %16, %21, %4
%24 = phi i32 [ -1, %4 ], [ -1, %16 ], [ 0, %21 ]
ret i32 %24
}