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

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int builtin_echo(int line, int argc, char **argv, time_t stoptime) {
  int i;
  int do_newline = 1;
  for (i = 1; i < argc; i++) {
    if (!strcmp(argv[i], "-n")) {
      do_newline = 0;
      continue;
    } else {
      printf("%s", argv[i]);
      if (i != (argc - 1))
        printf(" ");
    }
  }
  if (do_newline)
    printf("\n");
  fflush(stdout);
  return 1;
}


x86 assembly (clang, -O0):
<builtin_echo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11dd <builtin_echo+0xad>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe8e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    118c <builtin_echo+0x5c>
movl   $0x0,-0x1c(%rbp)
jmp    11cf <builtin_echo+0x9f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11c5 <builtin_echo+0x95>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ca <builtin_echo+0x9a>
jmp    11cf <builtin_echo+0x9f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1153 <builtin_echo+0x23>
cmpl   $0x0,-0x1c(%rbp)
je     11f5 <builtin_echo+0xc5>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<builtin_echo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%esi
jl     11c1 <builtin_echo+0x81>
mov    %rdx,%r12
lea    -0x1(%rsi),%r13d
mov    %esi,%ebp
mov    $0x1,%ecx
mov    $0x1,%r15d
jmp    117c <builtin_echo+0x3c>
cs nopw 0x0(%rax,%rax,1)
mov    %r14d,%ecx
add    $0x1,%r15
cmp    %r15,%rbp
je     11bd <builtin_echo+0x7d>
mov    %ecx,%r14d
mov    (%r12,%r15,8),%rbx
mov    %rbx,%rdi
lea    0xe73(%rip),%rsi
call   1050 <strcmp@plt>
mov    $0x0,%ecx
test   %eax,%eax
je     1173 <builtin_echo+0x33>
lea    0xe61(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r15,%r13
je     1170 <builtin_echo+0x30>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1170 <builtin_echo+0x30>
test   %ecx,%ecx
je     11cb <builtin_echo+0x8b>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"-n\00"
@.str.1 = [3 x i8] c"%s\00"
@stdout = global i32 0
define i32 @builtin_echo(i32 %0, i32 %1, i8** nocapture %2, i32 %3) {
%5 = icmp sgt i32 %1, 1
br i1 %5, label %6, label %28
6: ; preds = %4
%7 = add nsw i32 %1, -1
%8 = zext i32 %7 to i64
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %6, %22
%11 = phi i64 [ 1, %6 ], [ %24, %22 ]
%12 = phi i32 [ 1, %6 ], [ %23, %22 ]
%13 = getelementptr inbounds i8*, i8** %2, i64 %11
%14 = load i8*, i8** %13
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %14, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %10
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%19 = icmp eq i64 %11, %8
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 @putchar(i32 32)
br label %22
22: ; preds = %10, %20, %17
%23 = phi i32 [ %12, %20 ], [ %12, %17 ], [ 0, %10 ]
%24 = add nuw nsw i64 %11, 1
%25 = icmp eq i64 %24, %9
br i1 %25, label %26, label %10
26: ; preds = %22
%27 = icmp eq i32 %23, 0
br i1 %27, label %30, label %28
28: ; preds = %4, %26
%29 = tail call i32 @putchar(i32 10)
br label %30
30: ; preds = %28, %26
%31 = load i32, i32* @stdout
%32 = tail call i32 @fflush(i32 %31)
ret i32 1
}