#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 utsname {
  char *release;
};

/* Variables and functions */
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ uname(struct utsname *);
char *xmalloc(size_t);
char *boot_uname_r_str(void) {
  struct utsname uname_info;
  char *s;
  size_t len;
  if (uname(&uname_info))
    return "";
  len = strlen("/boot/System.map-") + strlen(uname_info.release) + 1;
  s = xmalloc(len);
  strcpy(s, "/boot/System.map-");
  strcat(s, uname_info.release);
  return s;
}


x86 assembly (clang, -O0):
<boot_uname_r_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x10(%rbp),%rdi
call   1050 <uname@plt>
cmp    $0x0,%rax
je     117b <boot_uname_r_str+0x2b>
lea    0xe9f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d5 <boot_uname_r_str+0x85>
lea    0xe7e(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <xmalloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<boot_uname_r_str>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
call   1050 <uname@plt>
test   %rax,%rax
je     1171 <boot_uname_r_str+0x21>
lea    0xea2(%rip),%rbx
jmp    11b5 <boot_uname_r_str+0x65>
lea    0xe88(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
add    %ebx,%eax
add    $0x1,%eax
movslq %eax,%rdi
call   1060 <xmalloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.utsname = type { i8* }
@.str = [1 x i8] zeroinitializer
@.str.1 = [18 x i8] c"/boot/System.map-\00"
define i8* @boot_uname_r_str() {
%1 = alloca i8*
%2 = alloca %struct.utsname
%3 = alloca i8*
%4 = alloca i64
%5 = call i64 @uname(%struct.utsname* %2)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %0
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %1
br label %25
8: ; preds = %0
%9 = call i32 @strlen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i32 0, i32 0
%11 = load i8*, i8** %10
%12 = call i32 @strlen(i8* %11)
%13 = add nsw i32 %9, %12
%14 = add nsw i32 %13, 1
%15 = sext i32 %14 to i64
store i64 %15, i64* %4
%16 = load i64, i64* %4
%17 = call i8* @xmalloc(i64 %16)
store i8* %17, i8** %3
%18 = load i8*, i8** %3
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%20 = load i8*, i8** %3
%21 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i32 0, i32 0
%22 = load i8*, i8** %21
%23 = call i32 @strcat(i8* %20, i8* %22)
%24 = load i8*, i8** %3
store i8* %24, i8** %1
br label %25
25: ; preds = %8, %7
%26 = load i8*, i8** %1
ret i8* %26
}

LLVM IR (-O2):
%struct.utsname = type { i8* }
@.str = [1 x i8] zeroinitializer
@.str.1 = [18 x i8] c"/boot/System.map-\00"
define i8* @boot_uname_r_str() {
%1 = alloca %struct.utsname
%2 = bitcast %struct.utsname* %1 to i8*
%3 = call i64 @uname(%struct.utsname* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %16
5: ; preds = %0
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%7 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 0
%8 = load i8*, i8** %7
%9 = tail call i32 @strlen(i8* %8)
%10 = add i32 %6, 1
%11 = add i32 %10, %9
%12 = sext i32 %11 to i64
%13 = tail call i8* @xmalloc(i64 %12)
%14 = tail call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @strcat(i8* %13, i8* %8)
br label %16
16: ; preds = %0, %5
%17 = phi i8* [ %13, %5 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %0 ]
ret i8* %17
}