#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*/ err(int, char *, char const *, char const *);
int link(char const *, char const *);
char *name_get(unsigned int);
int /*<<< orphan*/ printf(char *, char const *, char const *);
void do_link(unsigned from, unsigned to) {
  const char *fromstr, *tostr;
  fromstr = name_get(from);
  tostr = name_get(to);
  if (link(fromstr, tostr) == -1) {
    err(1, "link %s to %s", fromstr, tostr);
  }
  printf("link %s %s\n", fromstr, tostr);
}


x86 assembly (clang, -O0):
<do_link>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <name_get@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <name_get@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <link@plt>
cmp    $0xffffffff,%eax
jne    1195 <do_link+0x55>
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%edi
lea    0xe70(%rip),%rsi
call   1040 <err@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_link>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
call   1050 <name_get@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1050 <name_get@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1060 <link@plt>
cmp    $0xffffffff,%eax
jne    117f <do_link+0x3f>
lea    0xe91(%rip),%rsi
mov    $0x1,%edi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1040 <err@plt>
lea    0xe88(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"link %s to %s\00"
@.str.1 = [12 x i8] c"link %s %s\0A\00"
define void @do_link(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = call i8* @name_get(i32 %7)
store i8* %8, i8** %5
%9 = load i32, i32* %4
%10 = call i8* @name_get(i32 %9)
store i8* %10, i8** %6
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = call i32 @link(i8* %11, i8* %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i8*, i8** %5
%17 = load i8*, i8** %6
%18 = call i32 @err(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17)
br label %19
19: ; preds = %15, %2
%20 = load i8*, i8** %5
%21 = load i8*, i8** %6
%22 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %20, i8* %21)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"link %s to %s\00"
@.str.1 = [12 x i8] c"link %s %s\0A\00"
define void @do_link(i32 %0, i32 %1) {
%3 = tail call i8* @name_get(i32 %0)
%4 = tail call i8* @name_get(i32 %1)
%5 = tail call i32 @link(i8* %3, i8* %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
br label %9
9: ; preds = %7, %2
%10 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %4)
ret void
}