#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 */
scalar_t__ border_initialize(char *, char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char **argv) {
  if (argc < 4) {
    fprintf(stderr, "Usage: %s r_addr if_name tty_dev\n", argv[0]);
    return -1;
  }
  char addr[40];
  sprintf(addr, "abcd::1034:00FF:FE00:%s/64", argv[1]);
  char if_name[10];
  strncpy(if_name, argv[2], 10);
  char tty_dev[20];
  strncpy(tty_dev, argv[3], 20);
  if (border_initialize(if_name, addr, tty_dev) == 0) {
    while (1)
      ;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1188 <main+0x48>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe89(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f8 <main+0xb8>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe87(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x4a(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0xa,%edx
call   1030 <strncpy@plt>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    $0x14,%edx
call   1030 <strncpy@plt>
lea    -0x4a(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1050 <border_initialize@plt>
cmp    $0x0,%rax
jne    11f1 <main+0xb1>
jmp    11ec <main+0xac>
jmp    11ec <main+0xac>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jg     1170 <main+0x30>
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe9c(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    11c9 <main+0x89>
mov    0x8(%rbx),%rdx
lea    0xea7(%rip),%rsi
lea    0x30(%rsp),%r14
mov    %r14,%rdi
call   1060 <sprintf@plt>
mov    0x10(%rbx),%rsi
lea    0x6(%rsp),%r15
mov    %r15,%rdi
mov    $0xa,%edx
call   1030 <strncpy@plt>
mov    0x18(%rbx),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x14,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1050 <border_initialize@plt>
test   %rax,%rax
je     11e0 <main+0xa0>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
jmp    11e0 <main+0xa0>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: %s r_addr if_name tty_dev\0A\00"
@.str.1 = [27 x i8] c"abcd::1034:00FF:FE00:%s/64\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [40 x i8]
%7 = alloca [10 x i8]
%8 = alloca [20 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 -1, i32* %3
br label %41
17: ; preds = %2
%18 = getelementptr inbounds [40 x i8], [40 x i8]* %6, i64 0, i64 0
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @strncpy(i8* %23, i8* %26, i32 10)
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
%32 = call i32 @strncpy(i8* %28, i8* %31, i32 20)
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%34 = getelementptr inbounds [40 x i8], [40 x i8]* %6, i64 0, i64 0
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%36 = call i64 @border_initialize(i8* %33, i8* %34, i8* %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %17
br label %39
39: ; preds = %38, %39
br label %39
40: ; preds = %17
store i32 0, i32* %3
br label %41
41: ; preds = %40, %11
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"Usage: %s r_addr if_name tty_dev\0A\00"
@.str.1 = [27 x i8] c"abcd::1034:00FF:FE00:%s/64\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [40 x i8]
%4 = alloca [10 x i8]
%5 = alloca [20 x i8]
%6 = icmp slt i32 %0, 4
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %28
11: ; preds = %2
%12 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = call i32 @strncpy(i8* %16, i8* %18, i32 10)
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
%23 = call i32 @strncpy(i8* %20, i8* %22, i32 20)
%24 = call i64 @border_initialize(i8* %16, i8* %12, i8* %20)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %11, %26
br label %26
27: ; preds = %11
br label %28
28: ; preds = %27, %7
%29 = phi i32 [ -1, %7 ], [ 0, %27 ]
ret i32 %29
}