#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*/ memcpy(char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *);
int strlen(char *);
int pad_callsign(char *target, char *input) {
  if (strlen(input) > 9)
    return -1;
  sprintf(target, ":         :");
  memcpy(target + 1, input, strlen(input));
  return 0;
}


x86 assembly (clang, -O0):
<pad_callsign>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x9,%eax
jle    115e <pad_callsign+0x2e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a1 <pad_callsign+0x71>
mov    -0x10(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pad_callsign>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x9,%ecx
jg     116d <pad_callsign+0x4d>
movabs $0x202020202020203a,%rax
20 20 20
mov    %rax,(%rbx)
movl   $0x3a2020,0x8(%rbx)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <memcpy@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c": :\00"
define i32 @pad_callsign(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = call i32 @strlen(i8* %6)
%8 = icmp sgt i32 %7, 9
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 -1, i32* %3
br label %19
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8*, i8** %5
%16 = load i8*, i8** %5
%17 = call i32 @strlen(i8* %16)
%18 = call i32 @memcpy(i8* %14, i8* %15, i32 %17)
store i32 0, i32* %3
br label %19
19: ; preds = %10, %9
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@.str = [12 x i8] c": :\00"
define i32 @pad_callsign(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = icmp sgt i32 %3, 9
br i1 %4, label %9, label %5
5: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(12) %0, i8* align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64 12, i1 false)
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = tail call i32 @strlen(i8* %1)
%8 = tail call i32 @memcpy(i8* %6, i8* %1, i32 %7)
br label %9
9: ; preds = %2, %5
%10 = phi i32 [ 0, %5 ], [ -1, %2 ]
ret i32 %10
}