#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 */
struct kobject {
  int dummy;
};

/* Variables and functions */
char *kobject_name(struct kobject const *);
scalar_t__ mallocnull(int);
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
unsigned long strlen(char const *);
char *make_class_name(char const *name, struct kobject *kobj) {
  char *class_name;
  int size;
  unsigned long tmp;
  char const *tmp___0;
  unsigned long tmp___1;
  char const *tmp___2;
  tmp = strlen(name);
  tmp___0 = kobject_name((struct kobject const *)kobj);
  tmp___1 = strlen(tmp___0);
  size = (int)((tmp + tmp___1) + 2UL);
  class_name = (char *)mallocnull(size);
  if (!class_name) {
    return ((char *)((void *)0));
  }
  strcpy(class_name, name);
  strcat(class_name, ":");
  tmp___2 = kobject_name((struct kobject const *)kobj);
  strcat(class_name, tmp___2);
  return (class_name);
}


x86 assembly (clang, -O0):
<make_class_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <kobject_name@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
add    -0x40(%rbp),%rax
add    $0x2,%rax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <mallocnull@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ba <make_class_name+0x6a>
movq   $0x0,-0x8(%rbp)
jmp    11f9 <make_class_name+0xa9>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x18(%rbp),%rdi
call   1050 <kobject_name@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_class_name>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1060 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <kobject_name@plt>
mov    %rax,%rdi
call   1060 <strlen@plt>
lea    (%rax,%rbx,1),%edi
add    $0x2,%edi
call   1040 <mallocnull@plt>
test   %rax,%rax
je     11b5 <make_class_name+0x65>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe68(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %r14,%rdi
call   1050 <kobject_name@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1070 <strcat@plt>
jmp    11b7 <make_class_name+0x67>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.kobject = type { i32 }
@.str = [2 x i8] c":\00"
define i8* @make_class_name(i8* %0, %struct.kobject* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.kobject*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
store i8* %0, i8** %4
store %struct.kobject* %1, %struct.kobject** %5
%12 = load i8*, i8** %4
%13 = call i64 @strlen(i8* %12)
store i64 %13, i64* %8
%14 = load %struct.kobject*, %struct.kobject** %5
%15 = call i8* @kobject_name(%struct.kobject* %14)
store i8* %15, i8** %9
%16 = load i8*, i8** %9
%17 = call i64 @strlen(i8* %16)
store i64 %17, i64* %10
%18 = load i64, i64* %8
%19 = load i64, i64* %10
%20 = add i64 %18, %19
%21 = add i64 %20, 2
%22 = trunc i64 %21 to i32
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = call i64 @mallocnull(i32 %23)
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %6
%26 = load i8*, i8** %6
%27 = icmp ne i8* %26, null
br i1 %27, label %29, label %28
28: ; preds = %2
store i8* null, i8** %3
br label %41
29: ; preds = %2
%30 = load i8*, i8** %6
%31 = load i8*, i8** %4
%32 = call i32 @strcpy(i8* %30, i8* %31)
%33 = load i8*, i8** %6
%34 = call i32 @strcat(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%35 = load %struct.kobject*, %struct.kobject** %5
%36 = call i8* @kobject_name(%struct.kobject* %35)
store i8* %36, i8** %11
%37 = load i8*, i8** %6
%38 = load i8*, i8** %11
%39 = call i32 @strcat(i8* %37, i8* %38)
%40 = load i8*, i8** %6
store i8* %40, i8** %3
br label %41
41: ; preds = %29, %28
%42 = load i8*, i8** %3
ret i8* %42
}

LLVM IR (-O2):
%struct.kobject = type { i32 }
@.str = [2 x i8] c":\00"
define i8* @make_class_name(i8* %0, %struct.kobject* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = tail call i8* @kobject_name(%struct.kobject* %1)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %4)
%6 = add i64 %5, %3
%7 = trunc i64 %6 to i32
%8 = add i32 %7, 2
%9 = tail call i64 @mallocnull(i32 %8)
%10 = inttoptr i64 %9 to i8*
%11 = icmp eq i64 %9, 0
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = tail call i32 @strcpy(i8* %10, i8* %0)
%14 = tail call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = tail call i8* @kobject_name(%struct.kobject* %1)
%16 = tail call i32 @strcat(i8* %10, i8* %15)
br label %17
17: ; preds = %2, %12
%18 = phi i8* [ %10, %12 ], [ null, %2 ]
ret i8* %18
}