#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 const *, int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char const *, char *, int);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
void print_message(const char *msgfmt, const char *name) {
  char short_name[(23 + 2) + 4] = {0};
  int len;
  len = strlen(name);
  if (len == 0) {
    strcpy(short_name, "NULL");
  } else if (len <= (23 + 2)) {
    strcpy(short_name, name);
  } else {
    memset(short_name, '.', (23 + 2) + 3);
    memcpy(short_name, name, (23 + 2));
  }
  printf(msgfmt, short_name, len);
}


x86 assembly (clang, -O0):
<print_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x1d,%edx
call   1060 <memset@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    119b <print_message+0x4b>
lea    -0x30(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11e1 <print_message+0x91>
cmpl   $0x19,-0x34(%rbp)
jg     11b7 <print_message+0x67>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11dc <print_message+0x8c>
lea    -0x30(%rbp),%rdi
mov    $0x2e,%esi
mov    $0x1c,%edx
call   1060 <memset@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x19,%edx
call   1070 <memcpy@plt>
jmp    11e1 <print_message+0x91>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1050 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_message>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movups %xmm0,0xd(%rsp)
movaps %xmm0,(%rsp)
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
test   %eax,%eax
je     118c <print_message+0x3c>
cmp    $0x19,%ebp
jg     119d <print_message+0x4d>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
jmp    11c2 <print_message+0x72>
lea    0xe6d(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
jmp    11c2 <print_message+0x72>
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x2e,%esi
mov    $0x1c,%edx
call   1060 <memset@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x19,%edx
call   1070 <memcpy@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
mov    %ebp,%edx
call   1050 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"NULL\00"
define void @print_message(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [29 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = bitcast [29 x i8]* %5 to i8*
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = getelementptr inbounds [29 x i8], [29 x i8]* %5, i64 0, i64 0
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %29
15: ; preds = %2
%16 = load i32, i32* %6
%17 = icmp sle i32 %16, 25
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = getelementptr inbounds [29 x i8], [29 x i8]* %5, i64 0, i64 0
%20 = load i8*, i8** %4
%21 = call i32 @strcpy(i8* %19, i8* %20)
br label %28
22: ; preds = %15
%23 = getelementptr inbounds [29 x i8], [29 x i8]* %5, i64 0, i64 0
%24 = call i32 @memset(i8* %23, i8 signext 46, i32 28)
%25 = getelementptr inbounds [29 x i8], [29 x i8]* %5, i64 0, i64 0
%26 = load i8*, i8** %4
%27 = call i32 @memcpy(i8* %25, i8* %26, i32 25)
br label %28
28: ; preds = %22, %18
br label %29
29: ; preds = %28, %12
%30 = load i8*, i8** %3
%31 = getelementptr inbounds [29 x i8], [29 x i8]* %5, i64 0, i64 0
%32 = load i32, i32* %6
%33 = call i32 @printf(i8* %30, i8* %31, i32 %32)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"NULL\00"
define void @print_message(i8* %0, i8* %1) {
%3 = alloca [29 x i8]
%4 = getelementptr inbounds [29 x i8], [29 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %16
9: ; preds = %2
%10 = icmp slt i32 %5, 26
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = call i32 @strcpy(i8* %4, i8* %1)
br label %16
13: ; preds = %9
%14 = call i32 @memset(i8* %4, i8 signext 46, i32 28)
%15 = call i32 @memcpy(i8* %4, i8* %1, i32 25)
br label %16
16: ; preds = %11, %13, %7
%17 = call i32 @printf(i8* %0, i8* %4, i32 %5)
ret void
}