#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 */
char *memcpy(char *, char const *, size_t);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char const *);
void h(const char *p, const char *f) {
  size_t pl = p == NULL ? 0 : strlen(p);
  size_t fl = strlen(f) + 1;
  char a[pl + 1 + fl];
  char *cp = a;
  char b[pl + 5 + fl * 2];
  char *cccp = b;
  if (p != NULL) {
    cp = memcpy(cp, p, pl);
    *cp++ = ':';
  }
  memcpy(cp, f, fl);
  strcpy(b, a);
  puts(a);
}


x86 assembly (clang, -O0):
<h>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1165 <h+0x25>
xor    %eax,%eax
mov    %eax,-0x4c(%rbp)
jmp    1171 <h+0x31>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rdx
lea    0x1(%rax,%rdx,1),%rcx
mov    %rsp,%rsi
mov    %rsi,-0x28(%rbp)
lea    0x10(%rax,%rdx,1),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x60(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x30(%rbp)
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rdx
lea    0x5(%rax,%rdx,2),%rcx
lea    0x14(%rax,%rdx,2),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x58(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x40(%rbp)
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     121b <h+0xdb>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <memcpy@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x3a,(%rax)
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x60(%rbp),%rdi
call   1040 <puts@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<h>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
test   %rdi,%rdi
je     1166 <h+0x26>
mov    %r15,%rdi
call   1050 <strlen@plt>
movslq %eax,%r12
jmp    1169 <h+0x29>
xor    %r12d,%r12d
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
lea    0x1(%rax),%rdx
lea    (%r12,%rax,1),%rcx
add    $0x11,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rbx
sub    %rcx,%rbx
mov    %rbx,%rsp
lea    (%r12,%rax,2),%rax
add    $0x16,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r13
sub    %rax,%r13
mov    %r13,%rsp
mov    %rbx,%rdi
test   %r15,%r15
je     11c4 <h+0x84>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rdx,%r15
mov    %r12,%rdx
call   1060 <memcpy@plt>
mov    %r15,%rdx
lea    0x1(%rbx),%rdi
movb   $0x3a,(%rbx)
mov    %r14,%rsi
call   1060 <memcpy@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @h(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%12 = load i8*, i8** %3
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %2
br label %18
15: ; preds = %2
%16 = load i8*, i8** %3
%17 = call i32 @strlen(i8* %16)
br label %18
18: ; preds = %15, %14
%19 = phi i32 [ 0, %14 ], [ %17, %15 ]
%20 = sext i32 %19 to i64
store i64 %20, i64* %5
%21 = load i8*, i8** %4
%22 = call i32 @strlen(i8* %21)
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
store i64 %24, i64* %6
%25 = load i64, i64* %5
%26 = add i64 %25, 1
%27 = load i64, i64* %6
%28 = add i64 %26, %27
%29 = call i8* @llvm.stacksave()
store i8* %29, i8** %7
%30 = alloca i8, i64 %28
store i64 %28, i64* %8
store i8* %30, i8** %9
%31 = load i64, i64* %5
%32 = add i64 %31, 5
%33 = load i64, i64* %6
%34 = mul i64 %33, 2
%35 = add i64 %32, %34
%36 = alloca i8, i64 %35
store i64 %35, i64* %10
store i8* %36, i8** %11
%37 = load i8*, i8** %3
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %46
39: ; preds = %18
%40 = load i8*, i8** %9
%41 = load i8*, i8** %3
%42 = load i64, i64* %5
%43 = call i8* @memcpy(i8* %40, i8* %41, i64 %42)
store i8* %43, i8** %9
%44 = load i8*, i8** %9
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %9
store i8 58, i8* %44
br label %46
46: ; preds = %39, %18
%47 = load i8*, i8** %9
%48 = load i8*, i8** %4
%49 = load i64, i64* %6
%50 = call i8* @memcpy(i8* %47, i8* %48, i64 %49)
%51 = call i32 @strcpy(i8* %36, i8* %30)
%52 = call i32 @puts(i8* %30)
%53 = load i8*, i8** %7
ret void
}

LLVM IR (-O2):
define void @h(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @strlen(i8* %0)
%6 = sext i32 %5 to i64
br label %7
7: ; preds = %2, %4
%8 = phi i64 [ %6, %4 ], [ 0, %2 ]
%9 = tail call i32 @strlen(i8* %1)
%10 = add nsw i32 %9, 1
%11 = sext i32 %10 to i64
%12 = add nsw i64 %8, 1
%13 = add nsw i64 %12, %11
%14 = alloca i8, i64 %13
%15 = add nsw i64 %8, 5
%16 = shl nsw i64 %11, 1
%17 = add nsw i64 %15, %16
%18 = alloca i8, i64 %17
br i1 %3, label %21, label %19
19: ; preds = %7
%20 = getelementptr inbounds i8, i8* %14, i64 1
store i8 58, i8* %14
br label %21
21: ; preds = %19, %7
%22 = phi i8* [ %20, %19 ], [ %14, %7 ]
%23 = call i32 @strcpy(i8* %18, i8* %14)
%24 = call i32 @puts(i8* %14)
ret void
}