#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 *nodename;
};
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getpid();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int uname(struct utsname *);
int childFunc(void *arg) {
  struct utsname uts;
  pid_t pid = getpid();
  if (uname(&uts) == -1)
    do {
      perror("uname");
      exit(EXIT_FAILURE);
    } while (0);
  printf("uts.nodename in child:  %s from current pid: %d\n", uts.nodename,
         pid);
  printf("child\n");
  sleep(5);
  return 0;
}


x86 assembly (clang, -O0):
<childFunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x14(%rbp)
lea    -0x10(%rbp),%rdi
call   1050 <uname@plt>
cmp    $0xffffffff,%eax
jne    11a7 <childFunc+0x47>
jmp    118d <childFunc+0x2d>
lea    0xe6c(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x5,%edi
call   1080 <sleep@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<childFunc>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%rdi
call   1060 <uname@plt>
cmp    $0xffffffff,%eax
je     11c0 <childFunc+0x50>
mov    0x8(%rsp),%rsi
lea    0xe6d(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x5,%edi
call   1090 <sleep@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe39(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.utsname = type { i8* }
@.str = [6 x i8] c"uname\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [49 x i8] c"uts.nodename in child: %s from current pid: %d\0A\00"
@.str.2 = [7 x i8] c"child\0A\00"
define i32 @childFunc(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.utsname
%4 = alloca i32
store i8* %0, i8** %2
%5 = call i32 (...) @getpid()
store i32 %5, i32* %4
%6 = call i32 @uname(%struct.utsname* %3)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %14
8: ; preds = %1
br label %9
9: ; preds = %8
%10 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; No predecessors!
br label %14
14: ; preds = %13, %1
%15 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 0
%16 = load i8*, i8** %15
%17 = load i32, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @sleep(i32 5)
ret i32 0
}

LLVM IR (-O2):
%struct.utsname = type { i8* }
@.str = [6 x i8] c"uname\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [49 x i8] c"uts.nodename in child: %s from current pid: %d\0A\00"
@str = [6 x i8] c"child\00"
define i32 @childFunc(i8* nocapture readnone %0) {
%2 = alloca %struct.utsname
%3 = bitcast %struct.utsname* %2 to i8*
%4 = tail call i32 (...) @getpid()
%5 = call i32 @uname(%struct.utsname* %2)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %1
%12 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i64 0, i32 0
%13 = load i8*, i8** %12
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %13, i32 %4)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%16 = tail call i32 @sleep(i32 5)
ret i32 0
}