#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 {
  int /*<<< orphan*/ release;
  int /*<<< orphan*/ machine;
  int /*<<< orphan*/ sysname;
};

/* Variables and functions */
int /*<<< orphan*/ fatal(int /*<<< orphan*/, char *);
scalar_t__ uname(struct utsname *);
char *vstrcat(int /*<<< orphan*/, char *, int /*<<< orphan*/, char *,
              int /*<<< orphan*/, int /*<<< orphan*/ *);
extern char *str_arch() {
  static char *arch = 0;
  if (!arch) {
    struct utsname buf;
    if (uname(&buf))
      fatal(0, "str_arch(): uname() failed");
    arch = vstrcat(buf.sysname, "_", buf.machine, "_", buf.release, NULL);
  }
  return arch;
}


x86 assembly (clang, -O0):
<str_arch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cmpq   $0x0,0x2f00(%rip)
jne    118c <str_arch+0x5c>
lea    -0x10(%rbp),%rdi
call   1030 <uname@plt>
cmp    $0x0,%rax
je     1167 <str_arch+0x37>
xor    %edi,%edi
lea    0xe9e(%rip),%rsi
call   1040 <fatal@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%r8d
lea    0xea3(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r9d
mov    %rcx,%rsi
call   1050 <vstrcat@plt>
mov    %rax,0x2eb4(%rip)
mov    0x2ead(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_arch>:
sub    $0x18,%rsp
mov    0x2f05(%rip),%rax
test   %rax,%rax
je     1145 <str_arch+0x15>
add    $0x18,%rsp
ret
lea    0x8(%rsp),%rdi
call   1030 <uname@plt>
test   %rax,%rax
je     1162 <str_arch+0x32>
lea    0xea5(%rip),%rsi
xor    %edi,%edi
call   1040 <fatal@plt>
mov    0x10(%rsp),%edi
mov    0x8(%rsp),%r8d
mov    0xc(%rsp),%edx
lea    0xea5(%rip),%rcx
mov    %rcx,%rsi
xor    %r9d,%r9d
call   1050 <vstrcat@plt>
mov    %rax,0x2eb8(%rip)
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.utsname = type { i32, i32, i32 }
@str_arch.arch = internal global i8* null
@.str = [27 x i8] c"str_arch(): uname() failed\00"
@.str.1 = [2 x i8] c"_\00"
define i8* @str_arch() {
%1 = alloca %struct.utsname
%2 = load i8*, i8** @str_arch.arch
%3 = icmp ne i8* %2, null
br i1 %3, label %17, label %4
4: ; preds = %0
%5 = call i64 @uname(%struct.utsname* %1)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = call i32 @fatal(i32 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %4
%10 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 2
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 1
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 0
%15 = load i32, i32* %14
%16 = call i8* @vstrcat(i32 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32* null)
store i8* %16, i8** @str_arch.arch
br label %17
17: ; preds = %9, %0
%18 = load i8*, i8** @str_arch.arch
ret i8* %18
}

LLVM IR (-O2):
%struct.utsname = type { i32, i32, i32 }
@str_arch.arch = internal unnamed_addr global i8* null
@.str = [27 x i8] c"str_arch(): uname() failed\00"
@.str.1 = [2 x i8] c"_\00"
define i8* @str_arch() {
%1 = alloca %struct.utsname
%2 = load i8*, i8** @str_arch.arch
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %18
4: ; preds = %0
%5 = bitcast %struct.utsname* %1 to i8*
%6 = call i64 @uname(%struct.utsname* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call i32 @fatal(i32 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %4
%11 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 2
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 1
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 0
%16 = load i32, i32* %15
%17 = tail call i8* @vstrcat(i32 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32* null)
store i8* %17, i8** @str_arch.arch
br label %18
18: ; preds = %10, %0
%19 = phi i8* [ %17, %10 ], [ %2, %0 ]
ret i8* %19
}