#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ __NR_write;
int /*<<< orphan*/ err(int /*<<< orphan*/, char *);
long syscall(int /*<<< orphan*/, int, char const *, int);
int main(int argc, char **argv) {
  const char buf[] = "Hello world\n";
  long ret = syscall(__NR_write, 1, buf, sizeof(buf) - 1);
  if (ret < 0)
    err(EXIT_FAILURE, "write syscall");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x1d(%rbp)
mov    0xec1(%rip),%eax
mov    %eax,-0x15(%rbp)
mov    0xebc(%rip),%al
mov    %al,-0x11(%rbp)
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
lea    -0x1d(%rbp),%rdx
mov    $0x1,%esi
mov    $0xc,%ecx
call   1030 <syscall@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jge    1193 <main+0x73>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
call   1040 <err@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movabs $0xa646c726f7720,%rax
mov    %rax,0xd(%rsp)
movabs $0x6f77206f6c6c6548,%rax
20 77 6f
mov    %rax,0x8(%rsp)
mov    0x2e9f(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rdx
mov    $0x1,%esi
mov    $0xc,%ecx
call   1030 <syscall@plt>
test   %rax,%rax
jns    1179 <main+0x59>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
call   1040 <err@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.buf = [13 x i8] c"Hello world\0A\00"
@__NR_write = global i32 0
@EXIT_FAILURE = global i32 0
@.str = [14 x i8] c"write syscall\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [13 x i8]
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [13 x i8]* %6 to i8*
%9 = load i32, i32* @__NR_write
%10 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 0
%11 = call i64 @syscall(i32 %9, i32 1, i8* %10, i32 12)
store i64 %11, i64* %7
%12 = load i64, i64* %7
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @err(i32 %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %14, %2
ret i32 0
}

LLVM IR (-O2):
@__const.main.buf = [13 x i8] c"Hello world\0A\00"
@__NR_write = global i32 0
@EXIT_FAILURE = global i32 0
@.str = [14 x i8] c"write syscall\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [13 x i8]
%4 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @__NR_write
%6 = call i64 @syscall(i32 %5, i32 1, i8* %4, i32 12)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @err(i32 %9, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %8, %2
ret i32 0
}