#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 *sysname;
  char *nodename;
  char *release;
  char *version;
  char *machine;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, char *, char *,
                            char *);
int /*<<< orphan*/ strncat(char *, char *, size_t);
int uname(struct utsname *);
int versaoso(char *b, size_t s) {
  struct utsname my_uname;
  if (uname(&my_uname) == -1) {
    printf("uname call failed!");
    return -1;
  } else {
    char buffer[500];
    buffer[0] = '\x0';
    snprintf(buffer, 500,
             "<p><b>O.S.:</b> %s<br><b>Custom Name:</b> %s<br><b>Release:</b> "
             "%s<br><b>Version:</b> %s<br><b>Architecture:</b> %s</p>",
             my_uname.sysname, my_uname.nodename, my_uname.release,
             my_uname.version, my_uname.machine);
    strncat(b, buffer, s);
  }
  return 1;
}


x86 assembly (clang, -O0):
<versaoso>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <uname@plt>
cmp    $0xffffffff,%eax
jne    117d <versaoso+0x3d>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d4 <versaoso+0x94>
movb   $0x0,-0x240(%rbp)
lea    -0x240(%rbp),%rdi
mov    -0x40(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x30(%rbp),%r9
mov    -0x28(%rbp),%r10
mov    -0x20(%rbp),%rax
mov    $0x1f4,%esi
lea    0xe68(%rip),%rdx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <snprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x240(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <strncat@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<versaoso>:
push   %r15
push   %r14
push   %rbx
sub    $0x240,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x18(%rsp),%rdi
call   1050 <uname@plt>
cmp    $0xffffffff,%eax
je     11ac <versaoso+0x6c>
movb   $0x0,0x40(%rsp)
mov    0x18(%rsp),%rcx
mov    0x20(%rsp),%r8
mov    0x28(%rsp),%r9
movups 0x30(%rsp),%xmm0
movups %xmm0,(%rsp)
lea    0xe8e(%rip),%rdx
lea    0x40(%rsp),%r15
mov    %r15,%rdi
mov    $0x1f4,%esi
call   1040 <snprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1060 <strncat@plt>
mov    $0x1,%eax
jmp    11bd <versaoso+0x7d>
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%eax
add    $0x240,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@.str = [19 x i8] c"uname call failed!\00"
@.str.1 = [120 x i8] c"<p><b>O.S.:</b> %s<br><b>Custom Name:</b> %s<br><b>Release:</b> %s<br><b>Version:</b> %s<br><b>Architecture:</b> %s</p>\00"
define i32 @versaoso(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca %struct.utsname
%7 = alloca [500 x i8]
store i8* %0, i8** %4
store i64 %1, i64* %5
%8 = call i32 @uname(%struct.utsname* %6)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %31
12: ; preds = %2
%13 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
store i8 0, i8* %13
%14 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 0
%16 = load i8*, i8** %15
%17 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 1
%18 = load i8*, i8** %17
%19 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 2
%20 = load i8*, i8** %19
%21 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 3
%22 = load i8*, i8** %21
%23 = getelementptr inbounds %struct.utsname, %struct.utsname* %6, i32 0, i32 4
%24 = load i8*, i8** %23
%25 = call i32 @snprintf(i8* %14, i32 500, i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.1, i64 0, i64 0), i8* %16, i8* %18, i8* %20, i8* %22, i8* %24)
%26 = load i8*, i8** %4
%27 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%28 = load i64, i64* %5
%29 = call i32 @strncat(i8* %26, i8* %27, i64 %28)
br label %30
30: ; preds = %12
store i32 1, i32* %3
br label %31
31: ; preds = %30, %10
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
@.str = [19 x i8] c"uname call failed!\00"
@.str.1 = [120 x i8] c"<p><b>O.S.:</b> %s<br><b>Custom Name:</b> %s<br><b>Release:</b> %s<br><b>Version:</b> %s<br><b>Architecture:</b> %s</p>\00"
define i32 @versaoso(i8* %0, i64 %1) {
%3 = alloca %struct.utsname
%4 = alloca [500 x i8]
%5 = bitcast %struct.utsname* %3 to i8*
%6 = call i32 @uname(%struct.utsname* %3)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %24
10: ; preds = %2
%11 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
store i8 0, i8* %11
%12 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 0
%13 = load i8*, i8** %12
%14 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 1
%15 = load i8*, i8** %14
%16 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 2
%17 = load i8*, i8** %16
%18 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 3
%19 = load i8*, i8** %18
%20 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i64 0, i32 4
%21 = load i8*, i8** %20
%22 = call i32 @snprintf(i8* %11, i32 500, i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* %15, i8* %17, i8* %19, i8* %21)
%23 = call i32 @strncat(i8* %0, i8* %11, i64 %1)
br label %24
24: ; preds = %10, %8
%25 = phi i32 [ -1, %8 ], [ 1, %10 ]
ret i32 %25
}