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

/* Variables and functions */
int /*<<< orphan*/ SYS_write;
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ syscall(int /*<<< orphan*/, int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
void main() {
  char *hello_with_syscall = "Hello World with syscall\n";
  char *hello_without_syscall = "Hello World without syscall\n";
  char *hello_with_printf = "Hello World with printf\n";
  write(1, hello_without_syscall, strlen(hello_without_syscall));
  syscall(SYS_write, 1, hello_with_syscall, strlen(hello_with_syscall));
  printf("%s", hello_with_printf);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xec0(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xed2(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
mov    $0x1,%esi
call   1060 <syscall@plt>
mov    -0x18(%rbp),%rsi
lea    0xe8b(%rip),%rdi
call   1050 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xecf(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    0x2e7f(%rip),%rax
mov    (%rax),%ebx
lea    0xe8e(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %eax,%ecx
call   1060 <syscall@plt>
lea    0xebe(%rip),%rdi
lea    0xe9e(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Hello World with syscall\0A\00"
@.str.1 = [29 x i8] c"Hello World without syscall\0A\00"
@.str.2 = [25 x i8] c"Hello World with printf\0A\00"
@SYS_write = global i32 0
@.str.3 = [3 x i8] c"%s\00"
define void @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8** %3
%4 = load i8*, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = call i32 @write(i32 1, i8* %4, i32 %6)
%8 = load i32, i32* @SYS_write
%9 = load i8*, i8** %1
%10 = load i8*, i8** %1
%11 = call i32 @strlen(i8* %10)
%12 = call i32 @syscall(i32 %8, i32 1, i8* %9, i32 %11)
%13 = load i8*, i8** %3
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %13)
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"Hello World with syscall\0A\00"
@.str.1 = [29 x i8] c"Hello World without syscall\0A\00"
@.str.2 = [25 x i8] c"Hello World with printf\0A\00"
@SYS_write = global i32 0
@.str.3 = [3 x i8] c"%s\00"
define void @main() {
%1 = tail call i32 @strlen(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%3 = load i32, i32* @SYS_write
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @syscall(i32 %3, i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
ret void
}