#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 */
typedef int /*<<< orphan*/ str;

/* Variables and functions */
scalar_t__ EFAULT;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ assert(int);
scalar_t__ errno;
int write(int /*<<< orphan*/, char const *, int);
int main(int argc, char **argv) {
  const char str[] = "Hello world from a user program!\n";
  assert(write(STDOUT_FILENO, str, sizeof(str) - 1) == sizeof(str) - 1);
  assert(write(STDOUT_FILENO, (char *)0xDEADC0DE, 100) == -1);
  assert(errno == EFAULT);
  assert(write(STDOUT_FILENO, (char *)0x1EE7C0DE, 100) == -1);
  assert(errno == EFAULT);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x22,%edx
call   1050 <memcpy@plt>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rsi
mov    $0x21,%edx
call   1030 <write@plt>
cltq
cmp    $0x21,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
mov    $0xdeadc0de,%esi
mov    $0x64,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%rax
mov    0x2e3a(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
mov    $0x1ee7c0de,%esi
mov    $0x64,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    0x2dd3(%rip),%rax
mov    (%rax),%rax
mov    0x2df1(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    $0x1,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
movaps 0xee0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0xa,0x20(%rsp)
mov    0x2e9a(%rip),%r14
mov    (%r14),%edi
mov    %rsp,%rsi
mov    $0x21,%edx
call   1030 <write@plt>
xor    %edi,%edi
cmp    $0x21,%eax
sete   %dil
call   1040 <assert@plt>
mov    (%r14),%edi
mov    $0xdeadc0de,%esi
mov    $0x64,%edx
call   1030 <write@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1040 <assert@plt>
mov    0x2e3d(%rip),%rbx
mov    (%rbx),%rax
mov    0x2e5b(%rip),%r15
xor    %edi,%edi
cmp    (%r15),%rax
sete   %dil
call   1040 <assert@plt>
mov    (%r14),%edi
mov    $0x1ee7c0de,%esi
mov    $0x64,%edx
call   1030 <write@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1040 <assert@plt>
mov    (%rbx),%rax
xor    %edi,%edi
cmp    (%r15),%rax
sete   %dil
call   1040 <assert@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.str = [34 x i8] c"Hello world from a user program!\0A\00"
@STDOUT_FILENO = global i32 0
@errno = global i64 0
@EFAULT = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [34 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = bitcast [34 x i8]* %6 to i8*
%8 = load i32, i32* @STDOUT_FILENO
%9 = getelementptr inbounds [34 x i8], [34 x i8]* %6, i64 0, i64 0
%10 = call i32 @write(i32 %8, i8* %9, i32 33)
%11 = sext i32 %10 to i64
%12 = icmp eq i64 %11, 33
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i32, i32* @STDOUT_FILENO
%16 = call i32 @write(i32 %15, i8* inttoptr (i64 3735929054 to i8*), i32 100)
%17 = icmp eq i32 %16, -1
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i64, i64* @errno
%21 = load i64, i64* @EFAULT
%22 = icmp eq i64 %20, %21
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32, i32* @STDOUT_FILENO
%26 = call i32 @write(i32 %25, i8* inttoptr (i64 518504670 to i8*), i32 100)
%27 = icmp eq i32 %26, -1
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load i64, i64* @errno
%31 = load i64, i64* @EFAULT
%32 = icmp eq i64 %30, %31
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
ret i32 1
}

LLVM IR (-O2):
@__const.main.str = [34 x i8] c"Hello world from a user program!\0A\00"
@STDOUT_FILENO = global i32 0
@errno = global i64 0
@EFAULT = global i64 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [34 x i8]
%4 = getelementptr inbounds [34 x i8], [34 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @STDOUT_FILENO
%6 = call i32 @write(i32 %5, i8* %4, i32 33)
%7 = icmp eq i32 %6, 33
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = load i32, i32* @STDOUT_FILENO
%11 = tail call i32 @write(i32 %10, i8* inttoptr (i64 3735929054 to i8*), i32 100)
%12 = icmp eq i32 %11, -1
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = load i64, i64* @errno
%16 = load i64, i64* @EFAULT
%17 = icmp eq i64 %15, %16
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
%20 = load i32, i32* @STDOUT_FILENO
%21 = tail call i32 @write(i32 %20, i8* inttoptr (i64 518504670 to i8*), i32 100)
%22 = icmp eq i32 %21, -1
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
%25 = load i64, i64* @errno
%26 = load i64, i64* @EFAULT
%27 = icmp eq i64 %25, %26
%28 = zext i1 %27 to i32
%29 = tail call i32 @assert(i32 %28)
ret i32 1
}