#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;
};

/* Variables and functions */
int /*<<< orphan*/ execlp(char *, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sethostname(void *, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ strlen(void *);
int /*<<< orphan*/ uname(struct utsname *);
int child(void *arg) {
  struct utsname uts;
  sethostname(arg, strlen(arg));
  uname(&uts);
  printf("uts.nodename in child: %s\n", uts.nodename);
  sleep(1);
  execlp("bash", "bash", (char *)NULL);
  return 0;
}


x86 assembly (clang, -O0):
<child>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1060 <sethostname@plt>
lea    -0x10(%rbp),%rdi
call   1050 <uname@plt>
mov    -0x10(%rbp),%rsi
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
lea    0xe69(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    %rsi,%rdi
call   1070 <execlp@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<child>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <sethostname@plt>
lea    0x8(%rsp),%rdi
call   1050 <uname@plt>
mov    0x8(%rsp),%rsi
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
lea    0xe78(%rip),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1070 <execlp@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.utsname = type { i8* }
@.str = [27 x i8] c"uts.nodename in child: %s\0A\00"
@.str.1 = [5 x i8] c"bash\00"
define i32 @child(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.utsname
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = call i32 @sethostname(i8* %4, i32 %6)
%8 = call i32 @uname(%struct.utsname* %3)
%9 = getelementptr inbounds %struct.utsname, %struct.utsname* %3, i32 0, i32 0
%10 = load i8*, i8** %9
%11 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = call i32 @sleep(i32 1)
%13 = call i32 @execlp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* null)
ret i32 0
}

LLVM IR (-O2):
%struct.utsname = type { i8* }
@.str = [27 x i8] c"uts.nodename in child: %s\0A\00"
@.str.1 = [5 x i8] c"bash\00"
define i32 @child(i8* %0) {
%2 = alloca %struct.utsname
%3 = bitcast %struct.utsname* %2 to i8*
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32 @sethostname(i8* %0, i32 %4)
%6 = call i32 @uname(%struct.utsname* %2)
%7 = getelementptr inbounds %struct.utsname, %struct.utsname* %2, i64 0, i32 0
%8 = load i8*, i8** %7
%9 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @sleep(i32 1)
%11 = tail call i32 @execlp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* null)
ret i32 0
}