#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*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int STDOUT_FILENO;
int fcntl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  char line[256];
  int inf, flags, i;
  if (argc < 2) {
    printf("Syntax:  nbecho <argument>\n");
    return 1;
  }
  inf = STDOUT_FILENO;
  flags = fcntl(inf, F_GETFL);
  flags |= O_NONBLOCK;
  fcntl(inf, F_SETFL, flags);
  strcpy(line, "");
  for (i = 1; i < argc; i++)
    strcat(line, argv[i]);
  fprintf(stdout, "%s\n", line);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    118b <main+0x3b>
lea    0xe86(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1265 <main+0x115>
mov    0x2e5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x114(%rbp)
mov    -0x114(%rbp),%edi
mov    0x2e21(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1040 <fcntl@plt>
mov    %eax,-0x118(%rbp)
mov    0x2e23(%rip),%rax
mov    (%rax),%eax
or     -0x118(%rbp),%eax
mov    %eax,-0x118(%rbp)
mov    -0x114(%rbp),%edi
mov    0x2df8(%rip),%rax
mov    (%rax),%esi
mov    -0x118(%rbp),%edx
mov    $0x0,%al
call   1040 <fcntl@plt>
lea    -0x110(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x11c(%rbp)
mov    -0x11c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1242 <main+0xf2>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x11c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1070 <strcat@plt>
mov    -0x11c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x11c(%rbp)
jmp    1204 <main+0xb4>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rdx
lea    0xdc3(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
cmp    $0x1,%edi
jg     117a <main+0x2a>
lea    0xe99(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    120f <main+0xbf>
mov    %rsi,%r12
mov    %edi,%r14d
mov    0x2e69(%rip),%rax
mov    (%rax),%ebp
mov    0x2e38(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
xor    %eax,%eax
call   1050 <fcntl@plt>
mov    0x2e3e(%rip),%rcx
or     (%rcx),%eax
mov    0x2e25(%rip),%rcx
mov    (%rcx),%esi
mov    %ebp,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <fcntl@plt>
lea    0xe44(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1030 <strcpy@plt>
mov    %r14d,%ebp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12,%rbx,8),%rsi
mov    %r15,%rdi
call   1070 <strcat@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11e0 <main+0x90>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
lea    0xdfb(%rip),%rsi
mov    %rsp,%rdx
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Syntax: nbecho <argument>\0A\00"
@STDOUT_FILENO = global i32 0
@F_GETFL = global i32 0
@O_NONBLOCK = global i32 0
@F_SETFL = global i32 0
@.str.1 = [1 x i8] zeroinitializer
@stdout = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %47
14: ; preds = %2
%15 = load i32, i32* @STDOUT_FILENO
store i32 %15, i32* %7
%16 = load i32, i32* %7
%17 = load i32, i32* @F_GETFL
%18 = call i32 (i32, i32, ...) @fcntl(i32 %16, i32 %17)
store i32 %18, i32* %8
%19 = load i32, i32* @O_NONBLOCK
%20 = load i32, i32* %8
%21 = or i32 %20, %19
store i32 %21, i32* %8
%22 = load i32, i32* %7
%23 = load i32, i32* @F_SETFL
%24 = load i32, i32* %8
%25 = call i32 (i32, i32, ...) @fcntl(i32 %22, i32 %23, i32 %24)
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%27 = call i32 @strcpy(i8* %26, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %9
br label %28
28: ; preds = %40, %14
%29 = load i32, i32* %9
%30 = load i32, i32* %4
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %43
32: ; preds = %28
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%34 = load i8**, i8*** %5
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @strcat(i8* %33, i8* %38)
br label %40
40: ; preds = %32
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 1
store i32 %42, i32* %9
br label %28
43: ; preds = %28
%44 = load i32, i32* @stdout
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %45)
store i32 0, i32* %3
br label %47
47: ; preds = %43, %12
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
@F_GETFL = global i32 0
@O_NONBLOCK = global i32 0
@F_SETFL = global i32 0
@.str.1 = [1 x i8] zeroinitializer
@stdout = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@str = [27 x i8] c"Syntax: nbecho <argument>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %28
8: ; preds = %2
%9 = load i32, i32* @STDOUT_FILENO
%10 = load i32, i32* @F_GETFL
%11 = tail call i32 (i32, i32, ...) @fcntl(i32 %9, i32 %10)
%12 = load i32, i32* @O_NONBLOCK
%13 = or i32 %12, %11
%14 = load i32, i32* @F_SETFL
%15 = tail call i32 (i32, i32, ...) @fcntl(i32 %9, i32 %14, i32 %13)
%16 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%17 = zext i32 %0 to i64
br label %18
18: ; preds = %8, %18
%19 = phi i64 [ 1, %8 ], [ %23, %18 ]
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @strcat(i8* %4, i8* %21)
%23 = add nuw nsw i64 %19, 1
%24 = icmp eq i64 %23, %17
br i1 %24, label %25, label %18
25: ; preds = %18
%26 = load i32, i32* @stdout
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %28
28: ; preds = %25, %6
%29 = phi i32 [ 1, %6 ], [ 0, %25 ]
ret i32 %29
}