#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*/ get_resource_name(char *, char *);
int get_resource_size(char *);
int /*<<< orphan*/ get_resource_type(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
void print_header(char *data, char *buf) {
  char tmp[512];
  int size;
  if (buf)
    buf[0] = 0;
  get_resource_type(data, tmp);
  printf("Type: %s - ", tmp);
  if (buf)
    strcat(buf, tmp);
  get_resource_name(data, tmp);
  printf("Name: %s - ", tmp);
  if (buf)
    strcat(buf, tmp);
  size = get_resource_size(data);
  printf("Size: %d (0x%x)\n", size, size);
}


x86 assembly (clang, -O0):
<print_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1175 <print_header+0x25>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1050 <get_resource_type@plt>
lea    -0x210(%rbp),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11b5 <print_header+0x65>
mov    -0x10(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1070 <get_resource_name@plt>
lea    -0x210(%rbp),%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11f5 <print_header+0xa5>
mov    -0x10(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
call   1030 <get_resource_size@plt>
mov    %eax,-0x214(%rbp)
mov    -0x214(%rbp),%esi
mov    -0x214(%rbp),%edx
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_header>:
push   %r15
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %rdi,%r14
test   %rsi,%rsi
je     11bd <print_header+0x6d>
mov    %rsi,%rbx
movb   $0x0,(%rsi)
mov    %rsp,%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <get_resource_type@plt>
lea    0xe81(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <get_resource_name@plt>
lea    0xe66(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
jmp    11f8 <print_header+0xa8>
mov    %rsp,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <get_resource_type@plt>
lea    0xe2e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <get_resource_name@plt>
lea    0xe1e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <get_resource_size@plt>
lea    0xe11(%rip),%rdi
mov    %eax,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Type: %s - \00"
@.str.1 = [12 x i8] c"Name: %s - \00"
@.str.2 = [17 x i8] c"Size: %d (0x%x)\0A\00"
define void @print_header(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [512 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 0
store i8 0, i8* %11
br label %12
12: ; preds = %9, %2
%13 = load i8*, i8** %3
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%15 = call i32 @get_resource_type(i8* %13, i8* %14)
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %4
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %24
20: ; preds = %12
%21 = load i8*, i8** %4
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%23 = call i32 @strcat(i8* %21, i8* %22)
br label %24
24: ; preds = %20, %12
%25 = load i8*, i8** %3
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%27 = call i32 @get_resource_name(i8* %25, i8* %26)
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %4
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %36
32: ; preds = %24
%33 = load i8*, i8** %4
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%35 = call i32 @strcat(i8* %33, i8* %34)
br label %36
36: ; preds = %32, %24
%37 = load i8*, i8** %3
%38 = call i32 @get_resource_size(i8* %37)
store i32 %38, i32* %6
%39 = load i32, i32* %6
%40 = load i32, i32* %6
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %39, i32 %40)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Type: %s - \00"
@.str.1 = [12 x i8] c"Name: %s - \00"
@.str.2 = [17 x i8] c"Size: %d (0x%x)\0A\00"
define void @print_header(i8* %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = icmp eq i8* %1, null
br i1 %5, label %13, label %6
6: ; preds = %2
store i8 0, i8* %1
%7 = call i32 @get_resource_type(i8* %0, i8* %4)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %4)
%9 = call i32 @strcat(i8* %1, i8* %4)
%10 = call i32 @get_resource_name(i8* %0, i8* %4)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%12 = call i32 @strcat(i8* %1, i8* %4)
br label %18
13: ; preds = %2
%14 = call i32 @get_resource_type(i8* %0, i8* %4)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %4)
%16 = call i32 @get_resource_name(i8* %0, i8* %4)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %18
18: ; preds = %13, %6
%19 = call i32 @get_resource_size(i8* %0)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %19)
ret void
}